зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1310094 - Part 2: Remove UserCustomizations.jsm; r=myk
This commit is contained in:
Родитель
1c4461d57a
Коммит
c1d2c29601
|
@ -229,7 +229,6 @@ DEFAULT_TEST_PREFS = {
|
|||
'browser.newtabpage.introShown': True,
|
||||
# Disable useragent updates.
|
||||
'general.useragent.updates.enabled': False,
|
||||
'dom.apps.customization.enabled': True,
|
||||
'media.eme.enabled': True,
|
||||
'media.eme.apiVisible': True,
|
||||
# Don't forceably kill content processes after a timeout
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
"browser.pagethumbnails.capturing_disabled": true,
|
||||
"browser.download.panel.shown": true,
|
||||
"general.useragent.updates.enabled": false,
|
||||
"dom.apps.customization.enabled": true,
|
||||
"media.eme.enabled": true,
|
||||
"media.eme.apiVisible": true,
|
||||
"dom.ipc.tabs.shutdownTimeoutSecs": 0,
|
||||
|
|
|
@ -938,7 +938,6 @@ pref("browser.autofocus", false);
|
|||
pref("dom.wakelock.enabled", true);
|
||||
|
||||
// Enable webapps add-ons
|
||||
pref("dom.apps.customization.enabled", true);
|
||||
pref("dom.apps.reviewer_paths", "/reviewers/,/extension/reviewers/");
|
||||
|
||||
// New implementation to unify touch-caret and selection-carets.
|
||||
|
|
|
@ -17,9 +17,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "UserCustomizations",
|
||||
"resource://gre/modules/UserCustomizations.jsm");
|
||||
|
||||
const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");
|
||||
|
||||
function AppsService()
|
||||
|
@ -126,16 +123,6 @@ AppsService.prototype = {
|
|||
return null;
|
||||
},
|
||||
|
||||
isExtensionResource: function(aURI) {
|
||||
// This is only expected to be used by NeckoParent, and will not work
|
||||
// properly in child processes.
|
||||
if (Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return UserCustomizations.isFromExtension(aURI);
|
||||
},
|
||||
|
||||
classID : APPS_SERVICE_CID,
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
|
||||
}
|
||||
|
|
|
@ -1,177 +0,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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["UserCustomizations"];
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Extension.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ValueExtractor",
|
||||
"resource://gre/modules/ValueExtractor.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "console",
|
||||
"@mozilla.org/consoleservice;1",
|
||||
"nsIConsoleService");
|
||||
|
||||
function debug(aMsg) {
|
||||
if (!UserCustomizations._debug) {
|
||||
return;
|
||||
}
|
||||
dump("-*-*- UserCustomizations " + aMsg + "\n");
|
||||
}
|
||||
|
||||
function log(aStr) {
|
||||
console.logStringMessage(aStr);
|
||||
}
|
||||
|
||||
this.UserCustomizations = {
|
||||
extensions: new Map(), // id -> extension. Needed to disable extensions.
|
||||
appId: new Set(),
|
||||
|
||||
register: function(aApp) {
|
||||
if (!this._enabled || !aApp.enabled || aApp.role != "addon") {
|
||||
debug("Rejecting registration (global enabled=" + this._enabled +
|
||||
") (app role=" + aApp.role +
|
||||
", enabled=" + aApp.enabled + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
debug("Starting customization registration for " + aApp.manifestURL + "\n");
|
||||
|
||||
let extension = new Extension({
|
||||
id: AppsUtils.computeHash(aApp.manifestURL),
|
||||
resourceURI: Services.io.newURI(aApp.origin + "/", null, null)
|
||||
});
|
||||
|
||||
this.extensions.set(aApp.manifestURL, extension);
|
||||
let uri = Services.io.newURI(aApp.origin, null, null);
|
||||
debug(`Adding ${uri.host} to appId set`);
|
||||
this.appId.add(uri.host);
|
||||
|
||||
extension.startup()
|
||||
.then(() => { })
|
||||
.catch((err) => {
|
||||
debug(`extension.startup failed: ${err}`);
|
||||
this.appId.delete(uri.host);
|
||||
});
|
||||
},
|
||||
|
||||
unregister: function(aApp) {
|
||||
if (!this._enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug("Starting customization unregistration for " + aApp.manifestURL);
|
||||
if (this.extensions.has(aApp.manifestURL)) {
|
||||
this.extensions.get(aApp.manifestURL).shutdown();
|
||||
this.extensions.delete(aApp.manifestURL);
|
||||
let uri = Services.io.newURI(aApp.origin, null, null);
|
||||
this.appId.delete(uri.host);
|
||||
}
|
||||
},
|
||||
|
||||
isFromExtension: function(aURI) {
|
||||
if (!aURI && Services.prefs.getBoolPref("webextensions.tests")) {
|
||||
// That's the case in mochitests because of the packaging setup:
|
||||
// aURI is expected to be the appURI from the jarChannel but there is
|
||||
// no real app associated to mochitest's jar:remoteopenfile:/// uris.
|
||||
return true;
|
||||
}
|
||||
return this.appId.has(aURI.host);
|
||||
},
|
||||
|
||||
// Checks that this is a valid extension manifest.
|
||||
// The format is documented at https://developer.chrome.com/extensions/manifest
|
||||
checkExtensionManifest: function(aManifest) {
|
||||
if (!aManifest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const extractor = new ValueExtractor(console);
|
||||
const manifestVersionSpec = {
|
||||
objectName: "extension manifest",
|
||||
object: aManifest,
|
||||
property: "manifest_version",
|
||||
expectedType: "number",
|
||||
trim: true
|
||||
}
|
||||
|
||||
const nameSpec = {
|
||||
objectName: "extension manifest",
|
||||
object: aManifest,
|
||||
property: "name",
|
||||
expectedType: "string",
|
||||
trim: true
|
||||
}
|
||||
|
||||
const versionSpec = {
|
||||
objectName: "extension manifest",
|
||||
object: aManifest,
|
||||
property: "version",
|
||||
expectedType: "string",
|
||||
trim: true
|
||||
}
|
||||
|
||||
let res =
|
||||
extractor.extractValue(manifestVersionSpec) !== undefined &&
|
||||
extractor.extractValue(nameSpec) !== undefined &&
|
||||
extractor.extractValue(versionSpec) !== undefined;
|
||||
|
||||
return res;
|
||||
},
|
||||
|
||||
// Converts a chrome extension manifest into a webapp manifest.
|
||||
convertManifest: function(aManifest) {
|
||||
if (!aManifest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set the type to privileged to ensure we only allow signed addons.
|
||||
let result = {
|
||||
"type": "privileged",
|
||||
"name": aManifest.name,
|
||||
"role": "addon"
|
||||
}
|
||||
|
||||
if (aManifest.description) {
|
||||
result.description = aManifest.description;
|
||||
}
|
||||
|
||||
if (aManifest.icons) {
|
||||
result.icons = aManifest.icons;
|
||||
}
|
||||
|
||||
if (aManifest.version) {
|
||||
result.version = aManifest.version;
|
||||
}
|
||||
|
||||
// chrome extension manifests have a single 'author' property, that we
|
||||
// map to 'developer.name'.
|
||||
// Note that it has to match the one in the mini-manifest.
|
||||
if (aManifest.author) {
|
||||
result.developer = {
|
||||
name: aManifest.author
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
init: function() {
|
||||
this._enabled = false;
|
||||
try {
|
||||
this._enabled = Services.prefs.getBoolPref("dom.apps.customization.enabled");
|
||||
} catch(e) {}
|
||||
},
|
||||
}
|
||||
|
||||
UserCustomizations.init();
|
|
@ -19,7 +19,6 @@ EXTRA_JS_MODULES += [
|
|||
'AppsServiceChild.jsm',
|
||||
'PermissionsInstaller.jsm',
|
||||
'PermissionsTable.jsm',
|
||||
'UserCustomizations.jsm',
|
||||
]
|
||||
|
||||
EXTRA_PP_JS_MODULES += [
|
||||
|
|
|
@ -82,11 +82,4 @@ interface nsIAppsService : nsISupports
|
|||
* Returns the scope for app to use with service workers.
|
||||
*/
|
||||
DOMString getScopeByLocalId(in unsigned long localId);
|
||||
|
||||
/**
|
||||
* Returns true if this uri is a script or css resource loaded
|
||||
* from an extension.
|
||||
* Available only in the parent process.
|
||||
*/
|
||||
bool isExtensionResource(in nsIURI uri);
|
||||
};
|
||||
|
|
|
@ -105,14 +105,6 @@ var DoPreloadPostfork = function(aCallback) {
|
|||
// the chrome process in its init() function.
|
||||
Cu.import("resource://gre/modules/AppsServiceChild.jsm");
|
||||
|
||||
// Load UserCustomizations.jsm after fork since it sends an async message to
|
||||
// the chrome process in its init() function.
|
||||
try {
|
||||
if (Services.prefs.getBoolPref("dom.apps.customization.enabled")) {
|
||||
Cu.import("resource://gre/modules/UserCustomizations.jsm");
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// Load nsIAppsService after fork since its implementation loads
|
||||
// AppsServiceChild.jsm
|
||||
Cc["@mozilla.org/AppsService;1"].getService(Ci["nsIAppsService"]);
|
||||
|
|
|
@ -289,9 +289,6 @@ user_pref("browser.translation.engine", "bing");
|
|||
// Make sure we don't try to load snippets from the network.
|
||||
user_pref("browser.aboutHomeSnippets.updateUrl", "nonexistent://test");
|
||||
|
||||
// Enable apps customizations
|
||||
user_pref("dom.apps.customization.enabled", true);
|
||||
|
||||
// Don't fetch or send directory tiles data from real servers
|
||||
user_pref("browser.newtabpage.directory.source", 'data:application/json,{"testing":1}');
|
||||
user_pref("browser.newtabpage.directory.ping", "");
|
||||
|
|
Загрузка…
Ссылка в новой задаче