Bug 1424179 - Hide PWA badge when site identity updates to mix content. r=walkingice, a=gchang
authorNevin Chen <cnevinchen@gmail.com>
Fri, 08 Dec 2017 15:07:42 +0800
changeset 445525 c9992d9c13a867fc3a5fe2c86d5b45397a346095
parent 445524 55b95085ee3bf42caba85c756e688df866f3d743
child 445526 70846c5670178a9f4408f1029ac1bc4f45183a38
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswalkingice, gchang
bugs1424179
milestone58.0
Bug 1424179 - Hide PWA badge when site identity updates to mix content. r=walkingice, a=gchang https://m.aliexpress.com is a good target to test. But it sometimes show mixed content, sometimes not. I also chnage the check when adding a PWA shortcut. Only fail fast in nightly and local build. MozReview-Commit-ID: 4sLoNERIYuW
mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
mobile/android/base/java/org/mozilla/gecko/Tab.java
mobile/android/base/java/org/mozilla/gecko/Tabs.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
@@ -564,20 +564,27 @@ public class GeckoApplication extends Ap
     public static void createShortcut(final String title, final String url) {
         final Tab selectedTab = Tabs.getInstance().getSelectedTab();
         final String manifestUrl = selectedTab.getManifestUrl();
 
         if (manifestUrl != null) {
             // If a page has associated manifest, lets install it (PWA A2HS)
             // At this time, this page must be a secure page.
             // Please hide PWA badge UI in front end side.
-            // Otherwise we'll throw an exception here.
             final boolean safeForPwa = PwaUtils.shouldAddPwaShortcut(selectedTab);
             if (!safeForPwa) {
-                throw new IllegalStateException("This page is not safe for PWA");
+                final String message = "This page is not safe for PWA";
+                // For release and beta, we record an error message
+                if (AppConstants.RELEASE_OR_BETA) {
+                    Log.e(LOG_TAG, message);
+                } else {
+                    // For nightly and local build, we'll throw an exception here.
+                    throw new IllegalStateException(message);
+                }
+
             }
 
             final GeckoBundle message = new GeckoBundle();
             message.putInt("iconSize", GeckoAppShell.getPreferredIconSize());
             message.putString("manifestUrl", manifestUrl);
             message.putString("originalUrl", url);
             message.putString("originalTitle", title);
             EventDispatcher.getInstance().dispatch("Browser:LoadManifest", message);
--- a/mobile/android/base/java/org/mozilla/gecko/Tab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tab.java
@@ -877,11 +877,15 @@ public class Tab {
     private void showPwaBadge() {
         if (PwaUtils.shouldAddPwaShortcut(this)) {
             GeckoBundle bundle = new GeckoBundle();
             bundle.putString("id", UUID_PAGE_ACTION_PWA);
             bundle.putString("title", mAppContext.getString(R.string.pwa_add_to_launcher_badge));
             bundle.putString("icon", "drawable://add_to_homescreen");
             bundle.putBoolean("important", true);
             EventDispatcher.getInstance().dispatch("PageActions:Add", bundle);
+        } else {
+            GeckoBundle bundle = new GeckoBundle();
+            bundle.putString("id", UUID_PAGE_ACTION_PWA);
+            EventDispatcher.getInstance().dispatch("PageActions:Remove", bundle);
         }
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -608,16 +608,17 @@ public class Tabs implements BundleEvent
             tab.handleLocationChange(message);
 
         } else if ("Content:SubframeNavigation".equals(event)) {
             tab.handleButtonStateChange(message);
             notifyListeners(tab, TabEvents.LOCATION_CHANGE, tab.getURL());
 
         } else if ("Content:SecurityChange".equals(event)) {
             tab.updateIdentityData(message.getBundle("identity"));
+            tab.updatePageAction();
             notifyListeners(tab, TabEvents.SECURITY_CHANGE);
 
         } else if ("Content:StateChange".equals(event)) {
             final int state = message.getInt("state");
             if ((state & GeckoAppShell.WPL_STATE_IS_NETWORK) == 0) {
                 return;
             }
             if ((state & GeckoAppShell.WPL_STATE_START) != 0) {