Bug 1410362 - Merge nsIPromptService and nsIPromptService2. r=enndeakin+6102
authorMark Banner <standard8@mozilla.com>
Tue, 24 Oct 2017 21:40:59 +0100
changeset 439006 e9f42c55152fa4ae146a3aed846e13bab6c38b1e
parent 439005 5d54875788e3ed11ac8f0adb8778afcafd96c126
child 439007 27ac538d3d8b4ddee427179547e7855cb3df9af3
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1410362
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1410362 - Merge nsIPromptService and nsIPromptService2. r=enndeakin+6102 MozReview-Commit-ID: 5gKiuWF4LeA
mobile/android/components/PromptService.js
mobile/android/components/geckoview/GeckoViewPrompt.js
toolkit/components/browser/nsEmbedCID.h
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
toolkit/components/prompts/src/nsPrompter.js
toolkit/components/prompts/test/test_modal_prompts.html
toolkit/components/prompts/test/test_modal_select.html
toolkit/components/windowcreator/tests/unit/test_wwauthpromptfactory.js
toolkit/components/windowcreator/tests/unit/test_wwpromptfactory.js
toolkit/components/windowwatcher/moz.build
toolkit/components/windowwatcher/nsIPromptService.idl
toolkit/components/windowwatcher/nsIPromptService2.idl
--- a/mobile/android/components/PromptService.js
+++ b/mobile/android/components/PromptService.js
@@ -17,40 +17,40 @@ var gPromptService = null;
 function PromptService() {
   gPromptService = this;
 }
 
 PromptService.prototype = {
   classID: Components.ID("{9a61149b-2276-4a0a-b79c-be994ad106cf}"),
 
   QueryInterface: XPCOMUtils.generateQI([
-      Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
+      Ci.nsIPromptFactory, Ci.nsIPromptService]),
 
   /* ----------  nsIPromptFactory  ---------- */
   // XXX Copied from nsPrompter.js.
   getPrompt: function getPrompt(domWin, iid) {
     // This is still kind of dumb; the C++ code delegated to login manager
-    // here, which in turn calls back into us via nsIPromptService2.
+    // here, which in turn calls back into us via nsIPromptService.
     if (iid.equals(Ci.nsIAuthPrompt2) || iid.equals(Ci.nsIAuthPrompt)) {
       try {
         let pwmgr = Cc["@mozilla.org/passwordmanager/authpromptfactory;1"].getService(Ci.nsIPromptFactory);
         return pwmgr.getPrompt(domWin, iid);
       } catch (e) {
         Cu.reportError("nsPrompter: Delegation to password manager failed: " + e);
       }
     }
 
     let p = new InternalPrompt(domWin);
     p.QueryInterface(iid);
     return p;
   },
 
   /* ----------  private memebers  ---------- */
 
-  // nsIPromptService and nsIPromptService2 methods proxy to our Prompt class
+  // nsIPromptService methods proxy to our Prompt class
   callProxy: function(aMethod, aArguments) {
     let prompt;
     let domWin = aArguments[0];
     prompt = new InternalPrompt(domWin);
     return prompt[aMethod].apply(prompt, Array.prototype.slice.call(aArguments, 1));
   },
 
   /* ----------  nsIPromptService  ---------- */
@@ -78,17 +78,16 @@ PromptService.prototype = {
   },
   promptPassword: function() {
     return this.callProxy("promptPassword", arguments);
   },
   select: function() {
     return this.callProxy("select", arguments);
   },
 
-  /* ----------  nsIPromptService2  ---------- */
   promptAuth: function() {
     return this.callProxy("promptAuth", arguments);
   },
   asyncPromptAuth: function() {
     return this.callProxy("asyncPromptAuth", arguments);
   }
 };
 
--- a/mobile/android/components/geckoview/GeckoViewPrompt.js
+++ b/mobile/android/components/geckoview/GeckoViewPrompt.js
@@ -18,17 +18,17 @@ XPCOMUtils.defineLazyServiceGetter(this,
 function PromptFactory() {
   this.wrappedJSObject = this;
 }
 
 PromptFactory.prototype = {
   classID: Components.ID("{076ac188-23c1-4390-aa08-7ef1f78ca5d9}"),
 
   QueryInterface: XPCOMUtils.generateQI([
-    Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
+    Ci.nsIPromptFactory, Ci.nsIPromptService]),
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "click":
         this._handleClick(aEvent);
         break;
       case "contextmenu":
         this._handleContextMenu(aEvent);
@@ -285,34 +285,34 @@ PromptFactory.prototype = {
         uuid: aMsg.data.uuid,
         result: result,
       });
     });
   },
 
   /* ----------  nsIPromptFactory  ---------- */
   getPrompt: function(aDOMWin, aIID) {
-    // Delegated to login manager here, which in turn calls back into us via nsIPromptService2.
+    // Delegated to login manager here, which in turn calls back into us via nsIPromptService.
     if (aIID.equals(Ci.nsIAuthPrompt2) || aIID.equals(Ci.nsIAuthPrompt)) {
       try {
         let pwmgr = Cc["@mozilla.org/passwordmanager/authpromptfactory;1"].getService(Ci.nsIPromptFactory);
         return pwmgr.getPrompt(aDOMWin, aIID);
       } catch (e) {
         Cu.reportError("Delegation to password manager failed: " + e);
       }
     }
 
     let p = new PromptDelegate(aDOMWin);
     p.QueryInterface(aIID);
     return p;
   },
 
   /* ----------  private memebers  ---------- */
 
-  // nsIPromptService and nsIPromptService2 methods proxy to our Prompt class
+  // nsIPromptService methods proxy to our Prompt class
   callProxy: function(aMethod, aArguments) {
     let prompt = new PromptDelegate(aArguments[0]);
     return prompt[aMethod].apply(prompt, Array.prototype.slice.call(aArguments, 1));
   },
 
   /* ----------  nsIPromptService  ---------- */
 
   alert: function() {
@@ -338,17 +338,16 @@ PromptFactory.prototype = {
   },
   promptPassword: function() {
     return this.callProxy("promptPassword", arguments);
   },
   select: function() {
     return this.callProxy("select", arguments);
   },
 
-  /* ----------  nsIPromptService2  ---------- */
   promptAuth: function() {
     return this.callProxy("promptAuth", arguments);
   },
   asyncPromptAuth: function() {
     return this.callProxy("asyncPromptAuth", arguments);
   }
 };
 
--- a/toolkit/components/browser/nsEmbedCID.h
+++ b/toolkit/components/browser/nsEmbedCID.h
@@ -30,17 +30,16 @@
 /**
  * Prompt Service ContractID
  *   The prompt service (which can be gotten by calling getServiceByContractID
  *   on this ContractID) is the way to pose various prompts, alerts,
  *   and confirmation dialogs to the user.
  *
  * This contract implements the following interfaces:
  * nsIPromptService
- * nsIPromptService2 (optional)
  *
  * Embedders may override this ContractID with their own implementation if they
  * want more control over the way prompts, alerts, and confirmation dialogs are
  * presented to the user.
  */
 #define NS_PROMPTSERVICE_CONTRACTID \
  "@mozilla.org/embedcomp/prompt-service;1"
 
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -259,17 +259,17 @@ LoginManagerPrompter.prototype = {
     return this.__pwmgr;
   },
 
   __promptService: null, // Prompt service for user interaction
   get _promptService() {
     if (!this.__promptService)
       this.__promptService =
           Cc["@mozilla.org/embedcomp/prompt-service;1"].
-          getService(Ci.nsIPromptService2);
+          getService(Ci.nsIPromptService);
     return this.__promptService;
   },
 
 
   __strBundle: null, // String bundle for L10N
   get _strBundle() {
     if (!this.__strBundle) {
       var bunService = Cc["@mozilla.org/intl/stringbundle;1"].
--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -14,32 +14,32 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/SharedPromptUtils.jsm");
 
 function Prompter() {
     // Note that EmbedPrompter clones this implementation.
 }
 
 Prompter.prototype = {
     classID: Components.ID("{1c978d25-b37f-43a8-a2d6-0c7a239ead87}"),
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptFactory, Ci.nsIPromptService, Ci.nsIPromptService2]),
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptFactory, Ci.nsIPromptService]),
 
 
     /* ----------  private members  ---------- */
 
     pickPrompter(domWin) {
         return new ModalPrompter(domWin);
     },
 
 
     /* ----------  nsIPromptFactory  ---------- */
 
 
     getPrompt(domWin, iid) {
         // This is still kind of dumb; the C++ code delegated to login manager
-        // here, which in turn calls back into us via nsIPromptService2.
+        // here, which in turn calls back into us via nsIPromptService.
         if (iid.equals(Ci.nsIAuthPrompt2) || iid.equals(Ci.nsIAuthPrompt)) {
             try {
                 let pwmgr = Cc["@mozilla.org/passwordmanager/authpromptfactory;1"].
                             getService(Ci.nsIPromptFactory);
                 return pwmgr.getPrompt(domWin, iid);
             } catch (e) {
                 Cu.reportError("nsPrompter: Delegation to password manager failed: " + e);
             }
@@ -95,19 +95,16 @@ Prompter.prototype = {
     },
 
     select(domWin, title, text, count, list, selected) {
         let p = this.pickPrompter(domWin);
         return p.select(title, text, count, list, selected);
     },
 
 
-    /* ----------  nsIPromptService2  ---------- */
-
-
     promptAuth(domWin, channel, level, authInfo, checkLabel, checkValue) {
         let p = this.pickPrompter(domWin);
         return p.promptAuth(channel, level, authInfo, checkLabel, checkValue);
     },
 
     asyncPromptAuth(domWin, channel, callback, context, level, authInfo, checkLabel, checkValue) {
         let p = this.pickPrompter(domWin);
         return p.asyncPromptAuth(channel, callback, context, level, authInfo, checkLabel, checkValue);
--- a/toolkit/components/prompts/test/test_modal_prompts.html
+++ b/toolkit/components/prompts/test/test_modal_prompts.html
@@ -21,17 +21,17 @@ Prompter tests: modal prompts
 async function runTests() {
     const { NetUtil } = SpecialPowers.Cu.import("resource://gre/modules/NetUtil.jsm");
     let state, action, promptDone;
     ok(true, "Running tests (isTabModal=" + isTabModal + ", usePromptService=" + usePromptService + ")");
 
     let prompter, promptArgs;
     if (usePromptService) {
         prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].
-                   getService(Ci.nsIPromptService2);
+                   getService(Ci.nsIPromptService);
     } else {
         prompter = Cc["@mozilla.org/prompter;1"].
                    getService(Ci.nsIPromptFactory).
                    getPrompt(window, Ci.nsIPrompt);
         if (isTabModal) {
             let bag = prompter.QueryInterface(Ci.nsIWritablePropertyBag2);
             bag.setPropertyAsBool("allowTabModal", true);
         }
--- a/toolkit/components/prompts/test/test_modal_select.html
+++ b/toolkit/components/prompts/test/test_modal_select.html
@@ -14,17 +14,17 @@ Prompter tests: modal prompts
 <div id="content" style="display: none">
   <iframe id="iframe"></iframe>
 </div>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 /* import-globals-from prompt_common.js */
 let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"].
-               getService(Ci.nsIPromptService2);
+               getService(Ci.nsIPromptService);
 
 function checkPromptState(promptState, expectedState) {
     // XXX check title? OS X has title in content
     // XXX check focused element
     // XXX check button labels?
 
     is(promptState.msg, expectedState.msg, "Checking expected message");
 
--- a/toolkit/components/windowcreator/tests/unit/test_wwauthpromptfactory.js
+++ b/toolkit/components/windowcreator/tests/unit/test_wwauthpromptfactory.js
@@ -45,17 +45,17 @@ var TestPromptFactory = {
  * The tests
  */
 function run_test() {
   Components.manager.nsIComponentRegistrar.registerFactory(tPFCID,
     "TestPromptFactory", tPFContract, TestPromptFactory);
 
   // Make sure that getting both nsIAuthPrompt and nsIAuthPrompt2 works
   // (these should work independently of whether the application has
-  // nsIPromptService2)
+  // nsIPromptService)
   var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService();
 
   authPromptRequestReceived = false;
 
   do_check_neq(ww.nsIPromptFactory.getPrompt(null, Ci.nsIAuthPrompt), null);
 
   do_check_true(authPromptRequestReceived);
 
--- a/toolkit/components/windowcreator/tests/unit/test_wwpromptfactory.js
+++ b/toolkit/components/windowcreator/tests/unit/test_wwpromptfactory.js
@@ -1,12 +1,12 @@
 function run_test() {
   // Make sure that getting both nsIAuthPrompt and nsIAuthPrompt2 works
   // (these should work independently of whether the application has
-  // nsIPromptService2)
+  // nsIPromptService)
   var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
                      .getService();
 
   var prompt;
 
   prompt = ww.nsIWindowWatcher.getNewPrompter(null);
   do_check_neq(prompt, null);
   prompt = ww.nsIWindowWatcher.getNewAuthPrompter(null);
--- a/toolkit/components/windowwatcher/moz.build
+++ b/toolkit/components/windowwatcher/moz.build
@@ -8,17 +8,16 @@ with Files('**'):
     BUG_COMPONENT = ('Core', 'Window Management')
 
 TEST_DIRS += ['test']
 
 XPIDL_SOURCES += [
     'nsIDialogParamBlock.idl',
     'nsIPromptFactory.idl',
     'nsIPromptService.idl',
-    'nsIPromptService2.idl',
     'nsIWindowWatcher.idl',
     'nsPIPromptService.idl',
     'nsPIWindowWatcher.idl',
 ]
 
 XPIDL_MODULE = 'windowwatcher'
 
 EXPORTS += [
--- a/toolkit/components/windowwatcher/nsIPromptService.idl
+++ b/toolkit/components/windowwatcher/nsIPromptService.idl
@@ -1,16 +1,20 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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/. */
 
 #include "nsISupports.idl"
 
 interface mozIDOMWindowProxy;
+interface nsIAuthPromptCallback;
+interface nsIAuthInformation;
+interface nsICancelable;
+interface nsIChannel;
 
 /**
  * This is the interface to the embeddable prompt service; the service that
  * implements nsIPrompt.  Its interface is designed to be just nsIPrompt, each
  * method modified to take a parent window parameter.
  *
  * Accesskeys can be attached to buttons and checkboxes by inserting an &
  * before the accesskey character in the checkbox message or button title.  For
@@ -116,36 +120,36 @@ interface nsIPromptService : nsISupports
 
   /**
    * Button Flags
    *
    * The following flags are combined to form the aButtonFlags parameter passed
    * to confirmEx.  See confirmEx for more information on how the flags may be
    * combined.
    */
-   
+
   /**
    * Button Position Flags
    */
   const unsigned long BUTTON_POS_0              = 1;
   const unsigned long BUTTON_POS_1              = 1 << 8;
   const unsigned long BUTTON_POS_2              = 1 << 16;
-     
+
   /**
    * Button Title Flags (used to set the labels of buttons in the prompt)
    */
   const unsigned long BUTTON_TITLE_OK            = 1;
   const unsigned long BUTTON_TITLE_CANCEL        = 2;
   const unsigned long BUTTON_TITLE_YES           = 3;
   const unsigned long BUTTON_TITLE_NO            = 4;
   const unsigned long BUTTON_TITLE_SAVE          = 5;
   const unsigned long BUTTON_TITLE_DONT_SAVE     = 6;
   const unsigned long BUTTON_TITLE_REVERT        = 7;
   const unsigned long BUTTON_TITLE_IS_STRING     = 127;
-  
+
   /**
    * Button Default Flags (used to select which button is the default one)
    */
   const unsigned long BUTTON_POS_0_DEFAULT       = 0;
   const unsigned long BUTTON_POS_1_DEFAULT       = 1 << 24;
   const unsigned long BUTTON_POS_2_DEFAULT       = 1 << 25;
 
   /**
@@ -184,17 +188,17 @@ interface nsIPromptService : nsISupports
    * @param aButton0Title
    *        Used when button 0 uses TITLE_IS_STRING
    * @param aButton1Title
    *        Used when button 1 uses TITLE_IS_STRING
    * @param aButton2Title
    *        Used when button 2 uses TITLE_IS_STRING
    * @param aCheckMsg
    *        Text to appear with the checkbox.  Null if no checkbox.
-   * @param aCheckState    
+   * @param aCheckState
    *        Contains the initial checked state of the checkbox when this method
    *        is called and the final checked state after this method returns.
    *
    * @return index of the button pressed.
    *
    * Buttons are numbered 0 - 2. The implementation can decide whether the
    * sequence goes from right to left or left to right.  Button 0 is the
    * default button unless one of the Button Default Flags is specified.
@@ -239,21 +243,21 @@ interface nsIPromptService : nsISupports
    *        Otherwise, the parameter's value is unmodified.
    * @param aCheckMsg
    *        Text to appear with the checkbox.  If null, check box will not be shown.
    * @param aCheckState
    *        Contains the initial checked state of the checkbox when this method
    *        is called and the final checked state after this method returns.
    *
    * @return true for OK, false for Cancel.
-   */                        
+   */
   boolean prompt(in mozIDOMWindowProxy aParent,
                  in wstring aDialogTitle,
                  in wstring aText,
-                 inout wstring aValue, 
+                 inout wstring aValue,
                  in wstring aCheckMsg,
                  inout boolean aCheckState);
 
   /**
    * Puts up a dialog with an edit field, a password field, and an optional,
    * labeled checkbox.
    *
    * @param aParent
@@ -274,17 +278,17 @@ interface nsIPromptService : nsISupports
    *        Otherwise, the parameter's value is unmodified.
    * @param aCheckMsg
    *        Text to appear with the checkbox.  If null, check box will not be shown.
    * @param aCheckState
    *        Contains the initial checked state of the checkbox when this method
    *        is called and the final checked state after this method returns.
    *
    * @return true for OK, false for Cancel.
-   */                        
+   */
   boolean promptUsernameAndPassword(in mozIDOMWindowProxy aParent,
                                     in wstring aDialogTitle,
                                     in wstring aText,
                                     inout wstring aUsername,
                                     inout wstring aPassword,
                                     in wstring aCheckMsg,
                                     inout boolean aCheckState);
 
@@ -304,17 +308,17 @@ interface nsIPromptService : nsISupports
    *        Otherwise, the parameter's value is unmodified.
    * @param aCheckMsg
    *        Text to appear with the checkbox.  If null, check box will not be shown.
    * @param aCheckState
    *        Contains the initial checked state of the checkbox when this method
    *        is called and the final checked state after this method returns.
    *
    * @return true for OK, false for Cancel.
-   */                        
+   */
   boolean promptPassword(in mozIDOMWindowProxy aParent,
                          in wstring aDialogTitle,
                          in wstring aText,
                          inout wstring aPassword,
                          in wstring aCheckMsg,
                          inout boolean aCheckState);
 
   /**
@@ -331,16 +335,40 @@ interface nsIPromptService : nsISupports
    *        The length of the aSelectList array parameter.
    * @param aSelectList
    *        The list of strings to display.
    * @param aOutSelection
    *        Contains the index of the selected item in the list when this
    *        method returns true.
    *
    * @return true for OK, false for Cancel.
-   */                                                 
+   */
   boolean select(in mozIDOMWindowProxy aParent,
                  in wstring aDialogTitle,
                  in wstring aText,
                  in  uint32_t aCount,
                  [array, size_is(aCount)] in wstring aSelectList,
                  out long aOutSelection);
+
+  // NOTE: These functions differ from their nsIAuthPrompt counterparts by
+  // having additional checkbox parameters
+  // checkValue can be null meaning to show no checkbox
+  // checkboxLabel is a wstring so that it can be null from both JS and C++ in
+  // a convenient way
+  //
+  // See nsIAuthPrompt2 for documentation on the semantics of the other
+  // parameters.
+  boolean promptAuth(in mozIDOMWindowProxy aParent,
+                     in nsIChannel aChannel,
+                     in uint32_t level,
+                     in nsIAuthInformation authInfo,
+                     in wstring checkboxLabel,
+                     inout boolean checkValue);
+
+  nsICancelable asyncPromptAuth(in mozIDOMWindowProxy aParent,
+                                in nsIChannel aChannel,
+                                in nsIAuthPromptCallback aCallback,
+                                in nsISupports aContext,
+                                in uint32_t level,
+                                in nsIAuthInformation authInfo,
+                                in wstring checkboxLabel,
+                                inout boolean checkValue);
 };
deleted file mode 100644
--- a/toolkit/components/windowwatcher/nsIPromptService2.idl
+++ /dev/null
@@ -1,45 +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/. */
-
-#include "nsIPromptService.idl"
-
-interface nsIAuthInformation;
-interface nsIAuthPromptCallback;
-interface nsICancelable;
-interface nsIChannel;
-interface mozIDOMWindowProxy;
-
-/**
- * This is an improved version of nsIPromptService that is less prescriptive
- * about the resulting user interface.
- *
- * @status INCOMPLETE do not freeze before fixing bug 228207
- */
-[scriptable, uuid(3775ad32-8326-422b-9ff3-87ef1d3f9f0e)]
-interface nsIPromptService2 : nsIPromptService {
-  // NOTE: These functions differ from their nsIAuthPrompt counterparts by
-  // having additional checkbox parameters
-  // checkValue can be null meaning to show no checkbox
-  // checkboxLabel is a wstring so that it can be null from both JS and C++ in
-  // a convenient way
-  //
-  // See nsIAuthPrompt2 for documentation on the semantics of the other
-  // parameters.
-  boolean promptAuth(in mozIDOMWindowProxy aParent,
-                     in nsIChannel aChannel,
-                     in uint32_t level,
-                     in nsIAuthInformation authInfo,
-                     in wstring checkboxLabel,
-                     inout boolean checkValue);
-
-  nsICancelable asyncPromptAuth(in mozIDOMWindowProxy aParent,
-                                in nsIChannel aChannel,
-                                in nsIAuthPromptCallback aCallback,
-                                in nsISupports aContext,
-                                in uint32_t level,
-                                in nsIAuthInformation authInfo,
-                                in wstring checkboxLabel,
-                                inout boolean checkValue);
-};
-