Bug 1353857 - Include the tab ID when notifying about leaving/entering a web app's scope. r?daleharvey,walkingice
We only want to process the AppEntered/Left message if it actually concerns our currently displayed tab.
MozReview-Commit-ID: EJ8RzRzDNAz
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ -106,16 +106,21 @@ public class WebAppActivity extends Sing
@Override
public int getLayout() {
return R.layout.customtabs_activity;
}
@Override
public void handleMessage(final String event, final GeckoBundle message,
final EventCallback callback) {
+ if (message == null ||
+ !message.containsKey("tabId") || message.getInt("tabId") != mLastSelectedTabId) {
+ return;
+ }
+
switch (event) {
case "Website:AppEntered":
getSupportActionBar().hide();
break;
case "Website:AppLeft":
getSupportActionBar().show();
break;
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2196,22 +2196,26 @@ var BrowserApp = {
return {
"historyItems": listitems,
"toIndex": toIndex
};
},
};
-async function notifyManifestStatus(browser) {
+async function notifyManifestStatus(tab) {
try {
- const manifest = await Manifests.getManifest(browser);
+ const manifest = await Manifests.getManifest(tab.browser);
const evtType = (manifest && manifest.installed) ?
"Website:AppEntered" : "Website:AppLeft";
- GlobalEventDispatcher.sendRequest({type: evtType});
+
+ GlobalEventDispatcher.sendRequest({
+ type: evtType,
+ tabId: tab.id,
+ });
} catch (err) {
Cu.reportError("Error sending status: " + err.message);
}
}
async function installManifest(browser, data) {
try {
const manifest = await Manifests.getManifest(browser, data.manifestUrl);
@@ -4509,17 +4513,17 @@ Tab.prototype = {
sameDocument: sameDocument,
canGoBack: webNav.canGoBack,
canGoForward: webNav.canGoForward,
};
GlobalEventDispatcher.sendRequest(message);
- notifyManifestStatus(this.browser);
+ notifyManifestStatus(this);
if (!sameDocument) {
// XXX This code assumes that this is the earliest hook we have at which
// browser.contentDocument is changed to the new document we're loading
this.contentDocumentIsDisplayed = false;
this.hasTouchListener = false;
Services.obs.notifyObservers(this.browser, "Session:NotifyLocationChange");
}