summaryrefslogtreecommitdiffstats
path: root/uriloader
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-10 11:39:27 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-10 11:39:27 +0100
commit974a481d12bf430891725bd3662876358e57e11a (patch)
treecad011151456251fef2f1b8d02ef4b4e45fad61a /uriloader
parent6bd66b1728eeddb058066edda740aaeb2ceaec23 (diff)
parent736d25cbec4541186ed46c935c117ce4d1c7f3bb (diff)
downloadUXP-974a481d12bf430891725bd3662876358e57e11a.tar
UXP-974a481d12bf430891725bd3662876358e57e11a.tar.gz
UXP-974a481d12bf430891725bd3662876358e57e11a.tar.lz
UXP-974a481d12bf430891725bd3662876358e57e11a.tar.xz
UXP-974a481d12bf430891725bd3662876358e57e11a.zip
Merge branch 'master' into js-modules
# Conflicts: # modules/libpref/init/all.js
Diffstat (limited to 'uriloader')
-rw-r--r--uriloader/exthandler/nsHandlerService.js16
-rw-r--r--uriloader/exthandler/win/nsOSHelperAppService.cpp192
-rw-r--r--uriloader/prefetch/nsOfflineCacheUpdate.h1
-rw-r--r--uriloader/prefetch/nsOfflineCacheUpdateService.cpp32
4 files changed, 63 insertions, 178 deletions
diff --git a/uriloader/exthandler/nsHandlerService.js b/uriloader/exthandler/nsHandlerService.js
index c932f9f5d..5e6356ac2 100644
--- a/uriloader/exthandler/nsHandlerService.js
+++ b/uriloader/exthandler/nsHandlerService.js
@@ -352,17 +352,11 @@ HandlerService.prototype = {
var prefSvc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
var prefBranch = prefSvc.getBranch("network.protocol-handler.");
- try {
- alwaysAsk = prefBranch.getBoolPref("warn-external." + type);
- } catch (e) {
- // will throw if pref didn't exist.
- try {
- alwaysAsk = prefBranch.getBoolPref("warn-external-default");
- } catch (e) {
- // Nothing to tell us what to do, so be paranoid and prompt.
- alwaysAsk = true;
- }
- }
+ // If neither of the prefs exists, be paranoid and prompt.
+ alwaysAsk =
+ prefBranch.getBoolPref("warn-external." + type,
+ prefBranch.getBoolPref("warn-external-default",
+ true));
}
aHandlerInfo.alwaysAskBeforeHandling = alwaysAsk;
diff --git a/uriloader/exthandler/win/nsOSHelperAppService.cpp b/uriloader/exthandler/win/nsOSHelperAppService.cpp
index f01f3b49b..48b6f1795 100644
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -29,8 +29,6 @@
#define LOG(args) MOZ_LOG(mLog, mozilla::LogLevel::Debug, args)
// helper methods: forward declarations...
-static nsresult GetExtensionFrom4xRegistryInfo(const nsACString& aMimeType,
- nsString& aFileExtension);
static nsresult GetExtensionFromWindowsMimeDatabase(const nsACString& aMimeType,
nsString& aFileExtension);
@@ -77,79 +75,45 @@ static nsresult GetExtensionFromWindowsMimeDatabase(const nsACString& aMimeType,
return NS_OK;
}
-// We have a serious problem!! I have this content type and the windows registry only gives me
-// helper apps based on extension. Right now, we really don't have a good place to go for
-// trying to figure out the extension for a particular mime type....One short term hack is to look
-// this information in 4.x (it's stored in the windows regsitry).
-static nsresult GetExtensionFrom4xRegistryInfo(const nsACString& aMimeType,
- nsString& aFileExtension)
-{
- nsCOMPtr<nsIWindowsRegKey> regKey =
- do_CreateInstance("@mozilla.org/windows-registry-key;1");
- if (!regKey)
- return NS_ERROR_NOT_AVAILABLE;
-
- nsresult rv = regKey->
- Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
- NS_LITERAL_STRING("Software\\Netscape\\Netscape Navigator\\Suffixes"),
- nsIWindowsRegKey::ACCESS_QUERY_VALUE);
- if (NS_FAILED(rv))
- return NS_ERROR_NOT_AVAILABLE;
-
- rv = regKey->ReadStringValue(NS_ConvertASCIItoUTF16(aMimeType),
- aFileExtension);
- if (NS_FAILED(rv))
- return NS_OK;
-
- aFileExtension.Insert(char16_t('.'), 0);
-
- // this may be a comma separated list of extensions...just take the
- // first one for now...
-
- int32_t pos = aFileExtension.FindChar(char16_t(','));
- if (pos > 0) {
- // we have a comma separated list of types...
- // truncate everything after the first comma (including the comma)
- aFileExtension.Truncate(pos);
- }
-
- return NS_OK;
-}
-
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists)
{
// look up the protocol scheme in the windows registry....if we find a match then we have a handler for it...
*aHandlerExists = false;
if (aProtocolScheme && *aProtocolScheme)
{
- // Vista: use new application association interface
- if (mAppAssoc) {
- wchar_t * pResult = nullptr;
- NS_ConvertASCIItoUTF16 scheme(aProtocolScheme);
- // We are responsible for freeing returned strings.
- HRESULT hr = mAppAssoc->QueryCurrentDefault(scheme.get(),
- AT_URLPROTOCOL, AL_EFFECTIVE,
- &pResult);
- if (SUCCEEDED(hr)) {
- CoTaskMemFree(pResult);
- *aHandlerExists = true;
+ NS_ENSURE_TRUE(mAppAssoc, NS_ERROR_NOT_AVAILABLE);
+ wchar_t * pResult = nullptr;
+ NS_ConvertASCIItoUTF16 scheme(aProtocolScheme);
+ // We are responsible for freeing returned strings.
+ HRESULT hr = mAppAssoc->QueryCurrentDefault(scheme.get(),
+ AT_URLPROTOCOL, AL_EFFECTIVE,
+ &pResult);
+ if (SUCCEEDED(hr)) {
+ CoTaskMemFree(pResult);
+ // Check the registry to see if it's a valid handler.
+ nsCOMPtr<nsIWindowsRegKey> regKey = do_CreateInstance("@mozilla.org/windows-registry-key;1");
+ if (!regKey) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+
+ nsresult rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
+ nsDependentString(scheme.get()),
+ nsIWindowsRegKey::ACCESS_QUERY_VALUE);
+ if (NS_FAILED(rv)) {
+ // Open will fail if the registry key path doesn't exist.
+ return NS_OK;
+ }
+
+ bool hasValue;
+ rv = regKey->HasValue(NS_LITERAL_STRING("URL Protocol"), &hasValue);
+ if (NS_FAILED(rv)) {
+ return NS_ERROR_FAILURE;
+ }
+ if (!hasValue) {
+ return NS_OK;
}
- return NS_OK;
- }
- HKEY hKey;
- LONG err = ::RegOpenKeyExW(HKEY_CLASSES_ROOT,
- NS_ConvertASCIItoUTF16(aProtocolScheme).get(),
- 0,
- KEY_QUERY_VALUE,
- &hKey);
- if (err == ERROR_SUCCESS)
- {
- err = ::RegQueryValueExW(hKey, L"URL Protocol",
- nullptr, nullptr, nullptr, nullptr);
- *aHandlerExists = (err == ERROR_SUCCESS);
- // close the key
- ::RegCloseKey(hKey);
+ *aHandlerExists = true;
}
}
@@ -180,40 +144,21 @@ NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString&
}
}
- if (mAppAssoc) {
- // Vista: use new application association interface
- wchar_t * pResult = nullptr;
- // We are responsible for freeing returned strings.
- HRESULT hr = mAppAssoc->QueryCurrentDefault(buf.get(),
- AT_URLPROTOCOL, AL_EFFECTIVE,
- &pResult);
- if (SUCCEEDED(hr)) {
- nsCOMPtr<nsIFile> app;
- nsAutoString appInfo(pResult);
- CoTaskMemFree(pResult);
- if (NS_SUCCEEDED(GetDefaultAppInfo(appInfo, _retval, getter_AddRefs(app))))
- return NS_OK;
- }
- return NS_ERROR_NOT_AVAILABLE;
+ NS_ENSURE_TRUE(mAppAssoc, NS_ERROR_NOT_AVAILABLE);
+ wchar_t * pResult = nullptr;
+ // We are responsible for freeing returned strings.
+ HRESULT hr = mAppAssoc->QueryCurrentDefault(buf.get(),
+ AT_URLPROTOCOL, AL_EFFECTIVE,
+ &pResult);
+ if (SUCCEEDED(hr)) {
+ nsCOMPtr<nsIFile> app;
+ nsAutoString appInfo(pResult);
+ CoTaskMemFree(pResult);
+ if (NS_SUCCEEDED(GetDefaultAppInfo(appInfo, _retval, getter_AddRefs(app))))
+ return NS_OK;
}
- nsCOMPtr<nsIFile> app;
- GetDefaultAppInfo(buf, _retval, getter_AddRefs(app));
-
- if (!_retval.Equals(buf))
- return NS_OK;
-
- // Fall back to full path
- buf.AppendLiteral("\\shell\\open\\command");
- nsresult rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
- buf,
- nsIWindowsRegKey::ACCESS_QUERY_VALUE);
- if (NS_FAILED(rv))
- return NS_ERROR_NOT_AVAILABLE;
-
- rv = regKey->ReadStringValue(EmptyString(), _retval);
-
- return NS_SUCCEEDED(rv) ? NS_OK : NS_ERROR_NOT_AVAILABLE;
+ return NS_ERROR_NOT_AVAILABLE;
}
// GetMIMEInfoFromRegistry: This function obtains the values of some of the nsIMIMEInfo
@@ -421,36 +366,18 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelperAppService::GetByExtension(const nsAFl
bool found;
// Retrieve the default application for this extension
- if (mAppAssoc) {
- // Vista: use the new application association COM interfaces
- // for resolving helpers.
- nsString assocType(fileExtToUse);
- wchar_t * pResult = nullptr;
- HRESULT hr = mAppAssoc->QueryCurrentDefault(assocType.get(),
- AT_FILEEXTENSION, AL_EFFECTIVE,
- &pResult);
- if (SUCCEEDED(hr)) {
- found = true;
- appInfo.Assign(pResult);
- CoTaskMemFree(pResult);
- }
- else {
- found = false;
- }
- }
- else
- {
- nsCOMPtr<nsIWindowsRegKey> regKey =
- do_CreateInstance("@mozilla.org/windows-registry-key;1");
- if (!regKey)
- return nullptr;
- nsresult rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
- fileExtToUse,
- nsIWindowsRegKey::ACCESS_QUERY_VALUE);
- if (NS_SUCCEEDED(rv)) {
- found = NS_SUCCEEDED(regKey->ReadStringValue(EmptyString(),
- appInfo));
- }
+ NS_ENSURE_TRUE(mAppAssoc, nullptr);
+ nsString assocType(fileExtToUse);
+ wchar_t * pResult = nullptr;
+ HRESULT hr = mAppAssoc->QueryCurrentDefault(assocType.get(),
+ AT_FILEEXTENSION, AL_EFFECTIVE,
+ &pResult);
+ if (SUCCEEDED(hr)) {
+ found = true;
+ appInfo.Assign(pResult);
+ CoTaskMemFree(pResult);
+ } else {
+ found = false;
}
// Bug 358297 - ignore the default handler, force the user to choose app
@@ -496,14 +423,9 @@ already_AddRefed<nsIMIMEInfo> nsOSHelperAppService::GetMIMEInfoFromOS(const nsAC
* We'll do extension-based lookup for this type later in this function.
*/
if (!aMIMEType.LowerCaseEqualsLiteral(APPLICATION_OCTET_STREAM)) {
- // (1) try to use the windows mime database to see if there is a mapping to a file extension
- // (2) try to see if we have some left over 4.x registry info we can peek at...
+ // try to use the windows mime database to see if there is a mapping to a file extension
GetExtensionFromWindowsMimeDatabase(aMIMEType, fileExtension);
LOG(("Windows mime database: extension '%s'\n", fileExtension.get()));
- if (fileExtension.IsEmpty()) {
- GetExtensionFrom4xRegistryInfo(aMIMEType, fileExtension);
- LOG(("4.x Registry: extension '%s'\n", fileExtension.get()));
- }
}
// If we found an extension for the type, do the lookup
RefPtr<nsMIMEInfoWin> mi;
diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.h b/uriloader/prefetch/nsOfflineCacheUpdate.h
index 4ccba4135..2e6d6d30c 100644
--- a/uriloader/prefetch/nsOfflineCacheUpdate.h
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.h
@@ -375,7 +375,6 @@ private:
bool mDisabled;
bool mUpdateRunning;
- bool mLowFreeSpace;
};
#endif
diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
index adb3fd516..6a67af013 100644
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -39,7 +39,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/Attributes.h"
#include "mozilla/Unused.h"
-#include "nsIDiskSpaceWatcher.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
@@ -246,7 +245,6 @@ NS_IMPL_ISUPPORTS(nsOfflineCacheUpdateService,
nsOfflineCacheUpdateService::nsOfflineCacheUpdateService()
: mDisabled(false)
, mUpdateRunning(false)
- , mLowFreeSpace(false)
{
MOZ_ASSERT(NS_IsMainThread());
Preferences::AddBoolVarCache(&sAllowOfflineCache,
@@ -273,19 +271,6 @@ nsOfflineCacheUpdateService::Init()
true);
NS_ENSURE_SUCCESS(rv, rv);
- // Get the current status of the disk in terms of free space and observe
- // low device storage notifications.
- nsCOMPtr<nsIDiskSpaceWatcher> diskSpaceWatcherService =
- do_GetService("@mozilla.org/toolkit/disk-space-watcher;1");
- if (diskSpaceWatcherService) {
- diskSpaceWatcherService->GetIsDiskFull(&mLowFreeSpace);
- } else {
- NS_WARNING("Could not get disk status from nsIDiskSpaceWatcher");
- }
-
- rv = observerService->AddObserver(this, "disk-space-watcher", false);
- NS_ENSURE_SUCCESS(rv, rv);
-
gOfflineCacheUpdateService = this;
return NS_OK;
@@ -407,11 +392,7 @@ nsOfflineCacheUpdateService::ProcessNextUpdate()
if (mUpdates.Length() > 0) {
mUpdateRunning = true;
- // Canceling the update before Begin() call will make the update
- // asynchronously finish with an error.
- if (mLowFreeSpace) {
- mUpdates[0]->Cancel();
- }
+
return mUpdates[0]->Begin();
}
@@ -582,17 +563,6 @@ nsOfflineCacheUpdateService::Observe(nsISupports *aSubject,
mDisabled = true;
}
- if (!strcmp(aTopic, "disk-space-watcher")) {
- if (NS_LITERAL_STRING("full").Equals(aData)) {
- mLowFreeSpace = true;
- for (uint32_t i = 0; i < mUpdates.Length(); i++) {
- mUpdates[i]->Cancel();
- }
- } else if (NS_LITERAL_STRING("free").Equals(aData)) {
- mLowFreeSpace = false;
- }
- }
-
return NS_OK;
}