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
--- 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
@@ -609,16 +609,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) {