Bug 1845057 - Remove aClaimAllTypes from setDefaultBrowser. r=nrishel,settings-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D189678
This commit is contained in:
@@ -584,7 +584,7 @@ nsBrowserContentHandler.prototype = {
|
||||
}
|
||||
}
|
||||
if (cmdLine.handleFlag("setDefaultBrowser", false)) {
|
||||
lazy.ShellService.setDefaultBrowser(true, true);
|
||||
lazy.ShellService.setDefaultBrowser(true);
|
||||
}
|
||||
|
||||
if (cmdLine.handleFlag("first-startup", false)) {
|
||||
@@ -923,20 +923,6 @@ nsBrowserContentHandler.prototype = {
|
||||
) {
|
||||
throw Components.Exception("", Cr.NS_ERROR_ABORT);
|
||||
}
|
||||
var isDefault = false;
|
||||
try {
|
||||
var url =
|
||||
Services.urlFormatter.formatURLPref("app.support.baseURL") +
|
||||
"win10-default-browser";
|
||||
if (urlParam == url) {
|
||||
isDefault = lazy.ShellService.isDefaultBrowser(false, false);
|
||||
}
|
||||
} catch (ex) {}
|
||||
if (isDefault) {
|
||||
// Firefox is already the default HTTP handler.
|
||||
// We don't have to show the instruction page.
|
||||
throw Components.Exception("", Cr.NS_ERROR_ABORT);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1724,7 +1724,7 @@ var gMainPane = {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
shellSvc.setDefaultBrowser(true, false);
|
||||
shellSvc.setDefaultBrowser(false);
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
return;
|
||||
|
||||
@@ -339,7 +339,7 @@ let ShellServiceInternal = {
|
||||
},
|
||||
|
||||
// override nsIShellService.setDefaultBrowser() on the ShellService proxy.
|
||||
setDefaultBrowser(claimAllTypes, forAllUsers) {
|
||||
setDefaultBrowser(forAllUsers) {
|
||||
// On Windows 10, our best chance is to set UserChoice, so try that first.
|
||||
if (
|
||||
AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
|
||||
@@ -353,29 +353,18 @@ let ShellServiceInternal = {
|
||||
// to fall back in case it fails.
|
||||
this.setAsDefaultUserChoice().catch(err => {
|
||||
console.error(err);
|
||||
this.shellService.setDefaultBrowser(claimAllTypes, forAllUsers);
|
||||
this.shellService.setDefaultBrowser(forAllUsers);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.shellService.setDefaultBrowser(claimAllTypes, forAllUsers);
|
||||
this.shellService.setDefaultBrowser(forAllUsers);
|
||||
},
|
||||
|
||||
setAsDefault() {
|
||||
let claimAllTypes = true;
|
||||
let setAsDefaultError = false;
|
||||
if (AppConstants.platform == "win") {
|
||||
try {
|
||||
// In Windows 8+, the UI for selecting default protocol is much
|
||||
// nicer than the UI for setting file type associations. So we
|
||||
// only show the protocol association screen on Windows 8+.
|
||||
// Windows 8 is version 6.2.
|
||||
let version = Services.sysinfo.getProperty("version");
|
||||
claimAllTypes = parseFloat(version) < 6.2;
|
||||
} catch (ex) {}
|
||||
}
|
||||
try {
|
||||
ShellService.setDefaultBrowser(claimAllTypes, false);
|
||||
ShellService.setDefaultBrowser(false);
|
||||
} catch (ex) {
|
||||
setAsDefaultError = true;
|
||||
console.error(ex);
|
||||
|
||||
@@ -253,7 +253,7 @@ nsGNOMEShellService::IsDefaultForScheme(const nsACString& aScheme,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) {
|
||||
nsGNOMEShellService::SetDefaultBrowser(bool aForAllUsers) {
|
||||
#ifdef DEBUG
|
||||
if (aForAllUsers)
|
||||
NS_WARNING(
|
||||
@@ -299,14 +299,11 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) {
|
||||
|
||||
// set handler for the protocols
|
||||
for (unsigned int i = 0; i < ArrayLength(appProtocols); ++i) {
|
||||
if (appProtocols[i].essential || aClaimAllTypes) {
|
||||
appInfo->SetAsDefaultForURIScheme(
|
||||
nsDependentCString(appProtocols[i].name));
|
||||
}
|
||||
}
|
||||
|
||||
// set handler for .html and xhtml files and MIME types:
|
||||
if (aClaimAllTypes) {
|
||||
// Add mime types for html, xhtml extension and set app to just created
|
||||
// appinfo.
|
||||
for (unsigned int i = 0; i < ArrayLength(appTypes); ++i) {
|
||||
@@ -316,7 +313,6 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) {
|
||||
nsDependentCString(appTypes[i].extensions));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefs) {
|
||||
|
||||
@@ -26,14 +26,11 @@ interface nsIShellService : nsISupports
|
||||
/**
|
||||
* Registers Firefox as the "Default Browser."
|
||||
*
|
||||
* @param aClaimAllTypes Register Firefox as the handler for
|
||||
* additional protocols (chrome etc)
|
||||
* and web documents (.html, .xhtml etc).
|
||||
* @param aForAllUsers Whether or not Firefox should attempt
|
||||
* to become the default browser for all
|
||||
* users on a multi-user system.
|
||||
*/
|
||||
void setDefaultBrowser(in boolean aClaimAllTypes, in boolean aForAllUsers);
|
||||
void setDefaultBrowser(in boolean aForAllUsers);
|
||||
|
||||
/**
|
||||
* Flags for positioning/sizing of the Desktop Background image.
|
||||
|
||||
@@ -68,7 +68,7 @@ nsMacShellService::IsDefaultBrowser(bool aForAllTypes,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) {
|
||||
nsMacShellService::SetDefaultBrowser(bool aForAllUsers) {
|
||||
// Note: We don't support aForAllUsers on Mac OS X.
|
||||
|
||||
CFStringRef firefoxID = ::CFBundleGetIdentifier(::CFBundleGetMainBundle());
|
||||
@@ -83,12 +83,10 @@ nsMacShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aClaimAllTypes) {
|
||||
if (::LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesAll,
|
||||
firefoxID) != noErr) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefs) {
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIWindowsRegKey.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIURLFormatter.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
@@ -294,10 +293,6 @@ nsresult nsWindowsShellService::LaunchControlPanelDefaultsSelectionUI() {
|
||||
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult nsWindowsShellService::LaunchControlPanelDefaultPrograms() {
|
||||
return ::LaunchControlPanelDefaultPrograms() ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::CheckAllProgIDsExist(bool* aResult) {
|
||||
*aResult = false;
|
||||
@@ -336,36 +331,8 @@ nsresult nsWindowsShellService::LaunchModernSettingsDialogDefaultApps() {
|
||||
return ::LaunchModernSettingsDialogDefaultApps() ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult nsWindowsShellService::InvokeHTTPOpenAsVerb() {
|
||||
nsCOMPtr<nsIURLFormatter> formatter(
|
||||
do_GetService("@mozilla.org/toolkit/URLFormatterService;1"));
|
||||
if (!formatter) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsString urlStr;
|
||||
nsresult rv = formatter->FormatURLPref(u"app.support.baseURL"_ns, urlStr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (!StringBeginsWith(urlStr, u"https://"_ns)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
urlStr.AppendLiteral("win10-default-browser");
|
||||
|
||||
SHELLEXECUTEINFOW seinfo = {sizeof(SHELLEXECUTEINFOW)};
|
||||
seinfo.lpVerb = L"openas";
|
||||
seinfo.lpFile = urlStr.get();
|
||||
seinfo.nShow = SW_SHOWNORMAL;
|
||||
if (!ShellExecuteExW(&seinfo)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes,
|
||||
bool aForAllUsers) {
|
||||
nsWindowsShellService::SetDefaultBrowser(bool aForAllUsers) {
|
||||
// If running from within a package, don't attempt to set default with
|
||||
// the helper, as it will not work and will only confuse our package's
|
||||
// virtualized registry.
|
||||
@@ -384,14 +351,6 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes,
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (aClaimAllTypes) {
|
||||
rv = LaunchModernSettingsDialogDefaultApps();
|
||||
// The above call should never really fail, but just in case
|
||||
// fall back to showing the HTTP association screen only.
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = InvokeHTTPOpenAsVerb();
|
||||
}
|
||||
} else {
|
||||
rv = LaunchModernSettingsDialogDefaultApps();
|
||||
// The above call should never really fail, but just in case
|
||||
// fall back to showing control panel for all defaults
|
||||
@@ -399,7 +358,6 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes,
|
||||
rv = LaunchControlPanelDefaultsSelectionUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefs) {
|
||||
|
||||
@@ -29,9 +29,7 @@ class nsWindowsShellService : public nsIShellService,
|
||||
|
||||
protected:
|
||||
nsresult LaunchControlPanelDefaultsSelectionUI();
|
||||
nsresult LaunchControlPanelDefaultPrograms();
|
||||
nsresult LaunchModernSettingsDialogDefaultApps();
|
||||
nsresult InvokeHTTPOpenAsVerb();
|
||||
};
|
||||
|
||||
#endif // nswindowsshellservice_h____
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function test() {
|
||||
ShellService.setDefaultBrowser(true, false);
|
||||
ShellService.setDefaultBrowser(false);
|
||||
ok(
|
||||
ShellService.isDefaultBrowser(true, false),
|
||||
"we got here and are the default browser"
|
||||
|
||||
@@ -1662,7 +1662,7 @@ export var UITour = {
|
||||
try {
|
||||
let shell = aWindow.getShellService();
|
||||
if (shell) {
|
||||
shell.setDefaultBrowser(true, false);
|
||||
shell.setDefaultBrowser(false);
|
||||
}
|
||||
} catch (e) {}
|
||||
break;
|
||||
|
||||
@@ -15,7 +15,7 @@ MockShellService.prototype = {
|
||||
isDefaultBrowser(aStartupCheck, aForAllTypes) {
|
||||
return false;
|
||||
},
|
||||
setDefaultBrowser(aClaimAllTypes, aForAllUsers) {
|
||||
setDefaultBrowser(aForAllUsers) {
|
||||
setDefaultBrowserCalled = true;
|
||||
},
|
||||
shouldCheckDefaultBrowser: false,
|
||||
|
||||
Reference in New Issue
Block a user