Bug 1450344 - 3. Use EventDispatcher directly for child process prompts; r=esawin

We had some custom messaging code in GeckoViewPrompts for supporting
child processes, but using EventDispatcher directly works just as well.

MozReview-Commit-ID: JRFzp96z11i

--HG--
extra : rebase_source : 29da0c85be0870c35e72ddc1c70e744d24f5ab40
This commit is contained in:
Jim Chen 2018-04-05 18:50:12 -04:00
Родитель b7a05e181a
Коммит 4610d6603e
2 изменённых файлов: 1 добавлений и 49 удалений

Просмотреть файл

@ -22,7 +22,7 @@ PromptFactory.prototype = {
classID: Components.ID("{076ac188-23c1-4390-aa08-7ef1f78ca5d9}"),
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIPromptFactory, Ci.nsIPromptService]),
Ci.nsIDOMEventListener, Ci.nsIPromptFactory, Ci.nsIPromptService]),
handleEvent: function(aEvent) {
switch (aEvent.type) {
@ -273,20 +273,6 @@ PromptFactory.prototype = {
aEvent.preventDefault();
},
receiveMessage: function(aMsg) {
if (aMsg.name !== "GeckoView:Prompt") {
return;
}
let prompt = new PromptDelegate(aMsg.target.contentWindow || aMsg.target.ownerGlobal);
prompt.asyncShowPrompt(aMsg.data, result => {
aMsg.target.messageManager.sendAsyncMessage("GeckoView:PromptClose", {
uuid: aMsg.data.uuid,
result: result,
});
});
},
/* ---------- nsIPromptFactory ---------- */
getPrompt: function(aDOMWin, aIID) {
// Delegated to login manager here, which in turn calls back into us via nsIPromptService.
@ -353,10 +339,6 @@ PromptFactory.prototype = {
function PromptDelegate(aDomWin) {
this._domWin = aDomWin;
if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) {
return;
}
if (aDomWin) {
this._dispatcher = GeckoViewUtils.getDispatcherForWindow(aDomWin);
}
@ -425,29 +407,6 @@ PromptDelegate.prototype = {
},
asyncShowPrompt: function(aMsg, aCallback) {
if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) {
let docShell = this._domWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem;
let messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsITabChild)
.messageManager;
let uuid = UUIDGen.generateUUID().toString();
aMsg.uuid = uuid;
messageManager.addMessageListener("GeckoView:PromptClose", function listener(msg) {
if (msg.data.uuid !== uuid) {
return;
}
messageManager.removeMessageListener(msg.name, listener);
aCallback(msg.data.result);
});
messageManager.sendAsyncMessage("GeckoView:Prompt", aMsg);
return;
}
let handled = false;
let onResponse = response => {
if (handled) {

Просмотреть файл

@ -69,13 +69,6 @@ GeckoViewStartup.prototype = {
"ContentPrefs:RemoveObserverForName",
],
});
GeckoViewUtils.addLazyGetter(this, "GeckoViewPrompt", {
service: "@mozilla.org/prompter;1",
mm: [
"GeckoView:Prompt",
],
});
break;
}
}