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

--HG--
extra : rebase_source : 18663f8aafa5029afa1dd443cb9029ad3dd44abd
This commit is contained in:
Nevin Chen 2017-12-08 15:07:42 +08:00
Родитель 200ff11a39
Коммит 903f8af32b
3 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -569,10 +569,17 @@ public class GeckoApplication extends Application
// 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();

Просмотреть файл

@ -882,6 +882,10 @@ public class Tab {
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);
}
}
}

Просмотреть файл

@ -612,6 +612,7 @@ public class Tabs implements BundleEventListener {
} else if ("Content:SecurityChange".equals(event)) {
tab.updateIdentityData(message.getBundle("identity"));
tab.updatePageAction();
notifyListeners(tab, TabEvents.SECURITY_CHANGE);
} else if ("Content:StateChange".equals(event)) {