From 1507e819e9442aaae76a988c5a76ec92c2a76be5 Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Fri, 2 Jun 2017 16:16:11 -0400 Subject: [PATCH] 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 | 5 +++-- mobile/android/chrome/content/browser.js | 4 ++++ mobile/android/components/ColorPicker.js | 11 +++++++---- mobile/android/components/FilePicker.js | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/mobile/android/chrome/content/CastingApps.js b/mobile/android/chrome/content/CastingApps.js index a0abeb657032..d18e5955a4a9 100644 --- a/mobile/android/chrome/content/CastingApps.js +++ b/mobile/android/chrome/content/CastingApps.js @@ -572,7 +572,7 @@ var CastingApps = { } }, - prompt: function(aCallback, aFilterFunc) { + prompt: function(aWindow, aCallback, aFilterFunc) { let items = []; let filteredServices = []; SimpleServiceDiscovery.services.forEach(function(aService) { @@ -591,6 +591,7 @@ var CastingApps = { } let prompt = new Prompt({ + window: aWindow, title: Strings.browser.GetStringFromName("casting.sendToDevice") }).setSingleChoiceItems(items).show(function(data) { let selected = data.button; @@ -620,7 +621,7 @@ var CastingApps = { 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; diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 69e6c645f7a0..efb2f43bac4f 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -5374,6 +5374,7 @@ var XPInstallObserver = { } new Prompt({ + window: window, title: Strings.browser.GetStringFromName("addonError.titleError"), message: message, buttons: buttons @@ -5408,6 +5409,7 @@ var XPInstallObserver = { strings.GetStringFromName("unsignedAddonsDisabled.dismiss") ]; new Prompt({ + window: window, title: Strings.browser.GetStringFromName("addonError.titleBlocked"), message: message, buttons: buttons @@ -5424,6 +5426,7 @@ var XPInstallObserver = { return; new Prompt({ + window: window, title: Strings.browser.GetStringFromName("addonError.titleBlocked"), message: strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName], 1), buttons: [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")] @@ -6649,6 +6652,7 @@ var ExternalApps = { 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"), diff --git a/mobile/android/components/ColorPicker.js b/mobile/android/components/ColorPicker.js index 7d478da8035e..d612135148a6 100644 --- a/mobile/android/components/ColorPicker.js +++ b/mobile/android/components/ColorPicker.js @@ -34,11 +34,14 @@ ColorPicker.prototype = { }, 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) diff --git a/mobile/android/components/FilePicker.js b/mobile/android/components/FilePicker.js index 497a342a3f7b..1f115217051d 100644 --- a/mobile/android/components/FilePicker.js +++ b/mobile/android/components/FilePicker.js @@ -212,7 +212,7 @@ FilePicker.prototype = { // 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; }