зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1479310: Don't load content-UITour.js until needed. r=Mossop
MozReview-Commit-ID: 55EPBxUYv9o --HG-- rename : browser/components/uitour/content-UITour.js => browser/components/uitour/ContentUITour.jsm extra : rebase_source : 79ecc8b8df092dc9c9e837f0b11eede052df42c7
This commit is contained in:
Родитель
e90505ef2c
Коммит
2cb03639b4
|
@ -1320,7 +1320,6 @@ var gBrowserInit = {
|
|||
let mm = window.getGroupMessageManager("browsers");
|
||||
mm.loadFrameScript("chrome://browser/content/tab-content.js", true);
|
||||
mm.loadFrameScript("chrome://browser/content/content.js", true);
|
||||
mm.loadFrameScript("chrome://browser/content/content-UITour.js", true);
|
||||
mm.loadFrameScript("chrome://global/content/content-HybridContentTelemetry.js", true);
|
||||
mm.loadFrameScript("chrome://global/content/manifestMessages.js", true);
|
||||
|
||||
|
|
|
@ -2,14 +2,18 @@
|
|||
* 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/. */
|
||||
|
||||
/* eslint-env mozilla/frame-script */
|
||||
var EXPORTED_SYMBOLS = ["UITourListener"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const PREF_TEST_WHITELIST = "browser.uitour.testingOrigins";
|
||||
const UITOUR_PERMISSION = "uitour";
|
||||
|
||||
var UITourListener = {
|
||||
class UITourListener {
|
||||
constructor(mm) {
|
||||
this.mm = mm;
|
||||
}
|
||||
|
||||
handleEvent(event) {
|
||||
if (!Services.prefs.getBoolPref("browser.uitour.enabled")) {
|
||||
return;
|
||||
|
@ -17,14 +21,14 @@ var UITourListener = {
|
|||
if (!this.ensureTrustedOrigin()) {
|
||||
return;
|
||||
}
|
||||
addMessageListener("UITour:SendPageCallback", this);
|
||||
addMessageListener("UITour:SendPageNotification", this);
|
||||
sendAsyncMessage("UITour:onPageEvent", {
|
||||
this.mm.addMessageListener("UITour:SendPageCallback", this);
|
||||
this.mm.addMessageListener("UITour:SendPageNotification", this);
|
||||
this.mm.sendAsyncMessage("UITour:onPageEvent", {
|
||||
detail: event.detail,
|
||||
type: event.type,
|
||||
pageVisibilityState: content.document.visibilityState,
|
||||
pageVisibilityState: this.mm.content.document.visibilityState,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
isTestingOrigin(aURI) {
|
||||
if (Services.prefs.getPrefType(PREF_TEST_WHITELIST) != Services.prefs.PREF_STRING) {
|
||||
|
@ -43,7 +47,7 @@ var UITourListener = {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
}
|
||||
|
||||
// This function is copied from UITour.jsm.
|
||||
isSafeScheme(aURI) {
|
||||
|
@ -55,9 +59,11 @@ var UITourListener = {
|
|||
return false;
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
ensureTrustedOrigin() {
|
||||
let {content} = this.mm;
|
||||
|
||||
if (content.top != content)
|
||||
return false;
|
||||
|
||||
|
@ -74,7 +80,7 @@ var UITourListener = {
|
|||
return true;
|
||||
|
||||
return this.isTestingOrigin(uri);
|
||||
},
|
||||
}
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
|
@ -85,21 +91,19 @@ var UITourListener = {
|
|||
this.sendPageEvent("Notification", aMessage.data);
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
sendPageEvent(type, detail) {
|
||||
if (!this.ensureTrustedOrigin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let doc = content.document;
|
||||
let win = this.mm.content;
|
||||
let eventName = "mozUITour" + type;
|
||||
let event = new doc.defaultView.CustomEvent(eventName, {
|
||||
let event = new win.CustomEvent(eventName, {
|
||||
bubbles: true,
|
||||
detail: Cu.cloneInto(detail, doc.defaultView)
|
||||
detail: Cu.cloneInto(detail, win),
|
||||
});
|
||||
doc.dispatchEvent(event);
|
||||
win.document.dispatchEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
addEventListener("mozUITour", UITourListener, false, true);
|
||||
}
|
|
@ -1,6 +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/.
|
||||
|
||||
browser.jar:
|
||||
content/browser/content-UITour.js
|
|
@ -3,11 +3,10 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'ContentUITour.jsm',
|
||||
'UITour.jsm',
|
||||
]
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += [
|
||||
'test/browser.ini',
|
||||
]
|
||||
|
|
|
@ -43,6 +43,12 @@ XPCOMUtils.defineLazyProxy(this, "ShieldFrameListener", () => {
|
|||
return new tmp.ShieldFrameListener(global);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyProxy(this, "UITourListener", () => {
|
||||
let tmp = {};
|
||||
ChromeUtils.import("resource:///modules/ContentUITour.jsm", tmp);
|
||||
return new tmp.UITourListener(global);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyProxy(this, "SelectionSourceContent",
|
||||
"resource://gre/modules/SelectionSourceContent.jsm");
|
||||
|
||||
|
@ -542,3 +548,5 @@ let ExtFind = {
|
|||
ExtFind.init();
|
||||
|
||||
addEventListener("ShieldPageEvent", ShieldFrameListener, false, true);
|
||||
|
||||
addEventListener("mozUITour", UITourListener, false, true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче