Bug 724353. r=Mossop
authorFelipe Gomes <felipc@gmail.com>
Tue, 13 Oct 2015 20:33:35 -0300
changeset 267441 a512e6266d05b7f50286e56d1cda74c5f2908107
parent 267440 52917169ff8dc926ba6202b39f99644eceb79959
child 267442 c8e4c24e3f0040cf8a3e513373a88c130e8298b8
push id15657
push userfelipc@gmail.com
push dateTue, 13 Oct 2015 23:34:24 +0000
treeherderfx-team@a512e6266d05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop
bugs724353
milestone44.0a1
Bug 724353. r=Mossop
toolkit/mozapps/handling/content/dialog.js
--- a/toolkit/mozapps/handling/content/dialog.js
+++ b/toolkit/mozapps/handling/content/dialog.js
@@ -26,26 +26,31 @@
  *   This is the nsIURI that we are being brought up for in the first place.
  * window.arguments[9]:
  *   The nsIInterfaceRequestor of the parent window; may be null
  */
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
+var Cu = Components.utils;
+
+Cu.import("resource://gre/modules/SharedPromptUtils.jsm");
+
 
 var dialog = {
   //////////////////////////////////////////////////////////////////////////////
   //// Member Variables
 
   _handlerInfo: null,
   _URI: null,
   _itemChoose: null,
   _okButton: null,
   _windowCtxt: null,
+  _buttonDisabled: true,
   
   //////////////////////////////////////////////////////////////////////////////
   //// Methods
 
  /**
   * This function initializes the content of the dialog.
   */
   initialize: function initialize()
@@ -53,18 +58,16 @@ var dialog = {
     this._handlerInfo = window.arguments[7].QueryInterface(Ci.nsIHandlerInfo);
     this._URI         = window.arguments[8].QueryInterface(Ci.nsIURI);
     this._windowCtxt  = window.arguments[9];
     if (this._windowCtxt)
       this._windowCtxt.QueryInterface(Ci.nsIInterfaceRequestor);
     this._itemChoose  = document.getElementById("item-choose");
     this._okButton    = document.documentElement.getButton("accept");
 
-    this.updateOKButton();
-
     var description = {
       image: document.getElementById("description-image"),
       text:  document.getElementById("description-text")
     };
     var options = document.getElementById("item-action-text");
     var checkbox = {
       desc: document.getElementById("remember"),
       text:  document.getElementById("remember-text")
@@ -80,16 +83,28 @@ var dialog = {
     checkbox.text.textContent    = window.arguments[6];
 
     // Hide stuff that needs to be hidden
     if (!checkbox.desc.label)
       checkbox.desc.hidden = true;
 
     // UI is ready, lets populate our list
     this.populateList();
+
+    this._delayHelper = new EnableDelayHelper({
+      disableDialog: () => {
+        this._buttonDisabled = true;
+        this.updateOKButton();
+      },
+      enableDialog: () => {
+        this._buttonDisabled = false;
+        this.updateOKButton();
+      },
+      focusTarget: window
+    });
   },
 
  /**
   * Populates the list that a user can choose from.
   */
   populateList: function populateList()
   {
     var items = document.getElementById("items");
@@ -217,17 +232,18 @@ var dialog = {
     return true;
   },
 
  /**
   * Determines if the OK button should be disabled or not
   */
   updateOKButton: function updateOKButton()
   {
-    this._okButton.disabled = this._itemChoose.selected;
+    this._okButton.disabled = this._itemChoose.selected ||
+                              this._buttonDisabled;
   },
 
  /**
   * Updates the UI based on the checkbox being checked or not.
   */
   onCheck: function onCheck()
   {
     if (document.getElementById("remember").checked)