зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1470023: Lazily load PluginContent.jsm when it's first required. r=felipe
MozReview-Commit-ID: 2n9NP5mEEcG --HG-- extra : rebase_source : 4357e78d02e7c3f6af6cfea1e0681e50476bddcb extra : source : 064e448df638efc4a99fdf9f400d1eac2b7505ca
This commit is contained in:
Родитель
8bc0bcda97
Коммит
d9da2cdb02
|
@ -317,8 +317,70 @@ ClickEventHandler.init();
|
|||
ContentLinkHandler.init(this);
|
||||
ContentMetaHandler.init(this);
|
||||
|
||||
// TODO: Load this lazily so the JSM is run only if a relevant event/message fires.
|
||||
void new PluginContent(global);
|
||||
var PluginContentStub = {
|
||||
EVENTS: [
|
||||
"PluginCrashed",
|
||||
"PluginOutdated",
|
||||
"PluginInstantiated",
|
||||
"PluginRemoved",
|
||||
"HiddenPlugin",
|
||||
],
|
||||
|
||||
MESSAGES: [
|
||||
"BrowserPlugins:ActivatePlugins",
|
||||
"BrowserPlugins:NotificationShown",
|
||||
"BrowserPlugins:ContextMenuCommand",
|
||||
"BrowserPlugins:NPAPIPluginProcessCrashed",
|
||||
"BrowserPlugins:CrashReportSubmitted",
|
||||
"BrowserPlugins:Test:ClearCrashData",
|
||||
],
|
||||
|
||||
_pluginContent: null,
|
||||
get pluginContent() {
|
||||
if (!this._pluginContent) {
|
||||
this._pluginContent = new PluginContent(global);
|
||||
}
|
||||
return this._pluginContent;
|
||||
},
|
||||
|
||||
init() {
|
||||
addEventListener("unload", this);
|
||||
|
||||
addEventListener("PluginBindingAttached", this, true, true);
|
||||
|
||||
for (let event of this.EVENTS) {
|
||||
addEventListener(event, this, true);
|
||||
}
|
||||
for (let msg of this.MESSAGES) {
|
||||
addMessageListener(msg, this);
|
||||
}
|
||||
Services.obs.addObserver(this, "decoder-doctor-notification");
|
||||
},
|
||||
|
||||
uninit() {
|
||||
Services.obs.removeObserver(this, "decoder-doctor-notification");
|
||||
},
|
||||
|
||||
observe(subject, topic, data) {
|
||||
return this.pluginContent.observe(subject, topic, data);
|
||||
},
|
||||
|
||||
handleEvent(event) {
|
||||
if (event.type === "unload") {
|
||||
return this.uninit();
|
||||
}
|
||||
return this.pluginContent.handleEvent(event);
|
||||
},
|
||||
|
||||
receiveMessage(msg) {
|
||||
return this.pluginContent.receiveMessage(msg);
|
||||
},
|
||||
};
|
||||
|
||||
PluginContentStub.init();
|
||||
|
||||
// This is a temporary hack to prevent regressions.
|
||||
void content;
|
||||
|
||||
addEventListener("DOMWindowFocus", function(event) {
|
||||
sendAsyncMessage("DOMWindowFocus", {});
|
||||
|
|
|
@ -76,7 +76,7 @@ let tabListener = {
|
|||
},
|
||||
|
||||
onLocationChange(browser, webProgress, request, locationURI, flags) {
|
||||
if (webProgress.isTopLevel) {
|
||||
if (webProgress.isTopLevel && locationURI.spec !== "about:blank") {
|
||||
let {gBrowser} = browser.ownerGlobal;
|
||||
let nativeTab = gBrowser.getTabForBrowser(browser);
|
||||
|
||||
|
@ -596,7 +596,9 @@ this.tabs = class extends ExtensionAPI {
|
|||
window.focusAndSelectUrlBar();
|
||||
}
|
||||
|
||||
if (createProperties.url && createProperties.url !== window.BROWSER_NEW_TAB_URL) {
|
||||
if (createProperties.url &&
|
||||
createProperties.url !== "about:blank" &&
|
||||
createProperties.url !== window.BROWSER_NEW_TAB_URL) {
|
||||
// We can't wait for a location change event for about:newtab,
|
||||
// since it may be pre-rendered, in which case its initial
|
||||
// location change event has already fired.
|
||||
|
|
|
@ -42,51 +42,8 @@ PluginContent.prototype = {
|
|||
// Cache of plugin crash information sent from the parent
|
||||
this.pluginCrashData = new Map();
|
||||
|
||||
// Note that the XBL binding is untrusted
|
||||
global.addEventListener("PluginBindingAttached", this, true, true);
|
||||
global.addEventListener("PluginCrashed", this, true);
|
||||
global.addEventListener("PluginOutdated", this, true);
|
||||
global.addEventListener("PluginInstantiated", this, true);
|
||||
global.addEventListener("PluginRemoved", this, true);
|
||||
global.addEventListener("pagehide", this, true);
|
||||
global.addEventListener("pageshow", this, true);
|
||||
global.addEventListener("unload", this);
|
||||
global.addEventListener("HiddenPlugin", this, true);
|
||||
|
||||
global.addMessageListener("BrowserPlugins:ActivatePlugins", this);
|
||||
global.addMessageListener("BrowserPlugins:NotificationShown", this);
|
||||
global.addMessageListener("BrowserPlugins:ContextMenuCommand", this);
|
||||
global.addMessageListener("BrowserPlugins:NPAPIPluginProcessCrashed", this);
|
||||
global.addMessageListener("BrowserPlugins:CrashReportSubmitted", this);
|
||||
global.addMessageListener("BrowserPlugins:Test:ClearCrashData", this);
|
||||
|
||||
Services.obs.addObserver(this, "decoder-doctor-notification");
|
||||
},
|
||||
|
||||
uninit() {
|
||||
let global = this.global;
|
||||
|
||||
global.removeEventListener("PluginBindingAttached", this, true);
|
||||
global.removeEventListener("PluginCrashed", this, true);
|
||||
global.removeEventListener("PluginOutdated", this, true);
|
||||
global.removeEventListener("PluginInstantiated", this, true);
|
||||
global.removeEventListener("PluginRemoved", this, true);
|
||||
global.removeEventListener("pagehide", this, true);
|
||||
global.removeEventListener("pageshow", this, true);
|
||||
global.removeEventListener("unload", this);
|
||||
global.removeEventListener("HiddenPlugin", this, true);
|
||||
|
||||
global.removeMessageListener("BrowserPlugins:ActivatePlugins", this);
|
||||
global.removeMessageListener("BrowserPlugins:NotificationShown", this);
|
||||
global.removeMessageListener("BrowserPlugins:ContextMenuCommand", this);
|
||||
global.removeMessageListener("BrowserPlugins:NPAPIPluginProcessCrashed", this);
|
||||
global.removeMessageListener("BrowserPlugins:CrashReportSubmitted", this);
|
||||
global.removeMessageListener("BrowserPlugins:Test:ClearCrashData", this);
|
||||
|
||||
Services.obs.removeObserver(this, "decoder-doctor-notification");
|
||||
|
||||
delete this.global;
|
||||
delete this.content;
|
||||
},
|
||||
|
||||
receiveMessage(msg) {
|
||||
|
@ -444,11 +401,6 @@ PluginContent.prototype = {
|
|||
handleEvent(event) {
|
||||
let eventType = event.type;
|
||||
|
||||
if (eventType == "unload") {
|
||||
this.uninit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventType == "pagehide") {
|
||||
this.onPageHide(event);
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче