--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1,22 +1,22 @@
-# -*- indent-tabs-mode: nil -*-
-# 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/.
+/* 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/. */
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cr = Components.results;
const Cu = Components.utils;
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutHome",
"resource:///modules/AboutHome.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutNewTab",
"resource:///modules/AboutNewTab.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DirectoryLinksProvider",
@@ -62,20 +62,20 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource:///modules/CustomizationTabPreloader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PdfJs",
"resource://pdf.js/PdfJs.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ProcessHangMonitor",
"resource:///modules/ProcessHangMonitor.jsm");
-#ifdef NIGHTLY_BUILD
-XPCOMUtils.defineLazyModuleGetter(this, "ShumwayUtils",
- "resource://shumway/ShumwayUtils.jsm");
-#endif
+if (AppConstants.NIGHTLY_BUILD) {
+ XPCOMUtils.defineLazyModuleGetter(this, "ShumwayUtils",
+ "resource://shumway/ShumwayUtils.jsm");
+}
XPCOMUtils.defineLazyModuleGetter(this, "webrtcUI",
"resource:///modules/webrtcUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
@@ -115,35 +115,35 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/AsyncShutdown.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
"resource://gre/modules/LoginManagerParent.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SimpleServiceDiscovery",
"resource://gre/modules/SimpleServiceDiscovery.jsm");
-#ifdef NIGHTLY_BUILD
-XPCOMUtils.defineLazyModuleGetter(this, "SignInToWebsiteUX",
- "resource:///modules/SignInToWebsite.jsm");
-#endif
+if (AppConstants.NIGHTLY_BUILD) {
+ XPCOMUtils.defineLazyModuleGetter(this, "SignInToWebsiteUX",
+ "resource:///modules/SignInToWebsite.jsm");
+}
XPCOMUtils.defineLazyModuleGetter(this, "ContentSearch",
"resource:///modules/ContentSearch.jsm");
-#ifdef E10S_TESTING_ONLY
-XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
- "resource://gre/modules/UpdateUtils.jsm");
-#endif
+if (AppConstants.E10S_TESTING_ONLY) {
+ XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
+ "resource://gre/modules/UpdateUtils.jsm");
+}
XPCOMUtils.defineLazyModuleGetter(this, "TabCrashHandler",
"resource:///modules/ContentCrashHandlers.jsm");
-#ifdef MOZ_CRASHREPORTER
-XPCOMUtils.defineLazyModuleGetter(this, "PluginCrashReporter",
- "resource:///modules/ContentCrashHandlers.jsm");
-#endif
+if (AppConstants.MOZ_CRASHREPORTER) {
+ XPCOMUtils.defineLazyModuleGetter(this, "PluginCrashReporter",
+ "resource:///modules/ContentCrashHandlers.jsm");
+}
XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() {
return Services.strings.createBundle('chrome://branding/locale/brand.properties');
});
XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
return Services.strings.createBundle('chrome://browser/locale/browser.properties');
});
@@ -162,19 +162,16 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/AddonWatcher.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement",
"resource://gre/modules/ExtensionManagement.jsm");
-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");
XPCOMUtils.defineLazyServiceGetter(this, "AlertsService",
"@mozilla.org/alerts-service;1", "nsIAlertsService");
@@ -219,21 +216,21 @@ function BrowserGlue() {
let sanitizerScope = {};
Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", sanitizerScope);
return sanitizerScope.Sanitizer;
});
this._init();
}
-#ifndef XP_MACOSX
-# OS X has the concept of zero-window sessions and therefore ignores the
-# browser-lastwindow-close-* topics.
-#define OBSERVE_LASTWINDOW_CLOSE_TOPICS 1
-#endif
+/*
+ * OS X has the concept of zero-window sessions and therefore ignores the
+ * browser-lastwindow-close-* topics.
+ */
+const OBSERVE_LASTWINDOW_CLOSE_TOPICS = AppConstants.platform != "macosx";
BrowserGlue.prototype = {
_saveSession: false,
_isPlacesInitObserver: false,
_isPlacesLockedObserver: false,
_isPlacesShutdownObserver: false,
_isPlacesDatabaseLocked: false,
_migrationImportsDefaultBookmarks: false,
@@ -300,26 +297,28 @@ BrowserGlue.prototype = {
this._onSafeModeRestart();
break;
case "quit-application-requested":
this._onQuitRequest(subject, data);
break;
case "quit-application-granted":
this._onQuitApplicationGranted();
break;
-#ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
case "browser-lastwindow-close-requested":
- // The application is not actually quitting, but the last full browser
- // window is about to be closed.
- this._onQuitRequest(subject, "lastwindow");
+ if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
+ // The application is not actually quitting, but the last full browser
+ // window is about to be closed.
+ this._onQuitRequest(subject, "lastwindow");
+ }
break;
case "browser-lastwindow-close-granted":
- this._setPrefToSaveSession();
+ if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
+ this._setPrefToSaveSession();
+ }
break;
-#endif
case "weave:service:ready":
this._setSyncAutoconnectDelay();
break;
case "weave:engine:clients:display-uri":
this._onDisplaySyncURI(subject);
break;
case "session-save":
this._setPrefToSaveSession(true);
@@ -515,35 +514,35 @@ BrowserGlue.prototype = {
os.addObserver(this, "notifications-open-settings", false);
os.addObserver(this, "prefservice:after-app-defaults", false);
os.addObserver(this, "final-ui-startup", false);
os.addObserver(this, "browser-delayed-startup-finished", false);
os.addObserver(this, "sessionstore-windows-restored", false);
os.addObserver(this, "browser:purge-session-history", false);
os.addObserver(this, "quit-application-requested", false);
os.addObserver(this, "quit-application-granted", false);
-#ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
- os.addObserver(this, "browser-lastwindow-close-requested", false);
- os.addObserver(this, "browser-lastwindow-close-granted", false);
-#endif
+ if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
+ os.addObserver(this, "browser-lastwindow-close-requested", false);
+ os.addObserver(this, "browser-lastwindow-close-granted", false);
+ }
os.addObserver(this, "weave:service:ready", false);
os.addObserver(this, "weave:engine:clients:display-uri", false);
os.addObserver(this, "session-save", false);
os.addObserver(this, "places-init-complete", false);
this._isPlacesInitObserver = true;
os.addObserver(this, "places-database-locked", false);
this._isPlacesLockedObserver = true;
os.addObserver(this, "distribution-customization-complete", false);
os.addObserver(this, "places-shutdown", false);
this._isPlacesShutdownObserver = true;
os.addObserver(this, "handle-xul-text-link", false);
os.addObserver(this, "profile-before-change", false);
-#ifdef MOZ_SERVICES_HEALTHREPORT
- os.addObserver(this, "keyword-search", false);
-#endif
+ if (AppConstants.MOZ_SERVICES_HEALTHREPORT) {
+ os.addObserver(this, "keyword-search", false);
+ }
os.addObserver(this, "browser-search-engine-modified", false);
os.addObserver(this, "restart-in-safe-mode", false);
os.addObserver(this, "flash-plugin-hang", false);
os.addObserver(this, "xpi-signature-changed", false);
os.addObserver(this, "autocomplete-did-enter-text", false);
ExtensionManagement.registerScript("chrome://browser/content/ext-utils.js");
ExtensionManagement.registerScript("chrome://browser/content/ext-browserAction.js");
@@ -571,38 +570,38 @@ BrowserGlue.prototype = {
os.removeObserver(this, "notifications-open-settings");
os.removeObserver(this, "prefservice:after-app-defaults");
os.removeObserver(this, "final-ui-startup");
os.removeObserver(this, "sessionstore-windows-restored");
os.removeObserver(this, "browser:purge-session-history");
os.removeObserver(this, "quit-application-requested");
os.removeObserver(this, "quit-application-granted");
os.removeObserver(this, "restart-in-safe-mode");
-#ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
- os.removeObserver(this, "browser-lastwindow-close-requested");
- os.removeObserver(this, "browser-lastwindow-close-granted");
-#endif
+ if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
+ os.removeObserver(this, "browser-lastwindow-close-requested");
+ os.removeObserver(this, "browser-lastwindow-close-granted");
+ }
os.removeObserver(this, "weave:service:ready");
os.removeObserver(this, "weave:engine:clients:display-uri");
os.removeObserver(this, "session-save");
if (this._bookmarksBackupIdleTime) {
this._idleService.removeIdleObserver(this, this._bookmarksBackupIdleTime);
delete this._bookmarksBackupIdleTime;
}
if (this._isPlacesInitObserver)
os.removeObserver(this, "places-init-complete");
if (this._isPlacesLockedObserver)
os.removeObserver(this, "places-database-locked");
if (this._isPlacesShutdownObserver)
os.removeObserver(this, "places-shutdown");
os.removeObserver(this, "handle-xul-text-link");
os.removeObserver(this, "profile-before-change");
-#ifdef MOZ_SERVICES_HEALTHREPORT
- os.removeObserver(this, "keyword-search");
-#endif
+ if (AppConstants.MOZ_SERVICES_HEALTHREPORT) {
+ os.removeObserver(this, "keyword-search");
+ }
os.removeObserver(this, "browser-search-engine-modified");
os.removeObserver(this, "flash-plugin-hang");
os.removeObserver(this, "xpi-signature-changed");
os.removeObserver(this, "autocomplete-did-enter-text");
},
_onAppDefaults: function BG__onAppDefaults() {
// apply distribution customizations (prefs)
@@ -743,21 +742,21 @@ BrowserGlue.prototype = {
// prefs are applied in _onAppDefaults()
this._distributionCustomizer.applyCustomizations();
// handle any UI migration
this._migrateUI();
WebappManager.init();
PageThumbs.init();
-#ifdef NIGHTLY_BUILD
- if (Services.prefs.getBoolPref("dom.identity.enabled")) {
- SignInToWebsiteUX.init();
+ if (AppConstants.NIGHTLY_BUILD) {
+ if (Services.prefs.getBoolPref("dom.identity.enabled")) {
+ SignInToWebsiteUX.init();
+ }
}
-#endif
webrtcUI.init();
AboutHome.init();
DirectoryLinksProvider.init();
NewTabUtils.init();
NewTabUtils.links.addProvider(DirectoryLinksProvider);
AboutNewTab.init();
@@ -773,39 +772,39 @@ BrowserGlue.prototype = {
Feeds.init();
ContentPrefServiceParent.init();
LoginManagerParent.init();
ReaderParent.init();
SelfSupportBackend.init();
-#ifndef RELEASE_BUILD
- let themeName = gBrowserBundle.GetStringFromName("deveditionTheme.name");
- let vendorShortName = gBrandBundle.GetStringFromName("vendorShortName");
-
- LightweightThemeManager.addBuiltInTheme({
- id: "firefox-devedition@mozilla.org",
- name: themeName,
- headerURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.header.png",
- iconURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.icon.png",
- author: vendorShortName,
- });
-#endif
+ if (!AppConstants.RELEASE_BUILD) {
+ let themeName = gBrowserBundle.GetStringFromName("deveditionTheme.name");
+ let vendorShortName = gBrandBundle.GetStringFromName("vendorShortName");
+
+ LightweightThemeManager.addBuiltInTheme({
+ id: "firefox-devedition@mozilla.org",
+ name: themeName,
+ headerURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.header.png",
+ iconURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.icon.png",
+ author: vendorShortName,
+ });
+ }
TabCrashHandler.init();
-#ifdef MOZ_CRASHREPORTER
- PluginCrashReporter.init();
-#endif
+ if (AppConstants.MOZ_CRASHREPORTER) {
+ PluginCrashReporter.init();
+ }
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
-#ifdef NIGHTLY_BUILD
- AddonWatcher.init(this._notifySlowAddon);
-#endif
+ if (AppConstants.NIGHTLY_BUILD) {
+ AddonWatcher.init(this._notifySlowAddon);
+ }
},
_checkForOldBuildUpdates: function () {
// check for update if our build is old
if (AppConstants.MOZ_UPDATER &&
Services.prefs.getBoolPref("app.update.enabled") &&
Services.prefs.getBoolPref("app.update.checkInstallTime")) {
@@ -964,25 +963,28 @@ BrowserGlue.prototype = {
];
let nb = win.document.getElementById("high-priority-global-notificationbox");
nb.appendNotification(message, "unsigned-addons-disabled", "",
nb.PRIORITY_WARNING_MEDIUM, buttons);
},
_firstWindowTelemetry: function(aWindow) {
-#ifdef XP_WIN
- let SCALING_PROBE_NAME = "DISPLAY_SCALING_MSWIN";
-#elifdef XP_MACOSX
- let SCALING_PROBE_NAME = "DISPLAY_SCALING_OSX";
-#elifdef XP_LINUX
- let SCALING_PROBE_NAME = "DISPLAY_SCALING_LINUX";
-#else
let SCALING_PROBE_NAME = "";
-#endif
+ switch (AppConstants.platform) {
+ case "win":
+ SCALING_PROBE_NAME = "DISPLAY_SCALING_MSWIN";
+ break;
+ case "macosx":
+ SCALING_PROBE_NAME = "DISPLAY_SCALING_OSX";
+ break;
+ case "linux":
+ SCALING_PROBE_NAME = "DISPLAY_SCALING_LINUX";
+ break;
+ }
if (SCALING_PROBE_NAME) {
let scaling = aWindow.devicePixelRatio * 100;
Services.telemetry.getHistogramById(SCALING_PROBE_NAME).add(scaling);
}
},
// the first browser window has finished initializing
_onFirstWindowLoaded: function BG__onFirstWindowLoaded(aWindow) {
@@ -995,33 +997,33 @@ BrowserGlue.prototype = {
// shim for privileged api access.
PdfJs.init(true);
// child only: similar to the call above for parent - register content
// handler and init message manager child shim for privileged api access.
// With older versions of the extension installed, this load will fail
// passively.
Services.ppmm.loadProcessScript("resource://pdf.js/pdfjschildbootstrap.js", true);
-#ifdef NIGHTLY_BUILD
- // Registering Shumway bootstrap script the child processes.
- Services.ppmm.loadProcessScript("chrome://shumway/content/bootstrap-content.js", true);
- // Initializing Shumway (shall be run after child script registration).
- ShumwayUtils.init();
-#endif
-
-#ifdef XP_WIN
- // For windows seven, initialize the jump list module.
- const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
- if (WINTASKBAR_CONTRACTID in Cc &&
- Cc[WINTASKBAR_CONTRACTID].getService(Ci.nsIWinTaskbar).available) {
- let temp = {};
- Cu.import("resource:///modules/WindowsJumpLists.jsm", temp);
- temp.WinTaskbarJumpList.startup();
+ if (AppConstants.NIGHTLY_BUILD) {
+ // Registering Shumway bootstrap script the child processes.
+ Services.ppmm.loadProcessScript("chrome://shumway/content/bootstrap-content.js", true);
+ // Initializing Shumway (shall be run after child script registration).
+ ShumwayUtils.init();
}
-#endif
+
+ if (AppConstants.platform == "win") {
+ // For Windows 7, initialize the jump list module.
+ const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
+ if (WINTASKBAR_CONTRACTID in Cc &&
+ Cc[WINTASKBAR_CONTRACTID].getService(Ci.nsIWinTaskbar).available) {
+ let temp = {};
+ Cu.import("resource:///modules/WindowsJumpLists.jsm", temp);
+ temp.WinTaskbarJumpList.startup();
+ }
+ }
ProcessHangMonitor.init();
// A channel for "remote troubleshooting" code...
let channel = new WebChannel("remote-troubleshooting", "remote-troubleshooting");
channel.listen((id, data, target) => {
if (data.command == "request") {
let {Troubleshoot} = Cu.import("resource://gre/modules/Troubleshoot.jsm", {});
@@ -1075,26 +1077,26 @@ BrowserGlue.prototype = {
SelfSupportBackend.uninit();
CustomizationTabPreloader.uninit();
WebappManager.uninit();
NewTabPrefsProvider.prefs.uninit();
AboutNewTab.uninit();
-#ifdef NIGHTLY_BUILD
- if (Services.prefs.getBoolPref("dom.identity.enabled")) {
- SignInToWebsiteUX.uninit();
+ if (AppConstants.NIGHTLY_BUILD) {
+ if (Services.prefs.getBoolPref("dom.identity.enabled")) {
+ SignInToWebsiteUX.uninit();
+ }
}
-#endif
webrtcUI.uninit();
FormValidationHandler.uninit();
-#ifdef NIGHTLY_BUILD
- AddonWatcher.uninit();
-#endif
+ if (AppConstants.NIGHTLY_BUILD) {
+ AddonWatcher.uninit();
+ }
},
_initServiceDiscovery: function () {
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
return;
}
var rokuDevice = {
id: "roku:ecp",
@@ -1111,19 +1113,19 @@ BrowserGlue.prototype = {
SimpleServiceDiscovery.registerDevice(rokuDevice);
// Search for devices continuously every 120 seconds
SimpleServiceDiscovery.search(120 * 1000);
},
// All initial windows have opened.
_onWindowsRestored: function BG__onWindowsRestored() {
-#ifdef MOZ_DEV_EDITION
- this._createExtraDefaultProfile();
-#endif
+ if (AppConstants.MOZ_DEV_EDITION) {
+ this._createExtraDefaultProfile();
+ }
this._initServiceDiscovery();
// Show update notification, if needed.
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
this._showUpdateNotification();
// Load the "more info" page for a locked places.sqlite
@@ -1148,21 +1150,22 @@ BrowserGlue.prototype = {
if (!aAddon.userDisabled || !(aAddon.permissions & AddonManager.PERM_CAN_ENABLE))
return;
win.openUILinkIn("about:newaddon?id=" + aAddon.id, "tab");
})
});
}
-#ifdef MOZ_REQUIRE_SIGNING
- let signingRequired = true;
-#else
- let signingRequired = Services.prefs.getBoolPref("xpinstall.signatures.required");
-#endif
+ let signingRequired;
+ if (AppConstants.MOZ_REQUIRE_SIGNING) {
+ signingRequired = true;
+ } else {
+ signingRequired = Services.prefs.getBoolPref("xpinstall.signatures.required");
+ }
if (signingRequired) {
let disabledAddons = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
AddonManager.getAddonsByIDs(disabledAddons, (addons) => {
for (let addon of addons) {
if (addon.type == "experiment")
continue;
@@ -1171,29 +1174,26 @@ BrowserGlue.prototype = {
break;
}
}
});
}
// Perform default browser checking.
if (ShellService) {
-#ifdef DEBUG
- let shouldCheck = false;
-#else
- let shouldCheck = ShellService.shouldCheckDefaultBrowser;
-#endif
-#ifndef RELEASE_BUILD
- let promptCount =
- Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount");
- let skipDefaultBrowserCheck =
- Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheck");
-#else
+ let shouldCheck = AppConstants.DEBUG ? false :
+ ShellService.shouldCheckDefaultBrowser;
+ let promptCount;
let skipDefaultBrowserCheck = false;
-#endif
+ if (!AppConstants.RELEASE_BUILD) {
+ promptCount =
+ Services.prefs.getIntPref("browser.shell.defaultBrowserCheckCount");
+ skipDefaultBrowserCheck =
+ Services.prefs.getBoolPref("browser.shell.skipDefaultBrowserCheck");
+ }
let willRecoverSession = false;
try {
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].
getService(Ci.nsISessionStartup);
willRecoverSession =
(ss.sessionType == Ci.nsISessionStartup.RECOVER_SESSION);
}
catch (ex) { /* never mind; suppose SessionStore is broken */ }
@@ -1223,22 +1223,22 @@ BrowserGlue.prototype = {
} else {
promptCount++;
}
if (promptCount > 3) {
willPrompt = false;
}
}
-#ifndef RELEASE_BUILD
- if (willPrompt) {
- Services.prefs.setIntPref("browser.shell.defaultBrowserCheckCount",
- promptCount);
+ if (!AppConstants.RELEASE_BUILD) {
+ if (willPrompt) {
+ Services.prefs.setIntPref("browser.shell.defaultBrowserCheckCount",
+ promptCount);
+ }
}
-#endif
try {
// Report default browser status on startup to telemetry
// so we can track whether we are the default.
Services.telemetry.getHistogramById("BROWSER_IS_USER_DEFAULT")
.add(isDefault);
Services.telemetry.getHistogramById("BROWSER_IS_USER_DEFAULT_ERROR")
.add(isDefaultError);
@@ -1261,18 +1261,20 @@ BrowserGlue.prototype = {
}
if (AppConstants.platform == "win") {
// Handles prompting to inform about incompatibilites when accessibility
// and e10s are active together.
E10SAccessibilityCheck.init();
}
},
-#ifdef MOZ_DEV_EDITION
_createExtraDefaultProfile: function () {
+ if (!AppConstants.MOZ_DEV_EDITION) {
+ return;
+ }
// If Developer Edition is the only installed Firefox version and no other
// profiles are present, create a second one for use by other versions.
// This helps Firefox versions earlier than 35 avoid accidentally using the
// unsuitable Developer Edition profile.
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]
.getService(Ci.nsIToolkitProfileService);
let profileCount = profileService.profileCount;
if (profileCount == 1 && profileService.selectedProfile.name != "default") {
@@ -1292,17 +1294,16 @@ BrowserGlue.prototype = {
OS.File.removeDir(newProfilePath).then(() => {
return OS.File.makeDir(newProfilePath);
}).then(null, e => {
Cu.reportError("Could not empty profile 'default': " + e);
});
}
}
},
-#endif
_maybeMigrateTabGroups() {
let migrationObserver = (stateAsSupportsString, topic) => {
Services.obs.removeObserver(migrationObserver, "sessionstore-state-read");
TabGroupsMigrator.migrate(stateAsSupportsString);
};
Services.obs.addObserver(migrationObserver, "sessionstore-state-read", false);
},
@@ -1759,17 +1760,17 @@ BrowserGlue.prototype = {
delete this._bookmarksBackupIdleTime;
}
},
/**
* If a backup for today doesn't exist, this creates one.
*/
_backupBookmarks: function BG__backupBookmarks() {
- return Task.spawn(function() {
+ return Task.spawn(function*() {
let lastBackupFile = yield PlacesBackups.getMostRecentBackup();
// Should backup bookmarks if there are no backups or the maximum
// interval between backups elapsed.
if (!lastBackupFile ||
new Date() - PlacesBackups.getDateForFile(lastBackupFile) > BOOKMARKS_BACKUP_MIN_INTERVAL_DAYS * 86400000) {
let maxBackups = Services.prefs.getIntPref("browser.bookmarks.max_backups");
yield PlacesBackups.create(maxBackups);
}
@@ -1897,30 +1898,30 @@ BrowserGlue.prototype = {
} else {
currentset = currentset.replace(/(^|,)window-controls($|,)/,
"$1downloads-button,window-controls$2")
}
xulStore.setValue(BROWSER_DOCURL, "nav-bar", "currentset", currentset);
}
}
-#ifdef XP_WIN
- if (currentUIVersion < 10) {
- // For Windows systems with display set to > 96dpi (i.e. systemDefaultScale
- // will return a value > 1.0), we want to discard any saved full-zoom settings,
- // as we'll now be scaling the content according to the system resolution
- // scale factor (Windows "logical DPI" setting)
- let sm = Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
- if (sm.systemDefaultScale > 1.0) {
- let cps2 = Cc["@mozilla.org/content-pref/service;1"].
- getService(Ci.nsIContentPrefService2);
- cps2.removeByName("browser.content.full-zoom", null);
+ if (AppConstants.platform == "win") {
+ if (currentUIVersion < 10) {
+ // For Windows systems with display set to > 96dpi (i.e. systemDefaultScale
+ // will return a value > 1.0), we want to discard any saved full-zoom settings,
+ // as we'll now be scaling the content according to the system resolution
+ // scale factor (Windows "logical DPI" setting)
+ let sm = Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
+ if (sm.systemDefaultScale > 1.0) {
+ let cps2 = Cc["@mozilla.org/content-pref/service;1"].
+ getService(Ci.nsIContentPrefService2);
+ cps2.removeByName("browser.content.full-zoom", null);
+ }
}
}
-#endif
if (currentUIVersion < 11) {
Services.prefs.clearUserPref("dom.disable_window_move_resize");
Services.prefs.clearUserPref("dom.disable_window_flip");
Services.prefs.clearUserPref("dom.event.contextmenu.enabled");
Services.prefs.clearUserPref("javascript.enabled");
Services.prefs.clearUserPref("permissions.default.image");
}
@@ -2536,17 +2537,17 @@ ContentPermissionPrompt.prototype = {
var mainAction = popupNotificationActions.length ?
popupNotificationActions[0] : null;
var secondaryActions = popupNotificationActions.splice(1);
// Only allow exactly one permission request here.
let types = aRequest.types.QueryInterface(Ci.nsIArray);
if (types.length != 1) {
aRequest.cancel();
- return;
+ return undefined;
}
if (!aOptions)
aOptions = {};
aOptions.displayURI = requestPrincipal.URI;
return chromeWin.PopupNotifications.show(browser, aNotificationId, aMessage, aAnchorId,
mainAction, secondaryActions, aOptions);
@@ -2778,26 +2779,26 @@ var DefaultBrowserCheck = {
if (this._notification) {
this._notification.close();
}
},
setAsDefault: function() {
let claimAllTypes = true;
let setAsDefaultError = false;
-#ifdef XP_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) { }
-#endif
+ 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);
if (this._setAsDefaultTimer) {
this._setAsDefaultTimer.cancel();
}
this._setAsDefaultButtonClickStartTime = Math.floor(Date.now() / 1000);
@@ -2960,165 +2961,165 @@ var DefaultBrowserCheck = {
let popup = doc.getElementById(this.OPTIONPOPUP);
popup.removeEventListener("command", this);
popup.remove();
delete this._notification;
}
},
};
-#ifdef E10S_TESTING_ONLY
-var E10SUINotification = {
- CURRENT_PROMPT_PREF: "browser.displayedE10SPrompt.1",
- PREVIOUS_PROMPT_PREF: "browser.displayedE10SPrompt",
-
- get forcedOn() {
- try {
- return Services.prefs.getBoolPref("browser.tabs.remote.force-enable");
- } catch (e) {}
- return false;
- },
-
- get a11yRecentlyRan() {
- try {
- if (Services.prefs.getBoolPref("accessibility.loadedInLastSession")) {
+if (AppConstants.E10S_TESTING_ONLY) {
+ var E10SUINotification = {
+ CURRENT_PROMPT_PREF: "browser.displayedE10SPrompt.1",
+ PREVIOUS_PROMPT_PREF: "browser.displayedE10SPrompt",
+
+ get forcedOn() {
+ try {
+ return Services.prefs.getBoolPref("browser.tabs.remote.force-enable");
+ } catch (e) {}
+ return false;
+ },
+
+ get a11yRecentlyRan() {
+ try {
+ if (Services.prefs.getBoolPref("accessibility.loadedInLastSession")) {
+ return true;
+ }
+ } catch (e) {}
+ try {
+ Services.prefs.getBoolPref("accessibility.lastLoadDate");
return true;
- }
- } catch (e) {}
- try {
- Services.prefs.getBoolPref("accessibility.lastLoadDate");
- return true;
- } catch (e) {}
- return false;
- },
-
- checkStatus: function() {
- let updateChannel = UpdateUtils.UpdateChannel;
- let channelAuthorized = updateChannel == "nightly" || updateChannel == "aurora";
- if (!channelAuthorized) {
- return;
- }
-
- if (!Services.appinfo.browserTabsRemoteAutostart) {
- let displayFeedbackRequest = false;
- try {
- displayFeedbackRequest = Services.prefs.getBoolPref("browser.requestE10sFeedback");
} catch (e) {}
-
- if (displayFeedbackRequest) {
- let win = RecentWindow.getMostRecentBrowserWindow();
- if (!win) {
- return;
- }
-
- Services.prefs.clearUserPref("browser.requestE10sFeedback");
-
- let url = Services.urlFormatter.formatURLPref("app.feedback.baseURL");
- url += "?utm_source=tab&utm_campaign=e10sfeedback";
-
- win.openUILinkIn(url, "tab");
- return;
- }
-
- // If accessibility recently ran, don't prompt about trying out e10s
- if (this.a11yRecentlyRan) {
+ return false;
+ },
+
+ checkStatus: function() {
+ let updateChannel = UpdateUtils.UpdateChannel;
+ let channelAuthorized = updateChannel == "nightly" || updateChannel == "aurora";
+ if (!channelAuthorized) {
return;
}
- let e10sPromptShownCount = 0;
- try {
- e10sPromptShownCount = Services.prefs.getIntPref(this.CURRENT_PROMPT_PREF);
- } catch(e) {}
-
- let isHardwareAccelerated = true;
- // Linux and Windows are currently ok, mac not so much.
-#ifdef XP_MACOSX
- try {
- let win = RecentWindow.getMostRecentBrowserWindow();
- let winutils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
- isHardwareAccelerated = winutils.layerManagerType != "Basic";
- } catch (e) {}
-#endif
-
- if (!Services.appinfo.inSafeMode &&
- !Services.appinfo.accessibilityEnabled &&
- isHardwareAccelerated &&
- e10sPromptShownCount < 5) {
- Services.tm.mainThread.dispatch(() => {
+ if (!Services.appinfo.browserTabsRemoteAutostart) {
+ let displayFeedbackRequest = false;
+ try {
+ displayFeedbackRequest = Services.prefs.getBoolPref("browser.requestE10sFeedback");
+ } catch (e) {}
+
+ if (displayFeedbackRequest) {
+ let win = RecentWindow.getMostRecentBrowserWindow();
+ if (!win) {
+ return;
+ }
+
+ Services.prefs.clearUserPref("browser.requestE10sFeedback");
+
+ let url = Services.urlFormatter.formatURLPref("app.feedback.baseURL");
+ url += "?utm_source=tab&utm_campaign=e10sfeedback";
+
+ win.openUILinkIn(url, "tab");
+ return;
+ }
+
+ // If accessibility recently ran, don't prompt about trying out e10s
+ if (this.a11yRecentlyRan) {
+ return;
+ }
+
+ let e10sPromptShownCount = 0;
+ try {
+ e10sPromptShownCount = Services.prefs.getIntPref(this.CURRENT_PROMPT_PREF);
+ } catch(e) {}
+
+ let isHardwareAccelerated = true;
+ // Linux and Windows are currently ok, mac not so much.
+ if (AppConstants.platform == "macosx") {
try {
- this._showE10SPrompt();
- Services.prefs.setIntPref(this.CURRENT_PROMPT_PREF, e10sPromptShownCount + 1);
- Services.prefs.clearUserPref(this.PREVIOUS_PROMPT_PREF);
- } catch (ex) {
- Cu.reportError("Failed to show e10s prompt: " + ex);
+ let win = RecentWindow.getMostRecentBrowserWindow();
+ let winutils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+ isHardwareAccelerated = winutils.layerManagerType != "Basic";
+ } catch (e) {}
+ }
+
+ if (!Services.appinfo.inSafeMode &&
+ !Services.appinfo.accessibilityEnabled &&
+ isHardwareAccelerated &&
+ e10sPromptShownCount < 5) {
+ Services.tm.mainThread.dispatch(() => {
+ try {
+ this._showE10SPrompt();
+ Services.prefs.setIntPref(this.CURRENT_PROMPT_PREF, e10sPromptShownCount + 1);
+ Services.prefs.clearUserPref(this.PREVIOUS_PROMPT_PREF);
+ } catch (ex) {
+ Cu.reportError("Failed to show e10s prompt: " + ex);
+ }
+ }, Ci.nsIThread.DISPATCH_NORMAL);
+ }
+ }
+ },
+
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
+
+ _showE10SPrompt: function BG__showE10SPrompt() {
+ let win = RecentWindow.getMostRecentBrowserWindow();
+ if (!win)
+ return;
+
+ let browser = win.gBrowser.selectedBrowser;
+
+ let promptMessage = win.gNavigatorBundle.getFormattedString(
+ "e10s.offerPopup.mainMessage",
+ [gBrandBundle.GetStringFromName("brandShortName")]
+ );
+ let mainAction = {
+ label: win.gNavigatorBundle.getString("e10s.offerPopup.enableAndRestart.label"),
+ accessKey: win.gNavigatorBundle.getString("e10s.offerPopup.enableAndRestart.accesskey"),
+ callback: function () {
+ Services.prefs.setBoolPref("browser.tabs.remote.autostart", true);
+ Services.prefs.setBoolPref("browser.enabledE10SFromPrompt", true);
+ // Restart the app
+ let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
+ Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
+ if (cancelQuit.data)
+ return; // somebody canceled our quit request
+ Services.startup.quit(Services.startup.eAttemptQuit | Services.startup.eRestart);
+ }
+ };
+ let secondaryActions = [
+ {
+ label: win.gNavigatorBundle.getString("e10s.offerPopup.noThanks.label"),
+ accessKey: win.gNavigatorBundle.getString("e10s.offerPopup.noThanks.accesskey"),
+ callback: function () {
+ Services.prefs.setIntPref(E10SUINotification.CURRENT_PROMPT_PREF, 5);
}
- }, Ci.nsIThread.DISPATCH_NORMAL);
+ }
+ ];
+ let options = {
+ popupIconURL: "chrome://browser/skin/e10s-64@2x.png",
+ learnMoreURL: "https://wiki.mozilla.org/Electrolysis",
+ persistWhileVisible: true
+ };
+
+ win.PopupNotifications.show(browser, "enable-e10s", promptMessage, null, mainAction, secondaryActions, options);
+
+ let highlights = [
+ win.gNavigatorBundle.getString("e10s.offerPopup.highlight1"),
+ win.gNavigatorBundle.getString("e10s.offerPopup.highlight2")
+ ];
+
+ let doorhangerExtraContent = win.document.getElementById("enable-e10s-notification")
+ .querySelector("popupnotificationcontent");
+ for (let highlight of highlights) {
+ let highlightLabel = win.document.createElement("label");
+ highlightLabel.setAttribute("value", highlight);
+ doorhangerExtraContent.appendChild(highlightLabel);
}
}
- },
-
- QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
-
- _showE10SPrompt: function BG__showE10SPrompt() {
- let win = RecentWindow.getMostRecentBrowserWindow();
- if (!win)
- return;
-
- let browser = win.gBrowser.selectedBrowser;
-
- let promptMessage = win.gNavigatorBundle.getFormattedString(
- "e10s.offerPopup.mainMessage",
- [gBrandBundle.GetStringFromName("brandShortName")]
- );
- let mainAction = {
- label: win.gNavigatorBundle.getString("e10s.offerPopup.enableAndRestart.label"),
- accessKey: win.gNavigatorBundle.getString("e10s.offerPopup.enableAndRestart.accesskey"),
- callback: function () {
- Services.prefs.setBoolPref("browser.tabs.remote.autostart", true);
- Services.prefs.setBoolPref("browser.enabledE10SFromPrompt", true);
- // Restart the app
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
- if (cancelQuit.data)
- return; // somebody canceled our quit request
- Services.startup.quit(Services.startup.eAttemptQuit | Services.startup.eRestart);
- }
- };
- let secondaryActions = [
- {
- label: win.gNavigatorBundle.getString("e10s.offerPopup.noThanks.label"),
- accessKey: win.gNavigatorBundle.getString("e10s.offerPopup.noThanks.accesskey"),
- callback: function () {
- Services.prefs.setIntPref(E10SUINotification.CURRENT_PROMPT_PREF, 5);
- }
- }
- ];
- let options = {
- popupIconURL: "chrome://browser/skin/e10s-64@2x.png",
- learnMoreURL: "https://wiki.mozilla.org/Electrolysis",
- persistWhileVisible: true
- };
-
- win.PopupNotifications.show(browser, "enable-e10s", promptMessage, null, mainAction, secondaryActions, options);
-
- let highlights = [
- win.gNavigatorBundle.getString("e10s.offerPopup.highlight1"),
- win.gNavigatorBundle.getString("e10s.offerPopup.highlight2")
- ];
-
- let doorhangerExtraContent = win.document.getElementById("enable-e10s-notification")
- .querySelector("popupnotificationcontent");
- for (let highlight of highlights) {
- let highlightLabel = win.document.createElement("label");
- highlightLabel.setAttribute("value", highlight);
- doorhangerExtraContent.appendChild(highlightLabel);
- }
- }
-};
-#endif // E10S_TESTING_ONLY
+ };
+} // E10S_TESTING_ONLY
var E10SAccessibilityCheck = {
init: function() {
Services.obs.addObserver(this, "a11y-init-or-shutdown", true);
Services.obs.addObserver(this, "quit-application-granted", true);
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),