Bug 1555662 - Register L10nRegistry sources using categories. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D34227

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Zibi Braniecki 2019-06-07 20:11:00 +00:00
Родитель c9344d2f6c
Коммит 6ca89e400f
12 изменённых файлов: 29 добавлений и 25 удалений

Просмотреть файл

@ -35,6 +35,7 @@ const startupPhases = {
"resource://gre/modules/MainProcessSingleton.jsm",
"resource://gre/modules/XPCOMUtils.jsm",
"resource://gre/modules/Services.jsm",
"resource://gre/modules/L10nRegistry.jsm",
// Bugs to fix: The following components shouldn't be initialized that early.
"resource://gre/modules/PushComponents.jsm", // bug 1369436
]),

Просмотреть файл

@ -435,12 +435,10 @@ XPCOMUtils.defineLazyModuleGetters(this, {
DateTimePickerParent: "resource://gre/modules/DateTimePickerParent.jsm",
Discovery: "resource:///modules/Discovery.jsm",
ExtensionsUI: "resource:///modules/ExtensionsUI.jsm",
FileSource: "resource://gre/modules/L10nRegistry.jsm",
FxAccounts: "resource://gre/modules/FxAccounts.jsm",
HomePage: "resource:///modules/HomePage.jsm",
HybridContentTelemetry: "resource://gre/modules/HybridContentTelemetry.jsm",
Integration: "resource://gre/modules/Integration.jsm",
L10nRegistry: "resource://gre/modules/L10nRegistry.jsm",
LiveBookmarkMigrator: "resource:///modules/LiveBookmarkMigrator.jsm",
NewTabUtils: "resource://gre/modules/NewTabUtils.jsm",
Normandy: "resource://normandy/Normandy.jsm",
@ -1065,14 +1063,6 @@ BrowserGlue.prototype = {
PdfJs.earlyInit();
}
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.packagedLocales;
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
const appSource = new FileSource("app", locales, "resource://app/localization/{locale}/");
L10nRegistry.registerSource(appSource);
// check if we're in safe mode
if (Services.appinfo.inSafeMode) {
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",

Просмотреть файл

@ -188,6 +188,9 @@
@RESPATH@/components/Push.manifest
@RESPATH@/components/l10n-registry.manifest
@RESPATH@/browser/components/l10n-registry.manifest
; CDP remote agent
#ifdef ENABLE_REMOTE_AGENT
@RESPATH@/chrome/remote@JAREXT@

Просмотреть файл

@ -0,0 +1 @@
category l10n-registry browser resource://app/localization/{locale}/

Просмотреть файл

@ -11,6 +11,10 @@ SPHINX_TREES['browser'] = 'docs'
with Files('docs/**'):
SCHEDULES.exclusive = ['docs']
EXTRA_COMPONENTS += [
'l10n-registry.manifest',
]
DIRS += [
'actors',
'base',

Просмотреть файл

@ -89,7 +89,15 @@ class L10nRegistryService {
constructor() {
this.sources = new Map();
if (!isParentProcess) {
if (isParentProcess) {
const locales = Services.locale.packagedLocales;
for (let {entry, value} of Services.catMan.enumerateCategory("l10n-registry")) {
if (!this.hasSource(entry)) {
const source = new FileSource(entry, locales, value);
this.registerSource(source);
}
}
} else {
this._setSourcesFromSharedData();
Services.cpmm.sharedData.addEventListener("change", this);
}
@ -237,11 +245,14 @@ class L10nRegistryService {
});
}
Services.ppmm.sharedData.set("L10nRegistry:Sources", sources);
Services.ppmm.sharedData.flush();
}
_setSourcesFromSharedData() {
let sources = Services.cpmm.sharedData.get("L10nRegistry:Sources");
if (!sources) {
console.warn(`[l10nregistry] Failed to fetch sources from shared data.`);
return;
}
for (let [name, data] of sources.entries()) {
if (!this.hasSource(name)) {
const source = new FileSource(name, data.locales, data.prePath);

Просмотреть файл

@ -7,7 +7,6 @@
var {AddonManager} = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
var {DelayedInit} = ChromeUtils.import("resource://gre/modules/DelayedInit.jsm");
var {FileSource, L10nRegistry} = ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
var {EventDispatcher} = ChromeUtils.import("resource://gre/modules/Messaging.jsm");
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -405,11 +404,6 @@ var BrowserApp = {
"Telemetry:CustomTabsPing",
]);
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.packagedLocales;
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
// Provide compatibility for add-ons like QuitNow that send "Browser:Quit"
// as an observer notification.
Services.obs.addObserver((subject, topic, data) =>

Просмотреть файл

@ -8,9 +8,7 @@ const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUti
XPCOMUtils.defineLazyModuleGetters(this, {
ActorManagerParent: "resource://gre/modules/ActorManagerParent.jsm",
EventDispatcher: "resource://gre/modules/Messaging.jsm",
FileSource: "resource://gre/modules/L10nRegistry.jsm",
GeckoViewTelemetryController: "resource://gre/modules/GeckoViewTelemetryController.jsm",
L10nRegistry: "resource://gre/modules/L10nRegistry.jsm",
Preferences: "resource://gre/modules/Preferences.jsm",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
Services: "resource://gre/modules/Services.jsm",
@ -137,11 +135,6 @@ GeckoViewStartup.prototype = {
// ContentProcessSingleton.js for consistency with Desktop Telemetry.
GeckoViewTelemetryController.setup();
// Initialize the default l10n resource sources for L10nRegistry.
let locales = Services.locale.packagedLocales;
const greSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
L10nRegistry.registerSource(greSource);
ChromeUtils.import("resource://gre/modules/NotificationDB.jsm");
// Initialize safe browsing module. This is required for content

Просмотреть файл

@ -129,6 +129,7 @@
@BINPATH@/components/HandlerService.js
@BINPATH@/components/servicesComponents.manifest
@BINPATH@/components/servicesSettings.manifest
@BINPATH@/components/l10n-registry.js
#ifndef MOZ_GECKOVIEW_JAR
@BINPATH@/components/TelemetryStartup.manifest

Просмотреть файл

@ -56,6 +56,7 @@ MainProcessSingleton.prototype = {
switch (topic) {
case "app-startup": {
ChromeUtils.import("resource://gre/modules/CustomElementsListener.jsm", null);
ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
Services.obs.addObserver(this, "xpcom-shutdown");
// Load this script early so that console.* is initialized

Просмотреть файл

@ -0,0 +1 @@
category l10n-registry toolkit resource://gre/localization/{locale}/

Просмотреть файл

@ -6,6 +6,10 @@
SPHINX_TREES['/toolkit'] = 'docs'
EXTRA_COMPONENTS += [
'l10n-registry.manifest',
]
DIRS += [
'actors',
'components',