Bug 1241993 - Fix eslint errors in nsBrowserGlue.js. r=gijs

This commit is contained in:
Jared Wein 2016-01-22 15:48:20 -05:00
parent d94916bc31
commit 3cbabf2143
5 changed files with 168 additions and 165 deletions

View File

@ -68,7 +68,6 @@ browser/components/customizableui/**
browser/components/downloads/**
browser/components/feeds/**
browser/components/migration/**
browser/components/nsBrowserGlue.js
browser/components/pocket/**
browser/components/preferences/**
browser/components/privatebrowsing/**

View File

@ -36,11 +36,11 @@ XPIDL_MODULE = 'browsercompsbase'
EXTRA_PP_COMPONENTS += [
'BrowserComponents.manifest',
'nsBrowserGlue.js',
]
EXTRA_COMPONENTS += [
'nsBrowserContentHandler.js',
'nsBrowserGlue.js',
]
EXTRA_JS_MODULES += [
@ -59,6 +59,3 @@ with Files('safebrowsing/*'):
with Files('controlcenter/**'):
BUG_COMPONENT = ('Firefox', 'General')
if CONFIG['MOZ_REQUIRE_SIGNING']:
DEFINES['MOZ_REQUIRE_SIGNING'] = 1

View File

@ -1,7 +1,6 @@
# -*- 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;
@ -12,6 +11,7 @@ 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");
@ -67,10 +67,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "PdfJs",
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");
@ -120,25 +120,25 @@ XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
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');
@ -167,9 +167,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
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");
@ -224,11 +221,11 @@ function BrowserGlue() {
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,
@ -305,16 +302,18 @@ BrowserGlue.prototype = {
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;
@ -520,10 +519,10 @@ BrowserGlue.prototype = {
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);
@ -536,9 +535,9 @@ BrowserGlue.prototype = {
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);
@ -576,10 +575,10 @@ BrowserGlue.prototype = {
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");
@ -595,9 +594,9 @@ BrowserGlue.prototype = {
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");
@ -748,11 +747,11 @@ BrowserGlue.prototype = {
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();
@ -778,29 +777,29 @@ BrowserGlue.prototype = {
SelfSupportBackend.init();
#ifndef RELEASE_BUILD
let themeName = gBrowserBundle.GetStringFromName("deveditionTheme.name");
let vendorShortName = gBrandBundle.GetStringFromName("vendorShortName");
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,
});
#endif
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 () {
@ -969,15 +968,18 @@ BrowserGlue.prototype = {
},
_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);
@ -1000,23 +1002,23 @@ BrowserGlue.prototype = {
// 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();
}
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();
}
}
#endif
ProcessHangMonitor.init();
@ -1080,16 +1082,16 @@ BrowserGlue.prototype = {
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 () {
@ -1116,9 +1118,9 @@ BrowserGlue.prototype = {
// 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();
@ -1153,11 +1155,12 @@ BrowserGlue.prototype = {
});
}
#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);
@ -1176,19 +1179,16 @@ BrowserGlue.prototype = {
// 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"].
@ -1228,12 +1228,12 @@ BrowserGlue.prototype = {
}
}
#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
@ -1266,8 +1266,10 @@ BrowserGlue.prototype = {
}
},
#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
@ -1297,7 +1299,6 @@ BrowserGlue.prototype = {
}
}
},
#endif
_maybeMigrateTabGroups() {
let migrationObserver = (stateAsSupportsString, topic) => {
@ -1764,7 +1765,7 @@ BrowserGlue.prototype = {
* 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.
@ -1902,20 +1903,20 @@ BrowserGlue.prototype = {
}
}
#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");
@ -2541,7 +2542,7 @@ ContentPermissionPrompt.prototype = {
let types = aRequest.types.QueryInterface(Ci.nsIArray);
if (types.length != 1) {
aRequest.cancel();
return;
return undefined;
}
if (!aOptions)
@ -2783,16 +2784,16 @@ var DefaultBrowserCheck = {
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);
@ -2965,7 +2966,6 @@ var DefaultBrowserCheck = {
},
};
#ifdef E10S_TESTING_ONLY
var E10SUINotification = {
CURRENT_PROMPT_PREF: "browser.displayedE10SPrompt.1",
PREVIOUS_PROMPT_PREF: "browser.displayedE10SPrompt",
@ -3030,13 +3030,13 @@ var E10SUINotification = {
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 (AppConstants.platform == "macosx") {
try {
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 &&
@ -3113,7 +3113,6 @@ var E10SUINotification = {
}
}
};
#endif // E10S_TESTING_ONLY
var E10SAccessibilityCheck = {
init: function() {

View File

@ -247,6 +247,13 @@ this.AppConstants = Object.freeze({
false,
#endif
MOZ_REQUIRE_SIGNING:
#ifdef MOZ_REQUIRE_SIGNING
true,
#else
false,
#endif
MOZ_ANDROID_HISTORY:
#ifdef MOZ_ANDROID_HISTORY
true,

View File

@ -111,6 +111,7 @@ for var in ('ANDROID_PACKAGE_NAME',
DEFINES[var] = CONFIG[var]
for var in ('MOZ_TOOLKIT_SEARCH',
'MOZ_REQUIRE_SIGNING',
'MOZ_UPDATER'):
if CONFIG[var]:
DEFINES[var] = True