diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index 4a5268b1db11..69ea5096c710 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -10,6 +10,9 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); Components.utils.import("resource:///modules/RecentWindow.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "ShellService", + "resource:///modules/ShellService.jsm"); + XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); @@ -454,15 +457,10 @@ function gatherTextUnder ( root ) return text; } +// This function exists for legacy reasons. function getShellService() { - var shell = null; - try { - shell = Components.classes["@mozilla.org/browser/shell-service;1"] - .getService(Components.interfaces.nsIShellService); - } catch (e) { - } - return shell; + return ShellService; } function isBidiEnabled() { diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index 93aa8c9cf1e4..d9bbb9f72589 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -12,6 +12,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow", "resource:///modules/RecentWindow.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "ShellService", + "resource:///modules/ShellService.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils", "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"); @@ -660,9 +662,7 @@ nsBrowserContentHandler.prototype = { var url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "win10-default-browser"; if (urlParam == url) { - var shellSvc = Components.classes["@mozilla.org/browser/shell-service;1"] - .getService(Components.interfaces.nsIShellService); - isDefault = shellSvc.isDefaultBrowser(false, false); + isDefault = ShellService.isDefaultBrowser(false, false); } } catch (ex) {} if (isDefault) { diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index ca5915f858d7..ec02a669c43a 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -140,16 +140,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PluginCrashReporter", "resource:///modules/ContentCrashHandlers.jsm"); #endif -XPCOMUtils.defineLazyGetter(this, "ShellService", function() { - try { - return Cc["@mozilla.org/browser/shell-service;1"]. - getService(Ci.nsIShellService); - } - catch(ex) { - return null; - } -}); - XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() { return Services.strings.createBundle('chrome://branding/locale/brand.properties'); }); @@ -180,6 +170,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement", XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "ShellService", + "resource:///modules/ShellService.jsm"); + XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils", "@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils"); diff --git a/browser/components/preferences/in-content/main.js b/browser/components/preferences/in-content/main.js index 067782cc17da..bb8e906f3e3f 100644 --- a/browser/components/preferences/in-content/main.js +++ b/browser/components/preferences/in-content/main.js @@ -5,6 +5,7 @@ Components.utils.import("resource://gre/modules/Downloads.jsm"); Components.utils.import("resource://gre/modules/FileUtils.jsm"); Components.utils.import("resource://gre/modules/Task.jsm"); +Components.utils.import("resource:///modules/ShellService.jsm"); Components.utils.import("resource:///modules/TransientPrefs.jsm"); #ifdef E10S_TESTING_ONLY XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils", diff --git a/browser/components/shell/ShellService.jsm b/browser/components/shell/ShellService.jsm new file mode 100644 index 000000000000..f935eac94a79 --- /dev/null +++ b/browser/components/shell/ShellService.jsm @@ -0,0 +1,86 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this file, +* You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +this.EXPORTED_SYMBOLS = ["ShellService"]; + +const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; + +Cu.import("resource://gre/modules/AppConstants.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +/** + * Internal functionality to save and restore the docShell.allow* properties. + */ +let ShellServiceInternal = { + /** + * Used to determine whether or not to offer "Set as desktop background" + * functionality. Even if shell service is available it is not + * guaranteed that it is able to set the background for every desktop + * which is especially true for Linux with its many different desktop + * environments. + */ + get canSetDesktopBackground() { + if (AppConstants.platform == "win" || + AppConstants.platform == "macosx") { + return true; + } + + if (AppConstants.platform == "linux") { + if (this.shellService) { + let linuxShellService = this.shellService + .QueryInterface(Ci.nsIGNOMEShellService); + return linuxShellService.canSetDesktopBackground; + } + } + + return false; + }, + + /** + * Used to determine whether or not to show a "Set Default Browser" + * query dialog. This attribute is true if the application is starting + * up and "browser.shell.checkDefaultBrowser" is true, otherwise it + * is false. + */ + _checkedThisSession: false, + get shouldCheckDefaultBrowser() { + // If we've already checked, the browser has been started and this is a + // new window open, and we don't want to check again. + if (this._checkedThisSession) { + return false; + } + + return Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"); + }, + set shouldCheckDefaultBrowser(shouldCheck) { + Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", !!shouldCheck); + }, + isDefaultBrowser(startupCheck, forAllTypes) { + // If this is the first browser window, maintain internal state that we've + // checked this session (so that subsequent window opens don't show the + // default browser dialog). + if (startupCheck) { + this._checkedThisSession = true; + } + if (this.shellService) { + return this.shellService.isDefaultBrowser(startupCheck, forAllTypes); + } + } +}; + +XPCOMUtils.defineLazyServiceGetter(ShellServiceInternal, "shellService", + "@mozilla.org/browser/shell-service;1", Ci.nsIShellService); + +/** + * The external API exported by this module. + */ +this.ShellService = new Proxy(ShellServiceInternal, { + get(target, name) { + return name in target ? target[name] : + target.shellService[name]; + } +}); diff --git a/browser/components/shell/moz.build b/browser/components/shell/moz.build index 3a04e8d2aa70..b9d1bee866dd 100644 --- a/browser/components/shell/moz.build +++ b/browser/components/shell/moz.build @@ -21,6 +21,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': XPIDL_SOURCES += [ 'nsIMacShellService.idl', ] +elif CONFIG['MOZ_WIDGET_GTK']: + XPIDL_SOURCES += [ + 'nsIGNOMEShellService.idl', + ] XPIDL_MODULE = 'shellservice' @@ -45,6 +49,10 @@ EXTRA_COMPONENTS += [ 'nsSetDefaultBrowser.manifest', ] +EXTRA_JS_MODULES += [ + 'ShellService.jsm', +] + for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'): DEFINES[var] = '"%s"' % CONFIG[var] diff --git a/browser/components/shell/nsGNOMEShellService.cpp b/browser/components/shell/nsGNOMEShellService.cpp index 523825bf85cf..aef17925b6be 100644 --- a/browser/components/shell/nsGNOMEShellService.cpp +++ b/browser/components/shell/nsGNOMEShellService.cpp @@ -117,7 +117,7 @@ nsGNOMEShellService::Init() return appPath->GetNativePath(mAppPath); } -NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIShellService) +NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIGNOMEShellService, nsIShellService) bool nsGNOMEShellService::GetAppPathFromLauncher() @@ -201,8 +201,6 @@ nsGNOMEShellService::IsDefaultBrowser(bool aStartupCheck, bool* aIsDefaultBrowser) { *aIsDefaultBrowser = false; - if (aStartupCheck) - mCheckedThisSession = true; nsCOMPtr gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); nsCOMPtr giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID); @@ -325,37 +323,6 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes, return NS_OK; } -NS_IMETHODIMP -nsGNOMEShellService::GetShouldCheckDefaultBrowser(bool* aResult) -{ - // If we've already checked, the browser has been started and this is a - // new window open, and we don't want to check again. - if (mCheckedThisSession) { - *aResult = false; - return NS_OK; - } - - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { - return rv; - } - - return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult); -} - -NS_IMETHODIMP -nsGNOMEShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck) -{ - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { - return rv; - } - - return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck); -} - NS_IMETHODIMP nsGNOMEShellService::GetCanSetDesktopBackground(bool* aResult) { diff --git a/browser/components/shell/nsGNOMEShellService.h b/browser/components/shell/nsGNOMEShellService.h index ec435a53a428..a7b00380212d 100644 --- a/browser/components/shell/nsGNOMEShellService.h +++ b/browser/components/shell/nsGNOMEShellService.h @@ -6,17 +6,18 @@ #ifndef nsgnomeshellservice_h____ #define nsgnomeshellservice_h____ -#include "nsIShellService.h" +#include "nsIGNOMEShellService.h" #include "nsStringAPI.h" #include "mozilla/Attributes.h" -class nsGNOMEShellService final : public nsIShellService +class nsGNOMEShellService final : public nsIGNOMEShellService { public: - nsGNOMEShellService() : mCheckedThisSession(false), mAppIsInPath(false) { } + nsGNOMEShellService() : mAppIsInPath(false) { } NS_DECL_ISUPPORTS NS_DECL_NSISHELLSERVICE + NS_DECL_NSIGNOMESHELLSERVICE nsresult Init(); @@ -27,7 +28,6 @@ private: bool CheckHandlerMatchesAppName(const nsACString& handler) const; bool GetAppPathFromLauncher(); - bool mCheckedThisSession; bool mUseLocaleFilenames; nsCString mAppPath; bool mAppIsInPath; diff --git a/browser/components/shell/nsIGNOMEShellService.idl b/browser/components/shell/nsIGNOMEShellService.idl new file mode 100644 index 000000000000..842ce5e8a7a9 --- /dev/null +++ b/browser/components/shell/nsIGNOMEShellService.idl @@ -0,0 +1,19 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsIShellService.idl" + +[scriptable, uuid(2ce5c803-edcd-443d-98eb-ceba86d02d13)] +interface nsIGNOMEShellService : nsIShellService +{ + /** + * Used to determine whether or not to offer "Set as desktop background" + * functionality. Even if shell service is available it is not + * guaranteed that it is able to set the background for every desktop + * which is especially true for Linux with its many different desktop + * environments. + */ + readonly attribute boolean canSetDesktopBackground; +}; + diff --git a/browser/components/shell/nsIMacShellService.idl b/browser/components/shell/nsIMacShellService.idl index ce11a8d972cc..6a532bbd0b2a 100644 --- a/browser/components/shell/nsIMacShellService.idl +++ b/browser/components/shell/nsIMacShellService.idl @@ -5,7 +5,7 @@ #include "nsIShellService.idl" -[scriptable, uuid(291a27cd-ef4c-46c6-a2f8-83182498167e)] +[scriptable, uuid(387fdc80-0077-4b60-a0d9-d9e80a83ba64)] interface nsIMacShellService : nsIShellService { const long APPLICATION_KEYCHAIN_ACCESS = 2; diff --git a/browser/components/shell/nsIShellService.idl b/browser/components/shell/nsIShellService.idl index 9d9069cbc245..3e7e94b00a8e 100644 --- a/browser/components/shell/nsIShellService.idl +++ b/browser/components/shell/nsIShellService.idl @@ -8,7 +8,7 @@ interface nsIDOMElement; interface nsIFile; -[scriptable, uuid(53f4bc4a-5b86-4643-8e67-4907ecbab34c)] +[scriptable, uuid(2d1a95e4-5bd8-4eeb-b0a8-c1455fd2a357)] interface nsIShellService : nsISupports { /** @@ -38,23 +38,6 @@ interface nsIShellService : nsISupports */ void setDefaultBrowser(in boolean aClaimAllTypes, in boolean aForAllUsers); - /** - * Used to determine whether or not to show a "Set Default Browser" - * query dialog. This attribute is true if the application is starting - * up and "browser.shell.checkDefaultBrowser" is true, otherwise it - * is false. - */ - attribute boolean shouldCheckDefaultBrowser; - - /** - * Used to determine whether or not to offer "Set as desktop background" - * functionality. Even if shell service is available it is not - * guaranteed that it is able to set the background for every desktop - * which is especially true for Linux with its many different desktop - * environments. - */ - readonly attribute boolean canSetDesktopBackground; - /** * Flags for positioning/sizing of the Desktop Background image. */ diff --git a/browser/components/shell/nsIWindowsShellService.idl b/browser/components/shell/nsIWindowsShellService.idl index 31affd3062dc..57ed370555c3 100644 --- a/browser/components/shell/nsIWindowsShellService.idl +++ b/browser/components/shell/nsIWindowsShellService.idl @@ -5,7 +5,7 @@ #include "nsIShellService.idl" -[scriptable, uuid(13f20725-4fd5-431f-90a1-525ab31755b1)] +[scriptable, uuid(f8a26b94-49e5-4441-8fbc-315e0b4f22ef)] interface nsIWindowsShellService : nsIShellService { /** diff --git a/browser/components/shell/nsMacShellService.cpp b/browser/components/shell/nsMacShellService.cpp index 37ab5bce52ab..d8d64039d359 100644 --- a/browser/components/shell/nsMacShellService.cpp +++ b/browser/components/shell/nsMacShellService.cpp @@ -57,12 +57,6 @@ nsMacShellService::IsDefaultBrowser(bool aStartupCheck, ::CFRelease(defaultBrowserID); } - // If this is the first browser window, maintain internal state that we've - // checked this session (so that subsequent window opens don't show the - // default browser dialog). - if (aStartupCheck) - mCheckedThisSession = true; - return NS_OK; } @@ -103,44 +97,6 @@ nsMacShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) return NS_OK; } -NS_IMETHODIMP -nsMacShellService::GetShouldCheckDefaultBrowser(bool* aResult) -{ - // If we've already checked, the browser has been started and this is a - // new window open, and we don't want to check again. - if (mCheckedThisSession) { - *aResult = false; - return NS_OK; - } - - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { - return rv; - } - - return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult); -} - -NS_IMETHODIMP -nsMacShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck) -{ - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { - return rv; - } - - return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck); -} - -NS_IMETHODIMP -nsMacShellService::GetCanSetDesktopBackground(bool* aResult) -{ - *aResult = true; - return NS_OK; -} - NS_IMETHODIMP nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement, int32_t aPosition) diff --git a/browser/components/shell/nsMacShellService.h b/browser/components/shell/nsMacShellService.h index 7ca1c71ac325..db9527809273 100644 --- a/browser/components/shell/nsMacShellService.h +++ b/browser/components/shell/nsMacShellService.h @@ -15,7 +15,7 @@ class nsMacShellService : public nsIMacShellService, public nsIWebProgressListener { public: - nsMacShellService() : mCheckedThisSession(false) {}; + nsMacShellService() {}; NS_DECL_ISUPPORTS NS_DECL_NSISHELLSERVICE @@ -27,8 +27,6 @@ protected: private: nsCOMPtr mBackgroundFile; - - bool mCheckedThisSession; }; #endif // nsmacshellservice_h____ diff --git a/browser/components/shell/nsSetDefaultBrowser.js b/browser/components/shell/nsSetDefaultBrowser.js index d63a9d1635c0..bb09ab21315e 100644 --- a/browser/components/shell/nsSetDefaultBrowser.js +++ b/browser/components/shell/nsSetDefaultBrowser.js @@ -2,13 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* +/* * --setDefaultBrowser commandline handler * Makes the current executable the "default browser". */ const Cc = Components.classes; const Ci = Components.interfaces; +Components.utils.import("resource:///modules/ShellService.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function nsSetDefaultBrowser() {} @@ -16,9 +17,7 @@ function nsSetDefaultBrowser() {} nsSetDefaultBrowser.prototype = { handle: function nsSetDefault_handle(aCmdline) { if (aCmdline.handleFlag("setDefaultBrowser", false)) { - var shell = Cc["@mozilla.org/browser/shell-service;1"]. - getService(Ci.nsIShellService); - shell.setDefaultBrowser(true, true); + ShellService.setDefaultBrowser(true, true); } }, diff --git a/browser/components/shell/nsWindowsShellService.cpp b/browser/components/shell/nsWindowsShellService.cpp index 27fddd81678a..73a9cddd3c3c 100644 --- a/browser/components/shell/nsWindowsShellService.cpp +++ b/browser/components/shell/nsWindowsShellService.cpp @@ -608,12 +608,6 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck, bool aForAllTypes, bool* aIsDefaultBrowser) { - // If this is the first browser window, maintain internal state that we've - // checked this session (so that subsequent window opens don't show the - // default browser dialog). - if (aStartupCheck) - mCheckedThisSession = true; - // Assume we're the default unless one of the several checks below tell us // otherwise. *aIsDefaultBrowser = true; @@ -807,13 +801,6 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck, return NS_OK; } -NS_IMETHODIMP -nsWindowsShellService::GetCanSetDesktopBackground(bool* aResult) -{ - *aResult = true; - return NS_OK; -} - static nsresult DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo) { @@ -984,39 +971,6 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers) return rv; } -NS_IMETHODIMP -nsWindowsShellService::GetShouldCheckDefaultBrowser(bool* aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - // If we've already checked, the browser has been started and this is a - // new window open, and we don't want to check again. - if (mCheckedThisSession) { - *aResult = false; - return NS_OK; - } - - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { - return rv; - } - - return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult); -} - -NS_IMETHODIMP -nsWindowsShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck) -{ - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) { - return rv; - } - - return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck); -} - static nsresult WriteBitmap(nsIFile* aFile, imgIContainer* aImage) { @@ -1358,8 +1312,7 @@ nsWindowsShellService::SetDesktopBackgroundColor(uint32_t aColor) return regKey->Close(); } -nsWindowsShellService::nsWindowsShellService() : - mCheckedThisSession(false) +nsWindowsShellService::nsWindowsShellService() { } diff --git a/browser/components/shell/nsWindowsShellService.h b/browser/components/shell/nsWindowsShellService.h index 7f9c9191f00d..45b967078986 100644 --- a/browser/components/shell/nsWindowsShellService.h +++ b/browser/components/shell/nsWindowsShellService.h @@ -31,9 +31,6 @@ protected: nsresult LaunchModernSettingsDialogDefaultApps(); nsresult InvokeHTTPOpenAsVerb(); nsresult LaunchHTTPHandlerPane(); - -private: - bool mCheckedThisSession; }; #endif // nswindowsshellservice_h____ diff --git a/browser/components/shell/test/browser_633221.js b/browser/components/shell/test/browser_633221.js index 840394dea914..7929e809847d 100644 --- a/browser/components/shell/test/browser_633221.js +++ b/browser/components/shell/test/browser_633221.js @@ -1,15 +1,7 @@ +Components.utils.import("resource:///modules/ShellService.jsm"); + function test() { - let osString = Cc["@mozilla.org/xre/app-info;1"]. - getService(Ci.nsIXULRuntime).OS; - - // this test is Linux-specific - if (osString != "Linux") - return; - - let shell = Cc["@mozilla.org/browser/shell-service;1"]. - getService(Ci.nsIShellService); - - shell.setDefaultBrowser(true, false); - ok(shell.isDefaultBrowser(true, false), "we got here and are the default browser"); - ok(shell.isDefaultBrowser(true, true), "we got here and are the default browser"); + ShellService.setDefaultBrowser(true, false); + ok(ShellService.isDefaultBrowser(true, false), "we got here and are the default browser"); + ok(ShellService.isDefaultBrowser(true, true), "we got here and are the default browser"); } diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index 9ea75d783b78..109baa36e911 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -1039,6 +1039,7 @@ EnvironmentCache.prototype = { if (AppConstants.platform === "gonk") { return true; } + if (!("@mozilla.org/browser/shell-service;1" in Cc)) { this._log.info("_isDefaultBrowser - Could not obtain browser shell service"); return null; @@ -1046,11 +1047,21 @@ EnvironmentCache.prototype = { let shellService; try { - shellService = Cc["@mozilla.org/browser/shell-service;1"] - .getService(Ci.nsIShellService); + let scope = {}; + Cu.import("resource:///modules/ShellService.jsm", scope); + shellService = scope.ShellService; } catch (ex) { - this._log.error("_isDefaultBrowser - Could not obtain shell service", ex); - return null; + this._log.error("_isDefaultBrowser - Could not obtain shell service JSM"); + } + + if (!shellService) { + try { + shellService = Cc["@mozilla.org/browser/shell-service;1"] + .getService(Ci.nsIShellService); + } catch (ex) { + this._log.error("_isDefaultBrowser - Could not obtain shell service", ex); + return null; + } } try {