зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1367077 - 2. Move PromptService startup to BrowserCLH; r=snorp
Use the BrowserCLH for PromptService startup, to consolidate startup handling code and also to delay loading PromptService. MozReview-Commit-ID: 25UgVH7wrrs --HG-- extra : rebase_source : 162ee97db80608caf3c5cd93734764bc87b99c6f
This commit is contained in:
Родитель
14e212570a
Коммит
a8bb402821
|
@ -3,6 +3,9 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Prompt",
|
||||
"resource://gre/modules/Prompt.jsm");
|
||||
|
||||
var InputWidgetHelper = {
|
||||
_uiBusy: false,
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Prompt",
|
||||
"resource://gre/modules/Prompt.jsm");
|
||||
|
||||
var SelectHelper = {
|
||||
_uiBusy: false,
|
||||
|
||||
|
|
|
@ -45,11 +45,15 @@ BrowserCLH.prototype = {
|
|||
case "app-startup": {
|
||||
this.setResourceSubstitutions();
|
||||
|
||||
Services.obs.addObserver(this, "chrome-document-global-created");
|
||||
Services.obs.addObserver(this, "content-document-global-created");
|
||||
|
||||
GeckoViewUtils.addLazyGetter(this, "DownloadNotifications", {
|
||||
module: "resource://gre/modules/DownloadNotifications.jsm",
|
||||
observers: ["chrome-document-loaded"],
|
||||
once: true,
|
||||
});
|
||||
|
||||
if (AppConstants.MOZ_WEBRTC) {
|
||||
GeckoViewUtils.addLazyGetter(this, "WebrtcUI", {
|
||||
script: "chrome://browser/content/WebrtcUI.js",
|
||||
|
@ -63,6 +67,31 @@ BrowserCLH.prototype = {
|
|||
],
|
||||
});
|
||||
}
|
||||
|
||||
GeckoViewUtils.addLazyGetter(this, "SelectHelper", {
|
||||
script: "chrome://browser/content/SelectHelper.js",
|
||||
});
|
||||
GeckoViewUtils.addLazyGetter(this, "InputWidgetHelper", {
|
||||
script: "chrome://browser/content/InputWidgetHelper.js",
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "chrome-document-global-created":
|
||||
case "content-document-global-created": {
|
||||
let win = GeckoViewUtils.getChromeWindow(subject);
|
||||
if (win !== subject) {
|
||||
// Only attach to top-level windows.
|
||||
return;
|
||||
}
|
||||
|
||||
GeckoViewUtils.addLazyEventListener(win, "click", {
|
||||
handler: _ => [this.SelectHelper, this.InputWidgetHelper],
|
||||
options: {
|
||||
capture: true,
|
||||
mozSystemGroup: true,
|
||||
},
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ contract @mozilla.org/prompter;1 {9a61149b-2276-4a0a-b79c-be994ad106cf}
|
|||
contract @mozilla.org/embedcomp/prompt-service;1 {9a61149b-2276-4a0a-b79c-be994ad106cf}
|
||||
component {80dae1e9-e0d2-4974-915f-f97050fa8068} PromptService.js
|
||||
contract @mozilla.org/network/authprompt-adapter-factory;1 {80dae1e9-e0d2-4974-915f-f97050fa8068}
|
||||
category app-startup PromptService service,@mozilla.org/prompter;1
|
||||
|
||||
# PresentationDevicePrompt.js
|
||||
component {388bd149-c919-4a43-b646-d7ec57877689} PresentationDevicePrompt.js
|
||||
|
|
|
@ -22,46 +22,7 @@ PromptService.prototype = {
|
|||
classID: Components.ID("{9a61149b-2276-4a0a-b79c-be994ad106cf}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIObserver, Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
|
||||
|
||||
loadSubscript: function(aName, aScript) {
|
||||
let sandbox = {};
|
||||
Services.scriptloader.loadSubScript(aScript, sandbox);
|
||||
return sandbox[aName];
|
||||
},
|
||||
|
||||
/* ---------- nsIObserver ---------- */
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "app-startup": {
|
||||
Services.obs.addObserver(this, "chrome-document-global-created");
|
||||
Services.obs.addObserver(this, "content-document-global-created");
|
||||
break;
|
||||
}
|
||||
case "chrome-document-global-created":
|
||||
case "content-document-global-created": {
|
||||
let win = aSubject.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDocShell).QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindow);
|
||||
if (win !== aSubject) {
|
||||
// Only attach to top-level windows.
|
||||
return;
|
||||
}
|
||||
if (!this.selectHelper) {
|
||||
this.selectHelper = this.loadSubscript(
|
||||
"SelectHelper", "chrome://browser/content/SelectHelper.js");
|
||||
}
|
||||
if (!this.inputWidgetHelper) {
|
||||
this.inputWidgetHelper = this.loadSubscript(
|
||||
"InputWidgetHelper", "chrome://browser/content/InputWidgetHelper.js");
|
||||
}
|
||||
win.addEventListener("click", this.selectHelper, /* capture */ true);
|
||||
win.addEventListener("click", this.inputWidgetHelper, /* capture */ true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
|
||||
|
||||
/* ---------- nsIPromptFactory ---------- */
|
||||
// XXX Copied from nsPrompter.js.
|
||||
|
|
Загрузка…
Ссылка в новой задаче