[tor-commits] [tor-browser/tor-browser-60.7.0esr-9.0-2] Bug 1560192 - Clean up prompt open calls in Prompter.jsm. r=Gijs, a=pascalc

gk at torproject.org gk at torproject.org
Thu Jun 20 13:57:29 UTC 2019


commit df852fdc7f75aa7edddbaf1b54eea3484a552414
Author: Johann Hofmann <jhofmann at mozilla.com>
Date:   Wed Jun 19 21:59:18 2019 +0000

    Bug 1560192 - Clean up prompt open calls in Prompter.jsm. r=Gijs, a=pascalc
    
    Differential Revision: https://phabricator.services.mozilla.com/D35371
    
    --HG--
    extra : source : bfd88bfc61c42a09475da8749b2218f540e4592c
---
 browser/modules/RemotePrompt.jsm             | 14 +++++++++-----
 toolkit/components/prompts/src/nsPrompter.js | 18 +++++++++---------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/browser/modules/RemotePrompt.jsm b/browser/modules/RemotePrompt.jsm
index 45755c2446fc..f94052410d5c 100644
--- a/browser/modules/RemotePrompt.jsm
+++ b/browser/modules/RemotePrompt.jsm
@@ -23,10 +23,14 @@ var RemotePrompt = {
   receiveMessage(message) {
     switch (message.name) {
       case "Prompt:Open":
-        if (message.data.uri) {
-          this.openModalWindow(message.data, message.target);
-        } else {
+        const COMMON_DIALOG = "chrome://global/content/commonDialog.xul";
+        const SELECT_DIALOG = "chrome://global/content/selectDialog.xul";
+
+        if (message.data.tabPrompt) {
           this.openTabPrompt(message.data, message.target);
+        } else {
+          let uri = (message.data.promptType == "select") ? SELECT_DIALOG : COMMON_DIALOG;
+          this.openModalWindow(uri, message.data, message.target);
         }
         break;
     }
@@ -90,13 +94,13 @@ var RemotePrompt = {
     }
   },
 
-  openModalWindow(args, browser) {
+  openModalWindow(uri, args, browser) {
     let window = browser.ownerGlobal;
     try {
       PromptUtils.fireDialogEvent(window, "DOMWillOpenModalDialog", browser);
       let bag = PromptUtils.objectToPropBag(args);
 
-      Services.ww.openWindow(window, args.uri, "_blank",
+      Services.ww.openWindow(window, uri, "_blank",
                              "centerscreen,chrome,modal,titlebar", bag);
 
       PromptUtils.propBagToObject(bag, args);
diff --git a/toolkit/components/prompts/src/nsPrompter.js b/toolkit/components/prompts/src/nsPrompter.js
index bf76cd8b2078..77a65b25b100 100644
--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -430,7 +430,7 @@ function openTabPrompt(domWin, tabPrompt, args) {
     }
 }
 
-function openRemotePrompt(domWin, args, tabPrompt) {
+function openRemotePrompt(domWin, args) {
     let docShell = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIDocShell);
     let messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
@@ -438,7 +438,7 @@ function openRemotePrompt(domWin, args, tabPrompt) {
                                  .messageManager;
 
     let inPermitUnload = docShell.contentViewer && docShell.contentViewer.inPermitUnload;
-    let eventDetail = Cu.cloneInto({tabPrompt, inPermitUnload}, domWin);
+    let eventDetail = Cu.cloneInto({tabPrompt: args.tabPrompt, inPermitUnload}, domWin);
     PromptUtils.fireDialogEvent(domWin, "DOMWillOpenModalDialog", null, eventDetail);
 
     let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
@@ -536,7 +536,8 @@ ModalPrompter.prototype = {
 
         if (allowTabModal && this.domWin) {
             if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
-                openRemotePrompt(this.domWin, args, true);
+                args.tabPrompt = true;
+                openRemotePrompt(this.domWin, args);
                 return;
             }
 
@@ -548,17 +549,16 @@ ModalPrompter.prototype = {
         }
 
         // If we can't do a tab modal prompt, fallback to using a window-modal dialog.
-        const COMMON_DIALOG = "chrome://global/content/commonDialog.xul";
-        const SELECT_DIALOG = "chrome://global/content/selectDialog.xul";
-
-        let uri = (args.promptType == "select") ? SELECT_DIALOG : COMMON_DIALOG;
-
         if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_CONTENT) {
-            args.uri = uri;
+            args.tabPrompt = false;
             openRemotePrompt(this.domWin, args);
             return;
         }
 
+        const COMMON_DIALOG = "chrome://global/content/commonDialog.xul";
+        const SELECT_DIALOG = "chrome://global/content/selectDialog.xul";
+
+        let uri = (args.promptType == "select") ? SELECT_DIALOG : COMMON_DIALOG;
         let propBag = PromptUtils.objectToPropBag(args);
         openModalWindow(this.domWin, uri, propBag);
         PromptUtils.propBagToObject(propBag, args);



More information about the tor-commits mailing list