Bug 1367081 - 3. Include window when using Prompt.jsm; r=droeh
☠☠ backed out by dfd55929e842 ☠ ☠
authorJim Chen <nchen@mozilla.com>
Fri, 02 Jun 2017 16:16:11 -0400
changeset 412637 6065144fe5b32eab26374fd7ad67930d0c6d9403
parent 412636 49051e18e2760f6a34658b178f52f63fb0e8396e
child 412638 949bae6eaa96e9590aa7b1eba2c36398d3caece3
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh
bugs1367081
milestone55.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 1367081 - 3. Include window when using Prompt.jsm; r=droeh Include the window when using Prompt.jsm in JS so that the prompts can be directed to the correct Activity. MozReview-Commit-ID: CrPqf9gnDho
mobile/android/chrome/content/CastingApps.js
mobile/android/chrome/content/browser.js
mobile/android/components/ColorPicker.js
mobile/android/components/FilePicker.js
--- a/mobile/android/chrome/content/CastingApps.js
+++ b/mobile/android/chrome/content/CastingApps.js
@@ -567,17 +567,17 @@ var CastingApps = {
         title: Strings.browser.GetStringFromName("contextmenu.sendToDevice"),
         icon: "drawable://casting",
         clickCallback: this.pageAction.click,
         important: true
       });
     }
   },
 
-  prompt: function(aCallback, aFilterFunc) {
+  prompt: function(aWindow, aCallback, aFilterFunc) {
     let items = [];
     let filteredServices = [];
     SimpleServiceDiscovery.services.forEach(function(aService) {
       let item = {
         label: aService.friendlyName,
         selected: false
       };
       if (!aFilterFunc || aFilterFunc(aService)) {
@@ -586,16 +586,17 @@ var CastingApps = {
       }
     });
 
     if (items.length == 0) {
       return;
     }
 
     let prompt = new Prompt({
+      window: aWindow,
       title: Strings.browser.GetStringFromName("casting.sendToDevice")
     }).setSingleChoiceItems(items).show(function(data) {
       let selected = data.button;
       let service = selected == -1 ? null : filteredServices[selected];
       if (aCallback)
         aCallback(service);
     });
   },
@@ -615,17 +616,17 @@ var CastingApps = {
     if (!aVideo) {
       return;
     }
 
     function filterFunc(aService) {
       return this.allowableExtension(aVideo.sourceURI, aService.extensions) || this.allowableMimeType(aVideo.type, aService.types);
     }
 
-    this.prompt(aService => {
+    this.prompt(aVideo.element.ownerGlobal, aService => {
       if (!aService)
         return;
 
       // Make sure we have a player app for the given service
       let app = SimpleServiceDiscovery.findAppForService(aService);
       if (!app)
         return;
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -5369,16 +5369,17 @@ var XPInstallObserver = {
           callback: (data) => {
             if (data.button === 1) {
               Services.prefs.setBoolPref("xpinstall.enabled", true)
             }
           };
         }
 
         new Prompt({
+          window: window,
           title: Strings.browser.GetStringFromName("addonError.titleError"),
           message: message,
           buttons: buttons
         }).show(callback);
         break;
       }
       case "addon-install-blocked": {
         if (!tab)
@@ -5403,32 +5404,34 @@ var XPInstallObserver = {
           }
         }
 
         let buttons = [
             strings.GetStringFromName("xpinstallPromptAllowButton"),
             strings.GetStringFromName("unsignedAddonsDisabled.dismiss")
         ];
         new Prompt({
+          window: window,
           title: Strings.browser.GetStringFromName("addonError.titleBlocked"),
           message: message,
           buttons: buttons
         }).show((data) => {
           if (data.button === 0) {
             // Kick off the install
             installInfo.install();
           }
         });
         break;
       }
       case "addon-install-origin-blocked": {
         if (!tab)
           return;
 
         new Prompt({
+          window: window,
           title: Strings.browser.GetStringFromName("addonError.titleBlocked"),
           message: strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName], 1),
           buttons: [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")]
         }).show((data) => {});
         break;
       }
       case "xpi-signature-changed": {
         if (JSON.parse(aData).disabled.length) {
@@ -6644,16 +6647,17 @@ var ExternalApps = {
         let wasPlaying = mediaElement && !mediaElement.paused && !mediaElement.ended;
         if (wasPlaying) {
           mediaElement.pause();
         }
 
         if (apps.length > 1) {
           // Use the HelperApps prompt here to filter out any Http handlers
           HelperApps.prompt(apps, {
+            window: window,
             title: Strings.browser.GetStringFromName("openInApp.pageAction"),
             buttons: [
               Strings.browser.GetStringFromName("openInApp.ok"),
               Strings.browser.GetStringFromName("openInApp.cancel")
             ]
           }, (result) => {
             if (result.button != 0) {
               if (wasPlaying) {
--- a/mobile/android/components/ColorPicker.js
+++ b/mobile/android/components/ColorPicker.js
@@ -29,21 +29,24 @@ ColorPicker.prototype = {
 
   init: function(aParent, aTitle, aInitial) {
     this._domWin = aParent;
     this._initial = aInitial;
     this._title = aTitle;
   },
 
   open: function(aCallback) {
-    let p = new Prompt({ title: this._title,
+    let p = new Prompt({
+                         window: this._domWin,
+                         title: this._title,
                          buttons: [
-                            this.strings.GetStringFromName("inputWidgetHelper.set"),
-                            this.strings.GetStringFromName("inputWidgetHelper.cancel")
-                         ] })
+                           this.strings.GetStringFromName("inputWidgetHelper.set"),
+                           this.strings.GetStringFromName("inputWidgetHelper.cancel"),
+                         ],
+                       })
                       .addColorPicker({ value: this._initial })
                       .show((data) => {
       if (data.button == 0)
         aCallback.done(data.color0);
       else
         aCallback.done(this._initial);
     });
   },
--- a/mobile/android/components/FilePicker.js
+++ b/mobile/android/components/FilePicker.js
@@ -207,17 +207,17 @@ FilePicker.prototype = {
       guid: this.guid,
       title: this._title,
     };
 
     // Knowing the window lets us destroy any temp files when the tab is closed
     // Other consumers of the file picker may have to either wait for Android
     // to clean up the temp dir (not guaranteed) or clean up after themselves.
     let win = Services.wm.getMostRecentWindow('navigator:browser');
-    let tab = win.BrowserApp.getTabForWindow(this._domWin.top)
+    let tab = win && win.BrowserApp.getTabForWindow(this._domWin.top)
     if (tab) {
       msg.tabId = tab.id;
     }
 
     if (!this._extensionsFilter && !this._mimeTypeFilter) {
       // If neither filters is set show anything we can.
       msg.mode = "mimeType";
       msg.mimeType = "*/*";