Bug 1424179 - Hide PWA badge when site identity updates to mix content. r=walkingice
authorNevin Chen <cnevinchen@gmail.com>
Fri, 08 Dec 2017 15:07:42 +0800
changeset 448438 c97612e2aa6e8d225ad35a5051c3c3d9ff76df21
parent 448437 9ac1a844d346512416b3d6239cd07bf0bc49ce18
child 448439 14c5ca99af0cc6efe803d2f9d31c9e35ef500b4d
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswalkingice
bugs1424179
milestone59.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 1424179 - Hide PWA badge when site identity updates to mix content. r=walkingice 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
@@ -607,16 +607,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) {