Source code

Revision control

Copy as Markdown

Other Tools

/* 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/. */
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AboutNewTab: "resource:///modules/AboutNewTab.sys.mjs",
AWToolbarButton: "resource:///modules/aboutwelcome/AWToolbarUtils.sys.mjs",
ASRouter: "resource:///modules/asrouter/ASRouter.sys.mjs",
ASRouterDefaultConfig:
"resource:///modules/asrouter/ASRouterDefaultConfig.sys.mjs",
ASRouterNewTabHook: "resource:///modules/asrouter/ASRouterNewTabHook.sys.mjs",
ActorManagerParent: "resource://gre/modules/ActorManagerParent.sys.mjs",
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
AppMenuNotifications: "resource://gre/modules/AppMenuNotifications.sys.mjs",
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
BackupService: "resource:///modules/backup/BackupService.sys.mjs",
Blocklist: "resource://gre/modules/Blocklist.sys.mjs",
BookmarkHTMLUtils: "resource://gre/modules/BookmarkHTMLUtils.sys.mjs",
BookmarkJSONUtils: "resource://gre/modules/BookmarkJSONUtils.sys.mjs",
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs",
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.sys.mjs",
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
BuiltInThemes: "resource:///modules/BuiltInThemes.sys.mjs",
ContentRelevancyManager:
"resource://gre/modules/ContentRelevancyManager.sys.mjs",
ContextualIdentityService:
"resource://gre/modules/ContextualIdentityService.sys.mjs",
DAPTelemetrySender: "resource://gre/modules/DAPTelemetrySender.sys.mjs",
DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs",
Discovery: "resource:///modules/Discovery.sys.mjs",
DoHController: "resource:///modules/DoHController.sys.mjs",
DownloadsViewableInternally:
"resource:///modules/DownloadsViewableInternally.sys.mjs",
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
ExtensionsUI: "resource:///modules/ExtensionsUI.sys.mjs",
FeatureGate: "resource://featuregates/FeatureGate.sys.mjs",
FirefoxBridgeExtensionUtils:
"resource:///modules/FirefoxBridgeExtensionUtils.sys.mjs",
FormAutofillUtils: "resource://gre/modules/shared/FormAutofillUtils.sys.mjs",
FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs",
HomePage: "resource:///modules/HomePage.sys.mjs",
Integration: "resource://gre/modules/Integration.sys.mjs",
Interactions: "resource:///modules/Interactions.sys.mjs",
LoginBreaches: "resource:///modules/LoginBreaches.sys.mjs",
LoginHelper: "resource://gre/modules/LoginHelper.sys.mjs",
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
Normandy: "resource://normandy/Normandy.sys.mjs",
OnboardingMessageProvider:
"resource:///modules/asrouter/OnboardingMessageProvider.sys.mjs",
OsEnvironment: "resource://gre/modules/OsEnvironment.sys.mjs",
PageActions: "resource:///modules/PageActions.sys.mjs",
PageDataService: "resource:///modules/pagedata/PageDataService.sys.mjs",
PageThumbs: "resource://gre/modules/PageThumbs.sys.mjs",
PdfJs: "resource://pdf.js/PdfJs.sys.mjs",
PermissionUI: "resource:///modules/PermissionUI.sys.mjs",
PlacesBackups: "resource://gre/modules/PlacesBackups.sys.mjs",
PlacesDBUtils: "resource://gre/modules/PlacesDBUtils.sys.mjs",
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
// PluginManager is used by listeners object below.
// eslint-disable-next-line mozilla/valid-lazy
PluginManager: "resource:///actors/PluginParent.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.sys.mjs",
PublicSuffixList:
"resource://gre/modules/netwerk-dns/PublicSuffixList.sys.mjs",
QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
RFPHelper: "resource://gre/modules/RFPHelper.sys.mjs",
RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs",
ResetPBMPanel: "resource:///modules/ResetPBMPanel.sys.mjs",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.sys.mjs",
Sanitizer: "resource:///modules/Sanitizer.sys.mjs",
SaveToPocket: "chrome://pocket/content/SaveToPocket.sys.mjs",
ScreenshotsUtils: "resource:///modules/ScreenshotsUtils.sys.mjs",
SearchSERPCategorization: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs",
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
ShellService: "resource:///modules/ShellService.sys.mjs",
ShortcutUtils: "resource://gre/modules/ShortcutUtils.sys.mjs",
ShoppingUtils: "resource:///modules/ShoppingUtils.sys.mjs",
SpecialMessageActions:
"resource://messaging-system/lib/SpecialMessageActions.sys.mjs",
TRRRacer: "resource:///modules/TRRPerformance.sys.mjs",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.sys.mjs",
TabUnloader: "resource:///modules/TabUnloader.sys.mjs",
TelemetryUtils: "resource://gre/modules/TelemetryUtils.sys.mjs",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
WebChannel: "resource://gre/modules/WebChannel.sys.mjs",
WebProtocolHandlerRegistrar:
"resource:///modules/WebProtocolHandlerRegistrar.sys.mjs",
WindowsLaunchOnLogin: "resource://gre/modules/WindowsLaunchOnLogin.sys.mjs",
WindowsRegistry: "resource://gre/modules/WindowsRegistry.sys.mjs",
WindowsGPOParser: "resource://gre/modules/policies/WindowsGPOParser.sys.mjs",
clearTimeout: "resource://gre/modules/Timer.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
});
if (AppConstants.MOZ_UPDATER) {
ChromeUtils.defineESModuleGetters(lazy, {
UpdateListener: "resource://gre/modules/UpdateListener.sys.mjs",
});
XPCOMUtils.defineLazyServiceGetters(lazy, {
UpdateServiceStub: [
"@mozilla.org/updates/update-service-stub;1",
"nsIApplicationUpdateServiceStub",
],
});
}
if (AppConstants.MOZ_UPDATE_AGENT) {
ChromeUtils.defineESModuleGetters(lazy, {
BackgroundUpdate: "resource://gre/modules/BackgroundUpdate.sys.mjs",
});
}
// PluginManager is used in the listeners object below.
XPCOMUtils.defineLazyServiceGetters(lazy, {
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
PushService: ["@mozilla.org/push/Service;1", "nsIPushService"],
});
ChromeUtils.defineLazyGetter(
lazy,
"accountsL10n",
() => new Localization(["browser/accounts.ftl"], true)
);
if (AppConstants.ENABLE_WEBDRIVER) {
XPCOMUtils.defineLazyServiceGetter(
lazy,
"Marionette",
"@mozilla.org/remote/marionette;1",
"nsIMarionette"
);
XPCOMUtils.defineLazyServiceGetter(
lazy,
"RemoteAgent",
"@mozilla.org/remote/agent;1",
"nsIRemoteAgent"
);
} else {
lazy.Marionette = { running: false };
lazy.RemoteAgent = { running: false };
}
const PREF_PDFJS_ISDEFAULT_CACHE_STATE = "pdfjs.enabledCache.state";
const PRIVATE_BROWSING_BINARY = "private_browsing.exe";
// Index of Private Browsing icon in private_browsing.exe
// Must line up with IDI_PBICON_PB_PB_EXE in nsNativeAppSupportWin.h.
const PRIVATE_BROWSING_EXE_ICON_INDEX = 1;
const PREF_PRIVATE_BROWSING_SHORTCUT_CREATED =
"browser.privacySegmentation.createdShortcut";
// Whether this launch was initiated by the OS. A launch-on-login will contain
// the "os-autostart" flag in the initial launch command line.
let gThisInstanceIsLaunchOnLogin = false;
// Whether this launch was initiated by a taskbar tab shortcut. A launch from
// a taskbar tab shortcut will contain the "taskbar-tab" flag.
let gThisInstanceIsTaskbarTab = false;
/**
* Fission-compatible JSProcess implementations.
* Each actor options object takes the form of a ProcessActorOptions dictionary.
* Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
*/
let JSPROCESSACTORS = {
// Miscellaneous stuff that needs to be initialized per process.
BrowserProcess: {
child: {
esModuleURI: "resource:///actors/BrowserProcessChild.sys.mjs",
observers: [
// WebRTC related notifications. They are here to avoid loading WebRTC
// components when not needed.
"getUserMedia:request",
"recording-device-stopped",
"PeerConnection:request",
"recording-device-events",
"recording-window-ended",
],
},
},
RefreshBlockerObserver: {
child: {
esModuleURI: "resource:///actors/RefreshBlockerChild.sys.mjs",
observers: [
"webnavigation-create",
"chrome-webnavigation-create",
"webnavigation-destroy",
"chrome-webnavigation-destroy",
],
},
enablePreference: "accessibility.blockautorefresh",
onPreferenceChanged: (prefName, prevValue, isEnabled) => {
lazy.BrowserWindowTracker.orderedWindows.forEach(win => {
for (let browser of win.gBrowser.browsers) {
try {
browser.sendMessageToActor(
"PreferenceChanged",
{ isEnabled },
"RefreshBlocker",
"all"
);
} catch (ex) {}
}
});
},
},
};
/**
* Fission-compatible JSWindowActor implementations.
* Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
*/
let JSWINDOWACTORS = {
Megalist: {
parent: {
esModuleURI: "resource://gre/actors/MegalistParent.sys.mjs",
},
child: {
esModuleURI: "resource://gre/actors/MegalistChild.sys.mjs",
events: {
DOMContentLoaded: {},
},
},
includeChrome: true,
matches: ["chrome://global/content/megalist/megalist.html"],
allFrames: true,
enablePreference: "browser.megalist.enabled",
},
AboutLogins: {
parent: {
esModuleURI: "resource:///actors/AboutLoginsParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutLoginsChild.sys.mjs",
events: {
AboutLoginsCopyLoginDetail: { wantUntrusted: true },
AboutLoginsCreateLogin: { wantUntrusted: true },
AboutLoginsDeleteLogin: { wantUntrusted: true },
AboutLoginsDismissBreachAlert: { wantUntrusted: true },
AboutLoginsImportFromBrowser: { wantUntrusted: true },
AboutLoginsImportFromFile: { wantUntrusted: true },
AboutLoginsImportReportInit: { wantUntrusted: true },
AboutLoginsImportReportReady: { wantUntrusted: true },
AboutLoginsInit: { wantUntrusted: true },
AboutLoginsGetHelp: { wantUntrusted: true },
AboutLoginsOpenPreferences: { wantUntrusted: true },
AboutLoginsOpenSite: { wantUntrusted: true },
AboutLoginsRecordTelemetryEvent: { wantUntrusted: true },
AboutLoginsRemoveAllLogins: { wantUntrusted: true },
AboutLoginsSortChanged: { wantUntrusted: true },
AboutLoginsSyncEnable: { wantUntrusted: true },
AboutLoginsSyncOptions: { wantUntrusted: true },
AboutLoginsUpdateLogin: { wantUntrusted: true },
AboutLoginsExportPasswords: { wantUntrusted: true },
},
},
matches: ["about:logins", "about:logins?*", "about:loginsimportreport"],
allFrames: true,
remoteTypes: ["privilegedabout"],
},
AboutMessagePreview: {
parent: {
esModuleURI: "resource:///actors/AboutMessagePreviewParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutMessagePreviewChild.sys.mjs",
events: {
DOMDocElementInserted: { capture: true },
},
},
matches: ["about:messagepreview", "about:messagepreview?*"],
},
AboutNewTab: {
parent: {
esModuleURI: "resource:///actors/AboutNewTabParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutNewTabChild.sys.mjs",
events: {
DOMDocElementInserted: {},
DOMContentLoaded: {},
load: { capture: true },
unload: { capture: true },
pageshow: {},
visibilitychange: {},
},
},
// The wildcard on about:newtab is for the # parameter
// that is used for the newtab devtools. The wildcard for about:home
// is similar, and also allows for falling back to loading the
// about:home document dynamically if an attempt is made to load
// about:home?jscache from the AboutHomeStartupCache as a top-level
// load.
matches: ["about:home*", "about:welcome", "about:newtab*"],
remoteTypes: ["privilegedabout"],
},
AboutPocket: {
parent: {
esModuleURI: "resource:///actors/AboutPocketParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutPocketChild.sys.mjs",
events: {
DOMDocElementInserted: { capture: true },
},
},
remoteTypes: ["privilegedabout"],
matches: [
"about:pocket-saved*",
"about:pocket-signup*",
"about:pocket-home*",
"about:pocket-style-guide*",
],
},
AboutPrivateBrowsing: {
parent: {
esModuleURI: "resource:///actors/AboutPrivateBrowsingParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutPrivateBrowsingChild.sys.mjs",
events: {
DOMDocElementInserted: { capture: true },
},
},
matches: ["about:privatebrowsing*"],
},
AboutProtections: {
parent: {
esModuleURI: "resource:///actors/AboutProtectionsParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutProtectionsChild.sys.mjs",
events: {
DOMDocElementInserted: { capture: true },
},
},
matches: ["about:protections", "about:protections?*"],
},
AboutReader: {
parent: {
esModuleURI: "resource:///actors/AboutReaderParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutReaderChild.sys.mjs",
events: {
DOMContentLoaded: {},
pageshow: { mozSystemGroup: true },
// Don't try to create the actor if only the pagehide event fires.
// This can happen with the initial about:blank documents.
pagehide: { mozSystemGroup: true, createActor: false },
},
},
messageManagerGroups: ["browsers"],
},
AboutTabCrashed: {
parent: {
esModuleURI: "resource:///actors/AboutTabCrashedParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutTabCrashedChild.sys.mjs",
events: {
DOMDocElementInserted: { capture: true },
},
},
matches: ["about:tabcrashed*"],
},
AboutWelcomeShopping: {
parent: {
esModuleURI: "resource:///actors/AboutWelcomeParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutWelcomeChild.sys.mjs",
events: {
Update: {},
},
},
matches: ["about:shoppingsidebar"],
remoteTypes: ["privilegedabout"],
},
AboutWelcome: {
parent: {
esModuleURI: "resource:///actors/AboutWelcomeParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/AboutWelcomeChild.sys.mjs",
events: {
// This is added so the actor instantiates immediately and makes
// methods available to the page js on load.
DOMDocElementInserted: {},
},
},
matches: ["about:welcome"],
remoteTypes: ["privilegedabout"],
// See Bug 1618306
// Remove this preference check when we turn on separate about:welcome for all users.
enablePreference: "browser.aboutwelcome.enabled",
},
BackupUI: {
parent: {
esModuleURI: "resource:///actors/BackupUIParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/BackupUIChild.sys.mjs",
events: {
"BackupUI:InitWidget": { wantUntrusted: true },
"BackupUI:ToggleScheduledBackups": { wantUntrusted: true },
"BackupUI:ShowFilepicker": { wantUntrusted: true },
"BackupUI:GetBackupFileInfo": { wantUntrusted: true },
"BackupUI:RestoreFromBackupFile": { wantUntrusted: true },
"BackupUI:RestoreFromBackupChooseFile": { wantUntrusted: true },
},
},
matches: ["about:preferences*", "about:settings*"],
enablePreference: "browser.backup.preferences.ui.enabled",
},
BlockedSite: {
parent: {
esModuleURI: "resource:///actors/BlockedSiteParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/BlockedSiteChild.sys.mjs",
events: {
AboutBlockedLoaded: { wantUntrusted: true },
click: {},
},
},
matches: ["about:blocked?*"],
allFrames: true,
},
BrowserTab: {
child: {
esModuleURI: "resource:///actors/BrowserTabChild.sys.mjs",
},
messageManagerGroups: ["browsers"],
},
ClickHandler: {
parent: {
esModuleURI: "resource:///actors/ClickHandlerParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ClickHandlerChild.sys.mjs",
events: {
chromelinkclick: { capture: true, mozSystemGroup: true },
},
},
allFrames: true,
},
/* Note: this uses the same JSMs as ClickHandler, but because it
* relies on "normal" click events anywhere on the page (not just
* links) and is expensive, and only does something for the
* small group of people who have the feature enabled, it is its
* own actor which is only registered if the pref is enabled.
*/
MiddleMousePasteHandler: {
parent: {
esModuleURI: "resource:///actors/ClickHandlerParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ClickHandlerChild.sys.mjs",
events: {
auxclick: { capture: true, mozSystemGroup: true },
},
},
enablePreference: "middlemouse.contentLoadURL",
allFrames: true,
},
ContentSearch: {
parent: {
esModuleURI: "resource:///actors/ContentSearchParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ContentSearchChild.sys.mjs",
events: {
ContentSearchClient: { capture: true, wantUntrusted: true },
},
},
matches: [
"about:home",
"about:welcome",
"about:newtab",
"about:privatebrowsing",
"about:test-about-content-search-ui",
],
remoteTypes: ["privilegedabout"],
},
ContextMenu: {
parent: {
esModuleURI: "resource:///actors/ContextMenuParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ContextMenuChild.sys.mjs",
events: {
contextmenu: { mozSystemGroup: true },
},
},
allFrames: true,
},
DecoderDoctor: {
parent: {
esModuleURI: "resource:///actors/DecoderDoctorParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/DecoderDoctorChild.sys.mjs",
observers: ["decoder-doctor-notification"],
},
messageManagerGroups: ["browsers"],
allFrames: true,
},
DOMFullscreen: {
parent: {
esModuleURI: "resource:///actors/DOMFullscreenParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/DOMFullscreenChild.sys.mjs",
events: {
"MozDOMFullscreen:Request": {},
"MozDOMFullscreen:Entered": {},
"MozDOMFullscreen:NewOrigin": {},
"MozDOMFullscreen:Exit": {},
"MozDOMFullscreen:Exited": {},
},
},
messageManagerGroups: ["browsers"],
allFrames: true,
},
EncryptedMedia: {
parent: {
esModuleURI: "resource:///actors/EncryptedMediaParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/EncryptedMediaChild.sys.mjs",
observers: ["mediakeys-request"],
},
messageManagerGroups: ["browsers"],
allFrames: true,
},
FormValidation: {
parent: {
esModuleURI: "resource:///actors/FormValidationParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/FormValidationChild.sys.mjs",
events: {
MozInvalidForm: {},
// Listening to ‘pageshow’ event is only relevant if an invalid form
// popup was open, so don't create the actor when fired.
pageshow: { createActor: false },
},
},
allFrames: true,
},
LightweightTheme: {
child: {
esModuleURI: "resource:///actors/LightweightThemeChild.sys.mjs",
events: {
pageshow: { mozSystemGroup: true },
DOMContentLoaded: {},
},
},
includeChrome: true,
allFrames: true,
matches: [
"about:asrouter",
"about:home",
"about:newtab",
"about:welcome",
"chrome://browser/content/syncedtabs/sidebar.xhtml",
"chrome://browser/content/places/historySidebar.xhtml",
"chrome://browser/content/places/bookmarksSidebar.xhtml",
"about:firefoxview",
],
},
LinkHandler: {
parent: {
esModuleURI: "resource:///actors/LinkHandlerParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/LinkHandlerChild.sys.mjs",
events: {
DOMHeadElementParsed: {},
DOMLinkAdded: {},
DOMLinkChanged: {},
pageshow: {},
// The `pagehide` event is only used to clean up state which will not be
// present if the actor hasn't been created.
pagehide: { createActor: false },
},
},
messageManagerGroups: ["browsers"],
},
PageInfo: {
child: {
esModuleURI: "resource:///actors/PageInfoChild.sys.mjs",
},
allFrames: true,
},
PageStyle: {
parent: {
esModuleURI: "resource:///actors/PageStyleParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/PageStyleChild.sys.mjs",
events: {
pageshow: { createActor: false },
},
},
messageManagerGroups: ["browsers"],
allFrames: true,
},
Pdfjs: {
parent: {
esModuleURI: "resource://pdf.js/PdfjsParent.sys.mjs",
},
child: {
esModuleURI: "resource://pdf.js/PdfjsChild.sys.mjs",
},
allFrames: true,
},
// GMP crash reporting
Plugin: {
parent: {
esModuleURI: "resource:///actors/PluginParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/PluginChild.sys.mjs",
events: {
PluginCrashed: { capture: true },
},
},
allFrames: true,
},
PointerLock: {
parent: {
esModuleURI: "resource:///actors/PointerLockParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/PointerLockChild.sys.mjs",
events: {
"MozDOMPointerLock:Entered": {},
"MozDOMPointerLock:Exited": {},
},
},
messageManagerGroups: ["browsers"],
allFrames: true,
},
Profiles: {
parent: {
},
child: {
},
matches: ["about:profilemanager"],
enablePreference: "browser.profiles.enabled",
},
Prompt: {
parent: {
esModuleURI: "resource:///actors/PromptParent.sys.mjs",
},
includeChrome: true,
allFrames: true,
},
RefreshBlocker: {
parent: {
esModuleURI: "resource:///actors/RefreshBlockerParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/RefreshBlockerChild.sys.mjs",
},
messageManagerGroups: ["browsers"],
enablePreference: "accessibility.blockautorefresh",
},
ScreenshotsComponent: {
parent: {
esModuleURI: "resource:///modules/ScreenshotsUtils.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ScreenshotsComponentChild.sys.mjs",
events: {
"Screenshots:Close": {},
"Screenshots:Copy": {},
"Screenshots:Download": {},
"Screenshots:HidePanel": {},
"Screenshots:OverlaySelection": {},
"Screenshots:RecordEvent": {},
"Screenshots:ShowPanel": {},
"Screenshots:FocusPanel": {},
},
},
enablePreference: "screenshots.browser.component.enabled",
},
ScreenshotsHelper: {
parent: {
esModuleURI: "resource:///modules/ScreenshotsUtils.sys.mjs",
},
child: {
esModuleURI: "resource:///modules/ScreenshotsHelperChild.sys.mjs",
},
allFrames: true,
enablePreference: "screenshots.browser.component.enabled",
},
SearchSERPTelemetry: {
parent: {
esModuleURI: "resource:///actors/SearchSERPTelemetryParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/SearchSERPTelemetryChild.sys.mjs",
events: {
DOMContentLoaded: {},
pageshow: { mozSystemGroup: true },
// The 'pagehide' event is only used to clean up state, and should not
// force actor creation.
pagehide: { createActor: false },
load: { mozSystemGroup: true, capture: true },
},
},
matches: ["https://*/*"],
},
ShieldFrame: {
parent: {
esModuleURI: "resource://normandy-content/ShieldFrameParent.sys.mjs",
},
child: {
esModuleURI: "resource://normandy-content/ShieldFrameChild.sys.mjs",
events: {
pageshow: {},
pagehide: {},
ShieldPageEvent: { wantUntrusted: true },
},
},
matches: ["about:studies*"],
},
ShoppingSidebar: {
parent: {
esModuleURI: "resource:///actors/ShoppingSidebarParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ShoppingSidebarChild.sys.mjs",
events: {
ContentReady: { wantUntrusted: true },
PolledRequestMade: { wantUntrusted: true },
// This is added so the actor instantiates immediately and makes
// methods available to the page js on load.
DOMDocElementInserted: {},
ReportProductAvailable: { wantUntrusted: true },
AdClicked: { wantUntrusted: true },
AdImpression: { wantUntrusted: true },
DisableShopping: { wantUntrusted: true },
},
},
matches: ["about:shoppingsidebar"],
remoteTypes: ["privilegedabout"],
},
SpeechDispatcher: {
parent: {
esModuleURI: "resource:///actors/SpeechDispatcherParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/SpeechDispatcherChild.sys.mjs",
observers: ["chrome-synth-voices-error"],
},
messageManagerGroups: ["browsers"],
allFrames: true,
},
ASRouter: {
parent: {
esModuleURI: "resource:///actors/ASRouterParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/ASRouterChild.sys.mjs",
events: {
// This is added so the actor instantiates immediately and makes
// methods available to the page js on load.
DOMDocElementInserted: {},
},
},
matches: [
"about:asrouter*",
"about:home*",
"about:newtab*",
"about:welcome*",
"about:privatebrowsing*",
],
remoteTypes: ["privilegedabout"],
},
SwitchDocumentDirection: {
child: {
esModuleURI: "resource:///actors/SwitchDocumentDirectionChild.sys.mjs",
},
allFrames: true,
},
UITour: {
parent: {
esModuleURI: "resource:///modules/UITourParent.sys.mjs",
},
child: {
esModuleURI: "resource:///modules/UITourChild.sys.mjs",
events: {
mozUITour: { wantUntrusted: true },
},
},
messageManagerGroups: ["browsers"],
},
WebRTC: {
parent: {
esModuleURI: "resource:///actors/WebRTCParent.sys.mjs",
},
child: {
esModuleURI: "resource:///actors/WebRTCChild.sys.mjs",
},
allFrames: true,
},
};
ChromeUtils.defineLazyGetter(
lazy,
"WeaveService",
() => Cc["@mozilla.org/weave/service;1"].getService().wrappedJSObject
);
if (AppConstants.MOZ_CRASHREPORTER) {
ChromeUtils.defineESModuleGetters(lazy, {
UnsubmittedCrashHandler: "resource:///modules/ContentCrashHandlers.sys.mjs",
});
}
ChromeUtils.defineLazyGetter(lazy, "gBrandBundle", function () {
return Services.strings.createBundle(
"chrome://branding/locale/brand.properties"
);
});
ChromeUtils.defineLazyGetter(lazy, "gBrowserBundle", function () {
return Services.strings.createBundle(
"chrome://browser/locale/browser.properties"
);
});
ChromeUtils.defineLazyGetter(lazy, "log", () => {
let { ConsoleAPI } = ChromeUtils.importESModule(
"resource://gre/modules/Console.sys.mjs"
);
let consoleOptions = {
// tip: set maxLogLevel to "debug" and use lazy.log.debug() to create
// detailed messages during development. See LOG_LEVELS in Console.sys.mjs
// for details.
maxLogLevel: "error",
maxLogLevelPref: "browser.policies.loglevel",
prefix: "BrowserGlue.sys.mjs",
};
return new ConsoleAPI(consoleOptions);
});
const listeners = {
observers: {
"gmp-plugin-crash": ["PluginManager"],
"plugin-crashed": ["PluginManager"],
},
observe(subject, topic, data) {
for (let module of this.observers[topic]) {
try {
lazy[module].observe(subject, topic, data);
} catch (e) {
console.error(e);
}
}
},
init() {
for (let observer of Object.keys(this.observers)) {
Services.obs.addObserver(this, observer);
}
},
};
if (AppConstants.MOZ_UPDATER) {
listeners.observers["update-downloading"] = ["UpdateListener"];
listeners.observers["update-staged"] = ["UpdateListener"];
listeners.observers["update-downloaded"] = ["UpdateListener"];
listeners.observers["update-available"] = ["UpdateListener"];
listeners.observers["update-error"] = ["UpdateListener"];
listeners.observers["update-swap"] = ["UpdateListener"];
}
// Seconds of idle before trying to create a bookmarks backup.
const BOOKMARKS_BACKUP_IDLE_TIME_SEC = 8 * 60;
// Minimum interval between backups. We try to not create more than one backup
// per interval.
const BOOKMARKS_BACKUP_MIN_INTERVAL_DAYS = 1;
// Seconds of idle time before the late idle tasks will be scheduled.
const LATE_TASKS_IDLE_TIME_SEC = 20;
// Time after we stop tracking startup crashes.
const STARTUP_CRASHES_END_DELAY_MS = 30 * 1000;
/*
* 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";
export let BrowserInitState = {};
BrowserInitState.startupIdleTaskPromise = new Promise(resolve => {
BrowserInitState._resolveStartupIdleTask = resolve;
});
export function BrowserGlue() {
XPCOMUtils.defineLazyServiceGetter(
this,
"_userIdleService",
"@mozilla.org/widget/useridleservice;1",
"nsIUserIdleService"
);
ChromeUtils.defineLazyGetter(this, "_distributionCustomizer", function () {
const { DistributionCustomizer } = ChromeUtils.importESModule(
"resource:///modules/distribution.sys.mjs"
);
return new DistributionCustomizer();
});
XPCOMUtils.defineLazyServiceGetter(
this,
"AlertsService",
"@mozilla.org/alerts-service;1",
"nsIAlertsService"
);
this._init();
}
function WindowsRegPoliciesGetter(wrk, root, regLocation) {
wrk.open(root, regLocation, wrk.ACCESS_READ);
let policies;
if (wrk.hasChild("Mozilla\\" + Services.appinfo.name)) {
policies = lazy.WindowsGPOParser.readPolicies(wrk, policies);
}
wrk.close();
return policies;
}
function isPrivateBrowsingAllowedInRegistry() {
// If there is an attempt to open Private Browsing before
// EnterprisePolicies are initialized the Windows registry
// can be checked to determine if it is enabled
if (Services.policies.status > Ci.nsIEnterprisePolicies.UNINITIALIZED) {
// Yield to policies engine if initialized
let privateAllowed = Services.policies.isAllowed("privatebrowsing");
lazy.log.debug(
`Yield to initialized policies engine: Private Browsing Allowed = ${privateAllowed}`
);
return privateAllowed;
}
if (AppConstants.platform !== "win") {
// Not using Windows so no registry, return true
lazy.log.debug(
"AppConstants.platform is not 'win': Private Browsing allowed"
);
return true;
}
// If all other checks fail only then do we check registry
let wrk = Cc["@mozilla.org/windows-registry-key;1"].createInstance(
Ci.nsIWindowsRegKey
);
let regLocation = "SOFTWARE\\Policies";
let userPolicies, machinePolicies;
// Only check HKEY_LOCAL_MACHINE if not in testing
if (!Cu.isInAutomation) {
machinePolicies = WindowsRegPoliciesGetter(
wrk,
wrk.ROOT_KEY_LOCAL_MACHINE,
regLocation
);
}
// Check machine policies before checking user policies
// HKEY_LOCAL_MACHINE supersedes HKEY_CURRENT_USER so only check
// HKEY_CURRENT_USER if the registry key is not present in
// HKEY_LOCAL_MACHINE at all
if (machinePolicies && "DisablePrivateBrowsing" in machinePolicies) {
lazy.log.debug(
`DisablePrivateBrowsing in HKEY_LOCAL_MACHINE is ${machinePolicies.DisablePrivateBrowsing}`
);
return !(machinePolicies.DisablePrivateBrowsing === 1);
}
userPolicies = WindowsRegPoliciesGetter(
wrk,
wrk.ROOT_KEY_CURRENT_USER,
regLocation
);
if (userPolicies && "DisablePrivateBrowsing" in userPolicies) {
lazy.log.debug(
`DisablePrivateBrowsing in HKEY_CURRENT_USER is ${userPolicies.DisablePrivateBrowsing}`
);
return !(userPolicies.DisablePrivateBrowsing === 1);
}
// Private browsing allowed if no registry entry exists
lazy.log.debug(
"No DisablePrivateBrowsing registry entry: Private Browsing allowed"
);
return true;
}
BrowserGlue.prototype = {
_saveSession: false,
_migrationImportsDefaultBookmarks: false,
_placesBrowserInitComplete: false,
_isNewProfile: undefined,
_defaultCookieBehaviorAtStartup: null,
_setPrefToSaveSession: function BG__setPrefToSaveSession(aForce) {
if (!this._saveSession && !aForce) {
return;
}
if (!lazy.PrivateBrowsingUtils.permanentPrivateBrowsing) {
Services.prefs.setBoolPref(
"browser.sessionstore.resume_session_once",
true
);
}
// This method can be called via [NSApplication terminate:] on Mac, which
// ends up causing prefs not to be flushed to disk, so we need to do that
// explicitly here. See bug 497652.
Services.prefs.savePrefFile(null);
},
// nsIObserver implementation
observe: async function BG_observe(subject, topic, data) {
switch (topic) {
case "notifications-open-settings":
this._openPreferences("privacy-permissions");
break;
case "final-ui-startup":
this._beforeUIStartup();
break;
case "browser-delayed-startup-finished":
this._onFirstWindowLoaded(subject);
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
break;
case "sessionstore-windows-restored":
this._onWindowsRestored();
break;
case "browser:purge-session-history":
// reset the console service's error buffer
Services.console.logStringMessage(null); // clear the console (in case it's open)
Services.console.reset();
break;
case "restart-in-safe-mode":
this._onSafeModeRestart(subject);
break;
case "quit-application-requested":
this._onQuitRequest(subject, data);
break;
case "quit-application-granted":
this._onQuitApplicationGranted();
break;
case "browser-lastwindow-close-requested":
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":
if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
this._setPrefToSaveSession();
}
break;
case "fxaccounts:onverified":
this._onThisDeviceConnected();
break;
case "fxaccounts:device_connected":
this._onDeviceConnected(data);
break;
case "fxaccounts:verify_login":
this._onVerifyLoginNotification(JSON.parse(data));
break;
case "fxaccounts:device_disconnected":
data = JSON.parse(data);
if (data.isLocalDevice) {
this._onDeviceDisconnected();
}
break;
case "fxaccounts:commands:open-uri":
this._onDisplaySyncURIs(subject);
break;
case "fxaccounts:commands:close-uri":
this._onIncomingCloseTabCommand(subject);
break;
case "session-save":
this._setPrefToSaveSession(true);
subject.QueryInterface(Ci.nsISupportsPRBool);
subject.data = true;
break;
case "places-init-complete":
Services.obs.removeObserver(this, "places-init-complete");
if (!this._migrationImportsDefaultBookmarks) {
this._initPlaces(false);
}
break;
case "idle":
this._backupBookmarks();
break;
case "distribution-customization-complete":
Services.obs.removeObserver(
this,
"distribution-customization-complete"
);
// Customization has finished, we don't need the customizer anymore.
delete this._distributionCustomizer;
break;
case "browser-glue-test": // used by tests
if (data == "force-ui-migration") {
this._migrateUI();
} else if (data == "force-distribution-customization") {
this._distributionCustomizer.applyCustomizations();
// To apply distribution bookmarks use "places-init-complete".
} else if (data == "test-force-places-init") {
this._placesInitialized = false;
this._initPlaces(false);
} else if (data == "mock-alerts-service") {
Object.defineProperty(this, "AlertsService", {
value: subject.wrappedJSObject,
});
} else if (data == "places-browser-init-complete") {
if (this._placesBrowserInitComplete) {
Services.obs.notifyObservers(null, "places-browser-init-complete");
}
} else if (data == "add-breaches-sync-handler") {
this._addBreachesSyncHandler();
}
break;
case "initial-migration-will-import-default-bookmarks":
this._migrationImportsDefaultBookmarks = true;
break;
case "initial-migration-did-import-default-bookmarks":
this._initPlaces(true);
break;
case "handle-xul-text-link": {
let linkHandled = subject.QueryInterface(Ci.nsISupportsPRBool);
if (!linkHandled.data) {
let win = lazy.BrowserWindowTracker.getTopWindow();
if (win) {
data = JSON.parse(data);
let where = lazy.BrowserUtils.whereToOpenLink(data);
// Preserve legacy behavior of non-modifier left-clicks
// opening in a new selected tab.
if (where == "current") {
where = "tab";
}
win.openTrustedLinkIn(data.href, where);
linkHandled.data = true;
}
}
break;
}
case "profile-before-change":
// Any component depending on Places should be finalized in
// _onPlacesShutdown. Any component that doesn't need to act after
// the UI has gone should be finalized in _onQuitApplicationGranted.
this._dispose();
break;
case "keyword-search": {
// This notification is broadcast by the docshell when it "fixes up" a
// URI that it's been asked to load into a keyword search.
let engine = null;
try {
engine = Services.search.getEngineByName(
subject.QueryInterface(Ci.nsISupportsString).data
);
} catch (ex) {
console.error(ex);
}
let win = lazy.BrowserWindowTracker.getTopWindow();
lazy.BrowserSearchTelemetry.recordSearch(
win.gBrowser.selectedBrowser,
engine,
"urlbar"
);
break;
}
case "xpi-signature-changed": {
let disabledAddons = JSON.parse(data).disabled;
let addons = await lazy.AddonManager.getAddonsByIDs(disabledAddons);
if (addons.some(addon => addon)) {
this._notifyUnsignedAddonsDisabled();
}
break;
}
case "sync-ui-state:update":
this._updateFxaBadges(lazy.BrowserWindowTracker.getTopWindow());
break;
case "handlersvc-store-initialized":
// Initialize PdfJs when running in-process and remote. This only
// happens once since PdfJs registers global hooks. If the PdfJs
// extension is installed the init method below will be overridden
// leaving initialization to the extension.
// parent only: configure default prefs, set up pref observers, register
// pdf content handler, and initializes parent side message manager
// shim for privileged api access.
lazy.PdfJs.init(this._isNewProfile);
// Allow certain viewable internally types to be opened from downloads.
lazy.DownloadsViewableInternally.register();
break;
case "app-startup": {
this._earlyBlankFirstPaint(subject);
gThisInstanceIsTaskbarTab = subject.handleFlag("taskbar-tab", false);
gThisInstanceIsLaunchOnLogin = subject.handleFlag(
"os-autostart",
false
);
let launchOnLoginPref = "browser.startup.windowsLaunchOnLogin.enabled";
let profileSvc = Cc[
"@mozilla.org/toolkit/profile-service;1"
].getService(Ci.nsIToolkitProfileService);
if (
AppConstants.platform == "win" &&
!profileSvc.startWithLastProfile
) {
// If we don't start with last profile, the user
// likely sees the profile selector on launch.
if (Services.prefs.getBoolPref(launchOnLoginPref)) {
Services.telemetry.setEventRecordingEnabled(
"launch_on_login",
true
);
Services.telemetry.recordEvent(
"launch_on_login",
"last_profile_disable",
"startup"
);
}
Services.prefs.setBoolPref(launchOnLoginPref, false);
// To reduce confusion when running multiple Gecko profiles,
// delete launch on login shortcuts and registry keys so that
// users are not presented with the outdated profile selector
// dialog.
lazy.WindowsLaunchOnLogin.removeLaunchOnLogin();
}
break;
}
}
},
// initialization (called on application startup)
_init: function BG__init() {
let os = Services.obs;
[
"notifications-open-settings",
"final-ui-startup",
"browser-delayed-startup-finished",
"sessionstore-windows-restored",
"browser:purge-session-history",
"quit-application-requested",
"quit-application-granted",
"fxaccounts:onverified",
"fxaccounts:device_connected",
"fxaccounts:verify_login",
"fxaccounts:device_disconnected",
"fxaccounts:commands:open-uri",
"fxaccounts:commands:close-uri",
"session-save",
"places-init-complete",
"distribution-customization-complete",
"handle-xul-text-link",
"profile-before-change",
"keyword-search",
"restart-in-safe-mode",
"xpi-signature-changed",
"sync-ui-state:update",
"handlersvc-store-initialized",
].forEach(topic => os.addObserver(this, topic, true));
if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
os.addObserver(this, "browser-lastwindow-close-requested", true);
os.addObserver(this, "browser-lastwindow-close-granted", true);
}
lazy.ActorManagerParent.addJSProcessActors(JSPROCESSACTORS);
lazy.ActorManagerParent.addJSWindowActors(JSWINDOWACTORS);
this._firstWindowReady = new Promise(
resolve => (this._firstWindowLoaded = resolve)
);
},
// cleanup (called on application shutdown)
_dispose: function BG__dispose() {
// AboutHomeStartupCache might write to the cache during
// quit-application-granted, so we defer uninitialization
// until here.
AboutHomeStartupCache.uninit();
if (this._bookmarksBackupIdleTime) {
this._userIdleService.removeIdleObserver(
this,
this._bookmarksBackupIdleTime
);
this._bookmarksBackupIdleTime = null;
}
if (this._lateTasksIdleObserver) {
this._userIdleService.removeIdleObserver(
this._lateTasksIdleObserver,
LATE_TASKS_IDLE_TIME_SEC
);
delete this._lateTasksIdleObserver;
}
if (this._gmpInstallManager) {
this._gmpInstallManager.uninit();
delete this._gmpInstallManager;
}
Services.prefs.removeObserver(
"privacy.trackingprotection",
this._matchCBCategory
);
Services.prefs.removeObserver(
"network.cookie.cookieBehavior",
this._matchCBCategory
);
Services.prefs.removeObserver(
"network.cookie.cookieBehavior.pbmode",
this._matchCBCategory
);
Services.prefs.removeObserver(
"network.http.referer.disallowCrossSiteRelaxingDefault",
this._matchCBCategory
);
Services.prefs.removeObserver(
"network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation",
this._matchCBCategory
);
Services.prefs.removeObserver(
"privacy.partition.network_state.ocsp_cache",
this._matchCBCategory
);
Services.prefs.removeObserver(
"privacy.query_stripping.enabled",
this._matchCBCategory
);
Services.prefs.removeObserver(
"privacy.query_stripping.enabled.pbmode",
this._matchCBCategory
);
Services.prefs.removeObserver(
"privacy.fingerprintingProtection",
this._matchCBCategory
);
Services.prefs.removeObserver(
"privacy.fingerprintingProtection.pbmode",
this._matchCBCategory
);
Services.prefs.removeObserver(
ContentBlockingCategoriesPrefs.PREF_CB_CATEGORY,
this._updateCBCategory
);
Services.prefs.removeObserver(
"privacy.trackingprotection",
this._setPrefExpectations
);
Services.prefs.removeObserver(
"browser.contentblocking.features.strict",
this._setPrefExpectationsAndUpdate
);
},
// runs on startup, before the first command line handler is invoked
// (i.e. before the first window is opened)
_beforeUIStartup: function BG__beforeUIStartup() {
lazy.SessionStartup.init();
// check if we're in safe mode
if (Services.appinfo.inSafeMode) {
Services.ww.openWindow(
null,
"chrome://browser/content/safeMode.xhtml",
"_blank",
"chrome,centerscreen,modal,resizable=no",
null
);
}
// apply distribution customizations
this._distributionCustomizer.applyCustomizations();
// handle any UI migration
this._migrateUI();
if (!Services.prefs.prefHasUserValue(PREF_PDFJS_ISDEFAULT_CACHE_STATE)) {
lazy.PdfJs.checkIsDefault(this._isNewProfile);
}
if (!AppConstants.NIGHTLY_BUILD && this._isNewProfile) {
lazy.FormAutofillUtils.setOSAuthEnabled(
lazy.FormAutofillUtils.AUTOFILL_CREDITCARDS_REAUTH_PREF,
false
);
lazy.LoginHelper.setOSAuthEnabled(
lazy.LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF,
false
);
}
listeners.init();
lazy.SessionStore.init();
lazy.BuiltInThemes.maybeInstallActiveBuiltInTheme();
if (AppConstants.MOZ_NORMANDY) {
lazy.Normandy.init();
}
lazy.SaveToPocket.init();
lazy.ResetPBMPanel.init();
AboutHomeStartupCache.init();
Services.obs.notifyObservers(null, "browser-ui-startup-complete");
},
_checkForOldBuildUpdates() {
// check for update if our build is old
if (
AppConstants.MOZ_UPDATER &&
Services.prefs.getBoolPref("app.update.checkInstallTime")
) {
let buildID = Services.appinfo.appBuildID;
let today = new Date().getTime();
/* eslint-disable no-multi-spaces */
let buildDate = new Date(
buildID.slice(0, 4), // year
buildID.slice(4, 6) - 1, // months are zero-based.
buildID.slice(6, 8), // day
buildID.slice(8, 10), // hour
buildID.slice(10, 12), // min
buildID.slice(12, 14)
) // ms
.getTime();
/* eslint-enable no-multi-spaces */
const millisecondsIn24Hours = 86400000;
let acceptableAge =
Services.prefs.getIntPref("app.update.checkInstallTime.days") *
millisecondsIn24Hours;
if (buildDate + acceptableAge < today) {
// This is asynchronous, but just kick it off rather than waiting.
Cc["@mozilla.org/updates/update-service;1"]
.getService(Ci.nsIApplicationUpdateService)
.checkForBackgroundUpdates();
}
}
},
async _onSafeModeRestart(window) {
// prompt the user to confirm
let productName = lazy.gBrandBundle.GetStringFromName("brandShortName");
let strings = lazy.gBrowserBundle;
let promptTitle = strings.formatStringFromName(
"troubleshootModeRestartPromptTitle",
[productName]
);
let promptMessage = strings.GetStringFromName(
"troubleshootModeRestartPromptMessage"
);
let restartText = strings.GetStringFromName(
"troubleshootModeRestartButton"
);
let buttonFlags =
Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL +
Services.prompt.BUTTON_POS_0_DEFAULT;
let rv = await Services.prompt.asyncConfirmEx(
window.browsingContext,
Ci.nsIPrompt.MODAL_TYPE_INTERNAL_WINDOW,
promptTitle,
promptMessage,
buttonFlags,
restartText,
null,
null,
null,
{}
);
if (rv.get("buttonNumClicked") != 0) {
return;
}
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
Ci.nsISupportsPRBool
);