зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1514724 - register pocket about pages in the browser AboutRedirector to avoid having a process script specifically for this purpose, r=mconley,thecount
Differential Revision: https://phabricator.services.mozilla.com/D14801 --HG-- extra : rebase_source : fd2d6a3badc5894533e5b085abba5911956732b1
This commit is contained in:
Родитель
028d7ef9fa
Коммит
776e84408f
|
@ -83,6 +83,14 @@ static const RedirEntry kRedirMap[] = {
|
|||
{"library", "chrome://browser/content/aboutLibrary.xhtml",
|
||||
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT},
|
||||
{"pocket-saved", "chrome://pocket/content/panels/saved.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
|
||||
{"pocket-signup", "chrome://pocket/content/panels/signup.html",
|
||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
|
||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT},
|
||||
{"preferences",
|
||||
"chrome://browser/content/preferences/in-content/preferences.xul",
|
||||
nsIAboutModule::ALLOW_SCRIPT},
|
||||
|
|
|
@ -113,6 +113,8 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
|||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "restartrequired", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "welcome", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "policies", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-saved", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-signup", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
#if defined(XP_WIN)
|
||||
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
|
||||
#elif defined(XP_MACOSX)
|
||||
|
|
|
@ -1,94 +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 Cm = Components.manager;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
// See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
|
||||
const PREF_LOG_LEVEL = "loop.debug.loglevel";
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
XPCOMUtils.defineLazyGetter(this, "log", () => {
|
||||
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {}).ConsoleAPI;
|
||||
let consoleOptions = {
|
||||
maxLogLevelPref: PREF_LOG_LEVEL,
|
||||
prefix: "Loop",
|
||||
};
|
||||
return new ConsoleAPI(consoleOptions);
|
||||
});
|
||||
|
||||
|
||||
function AboutPage(chromeURL, aboutHost, classID, description, uriFlags) {
|
||||
this.chromeURL = chromeURL;
|
||||
this.aboutHost = aboutHost;
|
||||
this.classID = Components.ID(classID);
|
||||
this.description = description;
|
||||
this.uriFlags = uriFlags;
|
||||
}
|
||||
|
||||
AboutPage.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIAboutModule]),
|
||||
getURIFlags(aURI) { // eslint-disable-line no-unused-vars
|
||||
return this.uriFlags;
|
||||
},
|
||||
|
||||
newChannel(aURI, aLoadInfo) {
|
||||
let newURI = Services.io.newURI(this.chromeURL);
|
||||
let channel = Services.io.newChannelFromURIWithLoadInfo(newURI,
|
||||
aLoadInfo);
|
||||
channel.originalURI = aURI;
|
||||
|
||||
if (this.uriFlags & Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT) {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
|
||||
channel.owner = principal;
|
||||
}
|
||||
return channel;
|
||||
},
|
||||
|
||||
createInstance(outer, iid) {
|
||||
if (outer !== null) {
|
||||
throw Cr.NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
return this.QueryInterface(iid);
|
||||
},
|
||||
|
||||
register() {
|
||||
Cm.QueryInterface(Ci.nsIComponentRegistrar).registerFactory(
|
||||
this.classID, this.description,
|
||||
"@mozilla.org/network/protocol/about;1?what=" + this.aboutHost, this);
|
||||
},
|
||||
|
||||
unregister() {
|
||||
Cm.QueryInterface(Ci.nsIComponentRegistrar).unregisterFactory(
|
||||
this.classID, this);
|
||||
},
|
||||
};
|
||||
|
||||
/* exported AboutPocket */
|
||||
var AboutPocket = {};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(AboutPocket, "aboutSaved", () =>
|
||||
new AboutPage("chrome://pocket/content/panels/saved.html",
|
||||
"pocket-saved",
|
||||
"{3e759f54-37af-7843-9824-f71b5993ceed}",
|
||||
"About Pocket Saved",
|
||||
Ci.nsIAboutModule.ALLOW_SCRIPT |
|
||||
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(AboutPocket, "aboutSignup", () =>
|
||||
new AboutPage("chrome://pocket/content/panels/signup.html",
|
||||
"pocket-signup",
|
||||
"{8548329d-00c4-234e-8f17-75026db3b56e}",
|
||||
"About Pocket Signup",
|
||||
Ci.nsIAboutModule.ALLOW_SCRIPT |
|
||||
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||
Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT)
|
||||
);
|
||||
|
||||
var EXPORTED_SYMBOLS = ["AboutPocket"];
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://services-common/utils.js");
|
||||
ChromeUtils.defineModuleGetter(this, "AboutPocket",
|
||||
"chrome://pocket/content/AboutPocket.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "AddonManagerPrivate",
|
||||
"resource://gre/modules/AddonManager.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "BrowserUtils",
|
||||
|
@ -30,10 +28,6 @@ XPCOMUtils.defineLazyGetter(this, "gPocketStyleURI", function() {
|
|||
|
||||
var EXPORTED_SYMBOLS = ["SaveToPocket"];
|
||||
|
||||
// Due to bug 1051238 frame scripts are cached forever, so we can't update them
|
||||
// as a restartless add-on. The Math.random() is the work around for this.
|
||||
const PROCESS_SCRIPT = "chrome://pocket/content/pocket-content-process.js?" + Math.random();
|
||||
|
||||
const PREF_BRANCH = "extensions.pocket.";
|
||||
const PREFS = {
|
||||
enabled: true, // bug 1229937, figure out ui tour support
|
||||
|
@ -401,7 +395,6 @@ var PocketOverlay = {
|
|||
this._sheetType = styleSheetService.AUTHOR_SHEET;
|
||||
this._cachedSheet = styleSheetService.preloadSheet(gPocketStyleURI,
|
||||
this._sheetType);
|
||||
Services.ppmm.loadProcessScript(PROCESS_SCRIPT, true);
|
||||
Services.obs.addObserver(this, "browser-delayed-startup-finished");
|
||||
PocketReader.startup();
|
||||
PocketPageAction.init();
|
||||
|
@ -411,13 +404,7 @@ var PocketOverlay = {
|
|||
}
|
||||
},
|
||||
shutdown() {
|
||||
Services.ppmm.broadcastAsyncMessage("PocketShuttingDown");
|
||||
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
|
||||
// Although the ppmm loads the scripts into the chrome process as well,
|
||||
// we need to manually unregister here anyway to ensure these aren't part
|
||||
// of the chrome process and avoid errors.
|
||||
AboutPocket.aboutSaved.unregister();
|
||||
AboutPocket.aboutSignup.unregister();
|
||||
|
||||
PocketPageAction.shutdown();
|
||||
|
||||
|
|
|
@ -1,51 +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";
|
||||
|
||||
// This file is loaded as a process script, it will be loaded in the parent
|
||||
// process as well as all content processes.
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("chrome://pocket/content/AboutPocket.jsm");
|
||||
|
||||
function AboutPocketChildListener() {
|
||||
}
|
||||
AboutPocketChildListener.prototype = {
|
||||
onStartup: function onStartup() {
|
||||
|
||||
// Only do this in content processes since, as the broadcaster of this
|
||||
// message, the parent process doesn't also receive it. We handlers
|
||||
// the shutting down separately.
|
||||
if (Services.appinfo.processType ==
|
||||
Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
|
||||
Services.cpmm.addMessageListener("PocketShuttingDown", this, true);
|
||||
}
|
||||
|
||||
AboutPocket.aboutSaved.register();
|
||||
AboutPocket.aboutSignup.register();
|
||||
},
|
||||
|
||||
onShutdown: function onShutdown() {
|
||||
AboutPocket.aboutSignup.unregister();
|
||||
AboutPocket.aboutSaved.unregister();
|
||||
|
||||
Services.cpmm.removeMessageListener("PocketShuttingDown", this);
|
||||
Cu.unload("chrome://pocket/content/AboutPocket.jsm");
|
||||
},
|
||||
|
||||
receiveMessage: function receiveMessage(message) {
|
||||
switch (message.name) {
|
||||
case "PocketShuttingDown":
|
||||
this.onShutdown();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const listener = new AboutPocketChildListener();
|
||||
listener.onStartup();
|
Загрузка…
Ссылка в новой задаче