зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1285063 - Part 2 - Switch to using the Category Manager to register scripts/schemas in order to load them in time for Fennec. r=kmag
MozReview-Commit-ID: AviHoenUfwY --HG-- extra : transplant_source : %DEB%ED%86D%ED6%85%D1%5E%9FhS%BAd%40/%D0f%B7
This commit is contained in:
Родитель
f2f3a8da93
Коммит
0aa659b7d2
|
@ -0,0 +1,22 @@
|
|||
# scripts
|
||||
category webextension-scripts bookmarks chrome://browser/content/ext-bookmarks.js
|
||||
category webextension-scripts browserAction chrome://browser/content/ext-browserAction.js
|
||||
category webextension-scripts commands chrome://browser/content/ext-commands.js
|
||||
category webextension-scripts contextMenus chrome://browser/content/ext-contextMenus.js
|
||||
category webextension-scripts desktop-runtime chrome://browser/content/ext-desktop-runtime.js
|
||||
category webextension-scripts history chrome://browser/content/ext-history.js
|
||||
category webextension-scripts pageAction chrome://browser/content/ext-pageAction.js
|
||||
category webextension-scripts tabs chrome://browser/content/ext-tabs.js
|
||||
category webextension-scripts utils chrome://browser/content/ext-utils.js
|
||||
category webextension-scripts windows chrome://browser/content/ext-windows.js
|
||||
|
||||
# schemas
|
||||
category webextension-schemas bookmarks chrome://browser/content/schemas/bookmarks.json
|
||||
category webextension-schemas browser_action chrome://browser/content/schemas/browser_action.json
|
||||
category webextension-schemas commands chrome://browser/content/schemas/commands.json
|
||||
category webextension-schemas context_menus chrome://browser/content/schemas/context_menus.json
|
||||
category webextension-schemas context_menus_internal chrome://browser/content/schemas/context_menus_internal.json
|
||||
category webextension-schemas history chrome://browser/content/schemas/history.json
|
||||
category webextension-schemas page_action chrome://browser/content/schemas/page_action.json
|
||||
category webextension-schemas tabs chrome://browser/content/schemas/tabs.json
|
||||
category webextension-schemas windows chrome://browser/content/schemas/windows.json
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'extensions-browser.manifest',
|
||||
]
|
||||
|
||||
DIRS += ['schemas']
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
|
||||
|
|
|
@ -156,9 +156,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "AddonWatcher",
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
|
||||
"resource://gre/modules/LightweightThemeManager.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement",
|
||||
"resource://gre/modules/ExtensionManagement.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ShellService",
|
||||
"resource:///modules/ShellService.jsm");
|
||||
|
||||
|
@ -558,27 +555,6 @@ BrowserGlue.prototype = {
|
|||
os.addObserver(this, AddonWatcher.TOPIC_SLOW_ADDON_DETECTED, false);
|
||||
}
|
||||
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-bookmarks.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-browserAction.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-commands.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-contextMenus.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-desktop-runtime.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-history.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-pageAction.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-tabs.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-utils.js");
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-windows.js");
|
||||
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/bookmarks.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/browser_action.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/commands.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/context_menus.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/context_menus_internal.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/history.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/page_action.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/tabs.json");
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/windows.json");
|
||||
|
||||
this._flashHangCount = 0;
|
||||
this._firstWindowReady = new Promise(resolve => this._firstWindowLoaded = resolve);
|
||||
},
|
||||
|
|
|
@ -94,9 +94,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "Profiler",
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "SimpleServiceDiscovery",
|
||||
"resource://gre/modules/SimpleServiceDiscovery.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement",
|
||||
"resource://gre/modules/ExtensionManagement.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
||||
"resource://gre/modules/CharsetMenu.jsm");
|
||||
|
||||
|
@ -389,12 +386,6 @@ var BrowserApp = {
|
|||
Services.obs.addObserver(this, "Fonts:Reload", false);
|
||||
Services.obs.addObserver(this, "Vibration:Request", false);
|
||||
|
||||
// Register extension source files.
|
||||
ExtensionManagement.registerScript("chrome://browser/content/ext-pageAction.js");
|
||||
|
||||
// Register extension schemas.
|
||||
ExtensionManagement.registerSchema("chrome://browser/content/schemas/page_action.json");
|
||||
|
||||
Messaging.addListener(this.getHistory.bind(this), "Session:GetHistory");
|
||||
|
||||
function showFullScreenWarning() {
|
||||
|
@ -6784,7 +6775,7 @@ var SearchEngines = {
|
|||
}
|
||||
};
|
||||
|
||||
// Return valid, pre-sorted queryParams.
|
||||
// Return valid, pre-sorted queryParams.
|
||||
return formData.filter(a => a.name && a.value).sort((a, b) => {
|
||||
// nsIBrowserSearchService.hasEngineWithURL() ensures sort, but this helps.
|
||||
if (a.name > b.name) {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# scripts
|
||||
category webextension-scripts pageAction chrome://browser/content/ext-pageAction.js
|
||||
|
||||
# schemas
|
||||
category webextension-schemas page_action chrome://browser/content/schemas/page_action.json
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'extensions-mobile.manifest',
|
||||
]
|
||||
|
||||
DIRS += ['schemas']
|
||||
|
||||
MOCHITEST_CHROME_MANIFESTS += ['test/mochitest/chrome.ini']
|
|
@ -59,38 +59,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
|
|||
|
||||
Cu.import("resource://gre/modules/ExtensionManagement.jsm");
|
||||
|
||||
// Register built-in parts of the API. Other parts may be registered
|
||||
// in browser/, mobile/, or b2g/.
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-alarms.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-backgroundPage.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-cookies.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-downloads.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-notifications.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-i18n.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-idle.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-runtime.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-extension.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-webNavigation.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-webRequest.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-storage.js");
|
||||
ExtensionManagement.registerScript("chrome://extensions/content/ext-test.js");
|
||||
|
||||
const BASE_SCHEMA = "chrome://extensions/content/schemas/manifest.json";
|
||||
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/alarms.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/cookies.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/downloads.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/extension.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/extension_types.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/i18n.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/idle.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/notifications.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/runtime.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/storage.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/test.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/events.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/web_navigation.json");
|
||||
ExtensionManagement.registerSchema("chrome://extensions/content/schemas/web_request.json");
|
||||
const CATEGORY_EXTENSION_SCHEMAS = "webextension-schemas";
|
||||
const CATEGORY_EXTENSION_SCRIPTS = "webextension-scripts";
|
||||
|
||||
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
|
||||
var {
|
||||
|
@ -139,18 +110,20 @@ var Management = {
|
|||
// extended by other schemas, so needs to be loaded first.
|
||||
let promise = Schemas.load(BASE_SCHEMA).then(() => {
|
||||
let promises = [];
|
||||
for (let schema of ExtensionManagement.getSchemas()) {
|
||||
promises.push(Schemas.load(schema));
|
||||
for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCHEMAS)) {
|
||||
promises.push(Schemas.load(value));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
for (let script of ExtensionManagement.getScripts()) {
|
||||
let scope = {extensions: this,
|
||||
global: scriptScope,
|
||||
ExtensionContext: ExtensionContext,
|
||||
GlobalManager: GlobalManager};
|
||||
Services.scriptloader.loadSubScript(script, scope, "UTF-8");
|
||||
for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS)) {
|
||||
let scope = {
|
||||
extensions: this,
|
||||
global: scriptScope,
|
||||
ExtensionContext: ExtensionContext,
|
||||
GlobalManager: GlobalManager,
|
||||
};
|
||||
Services.scriptloader.loadSubScript(value, scope, "UTF-8");
|
||||
|
||||
// Save the scope to avoid it being garbage collected.
|
||||
this.scopes.push(scope);
|
||||
|
|
|
@ -85,32 +85,6 @@ var Frames = {
|
|||
};
|
||||
Frames.init();
|
||||
|
||||
// Manage the collection of ext-*.js scripts that define the extension API.
|
||||
var Scripts = {
|
||||
scripts: new Set(),
|
||||
|
||||
register(script) {
|
||||
this.scripts.add(script);
|
||||
},
|
||||
|
||||
getScripts() {
|
||||
return this.scripts;
|
||||
},
|
||||
};
|
||||
|
||||
// Manage the collection of schemas/*.json schemas that define the extension API.
|
||||
var Schemas = {
|
||||
schemas: new Set(),
|
||||
|
||||
register(schema) {
|
||||
this.schemas.add(schema);
|
||||
},
|
||||
|
||||
getSchemas() {
|
||||
return this.schemas;
|
||||
},
|
||||
};
|
||||
|
||||
// This object manages various platform-level issues related to
|
||||
// moz-extension:// URIs. It lives here so that it can be used in both
|
||||
// the parent and child processes.
|
||||
|
@ -283,12 +257,6 @@ this.ExtensionManagement = {
|
|||
startupExtension: Service.startupExtension.bind(Service),
|
||||
shutdownExtension: Service.shutdownExtension.bind(Service),
|
||||
|
||||
registerScript: Scripts.register.bind(Scripts),
|
||||
getScripts: Scripts.getScripts.bind(Scripts),
|
||||
|
||||
registerSchema: Schemas.register.bind(Schemas),
|
||||
getSchemas: Schemas.getSchemas.bind(Schemas),
|
||||
|
||||
getFrameId: Frames.getId.bind(Frames),
|
||||
getParentFrameId: Frames.getParentId.bind(Frames),
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# scripts
|
||||
category webextension-scripts alarms chrome://extensions/content/ext-alarms.js
|
||||
category webextension-scripts backgroundPage chrome://extensions/content/ext-backgroundPage.js
|
||||
category webextension-scripts cookies chrome://extensions/content/ext-cookies.js
|
||||
category webextension-scripts downloads chrome://extensions/content/ext-downloads.js
|
||||
category webextension-scripts notifications chrome://extensions/content/ext-notifications.js
|
||||
category webextension-scripts i18n chrome://extensions/content/ext-i18n.js
|
||||
category webextension-scripts idle chrome://extensions/content/ext-idle.js
|
||||
category webextension-scripts webRequest chrome://extensions/content/ext-webRequest.js
|
||||
category webextension-scripts webNavigation chrome://extensions/content/ext-webNavigation.js
|
||||
category webextension-scripts runtime chrome://extensions/content/ext-runtime.js
|
||||
category webextension-scripts extension chrome://extensions/content/ext-extension.js
|
||||
category webextension-scripts storage chrome://extensions/content/ext-storage.js
|
||||
category webextension-scripts test chrome://extensions/content/ext-test.js
|
||||
|
||||
# schemas
|
||||
category webextension-schemas alarms chrome://extensions/content/schemas/alarms.json
|
||||
category webextension-schemas cookies chrome://extensions/content/schemas/cookies.json
|
||||
category webextension-schemas downloads chrome://extensions/content/schemas/downloads.json
|
||||
category webextension-schemas events chrome://extensions/content/schemas/events.json
|
||||
category webextension-schemas extension chrome://extensions/content/schemas/extension.json
|
||||
category webextension-schemas extension_types chrome://extensions/content/schemas/extension_types.json
|
||||
category webextension-schemas i18n chrome://extensions/content/schemas/i18n.json
|
||||
category webextension-schemas idle chrome://extensions/content/schemas/idle.json
|
||||
category webextension-schemas manifest chrome://extensions/content/schemas/manifest.json
|
||||
category webextension-schemas native_host_manifest chrome://extensions/content/schemas/native_host_manifest.json
|
||||
category webextension-schemas notifications chrome://extensions/content/schemas/notifications.json
|
||||
category webextension-schemas runtime chrome://extensions/content/schemas/runtime.json
|
||||
category webextension-schemas storage chrome://extensions/content/schemas/storage.json
|
||||
category webextension-schemas test chrome://extensions/content/schemas/test.json
|
||||
category webextension-schemas web_navigation chrome://extensions/content/schemas/web_navigation.json
|
||||
category webextension-schemas web_request chrome://extensions/content/schemas/web_request.json
|
|
@ -15,6 +15,10 @@ EXTRA_JS_MODULES += [
|
|||
'Schemas.jsm',
|
||||
]
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'extensions-toolkit.manifest',
|
||||
]
|
||||
|
||||
DIRS += ['schemas']
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
|
Загрузка…
Ссылка в новой задаче