Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java |
| index a6d3108cc311843903e59a0f2887723294d224d5..64c9386241ae7cf8f1c849e32a491aa3bb181464 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java |
| @@ -4,6 +4,8 @@ |
| package org.chromium.chrome.browser.webapps; |
| +import static org.chromium.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREFIX; |
| + |
| import android.content.Intent; |
| import android.os.Bundle; |
| import android.os.SystemClock; |
| @@ -41,6 +43,9 @@ public class WebApkActivity extends WebappActivity { |
| /** The start time that the activity becomes focused. */ |
| private long mStartTime; |
| + /** Records whether we're currently showing a disclosure notification. */ |
| + private boolean mNotificationShown; |
| + |
| @Override |
| protected WebappInfo createWebappInfo(Intent intent) { |
| return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(intent); |
| @@ -102,8 +107,23 @@ public class WebApkActivity extends WebappActivity { |
| } |
| @Override |
| + public void onStartWithNative() { |
| + super.onStartWithNative(); |
| + // If WebappStorage is available, check whether to show a disclosure notification. If it's |
| + // not available, this check will happen once deferred startup returns with the storage |
| + // instance. |
| + WebappDataStorage storage = |
| + WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id()); |
| + if (storage != null) maybeShowDisclosure(storage); |
| + } |
| + |
| + @Override |
| public void onStopWithNative() { |
| super.onStopWithNative(); |
| + if (mNotificationShown) { |
| + WebApkDisclosureNotificationManager.dismissNotification(mWebappInfo); |
| + mNotificationShown = false; |
| + } |
| if (mUpdateManager != null && mUpdateManager.requestPendingUpdate()) { |
| WebApkUma.recordUpdateRequestSent(WebApkUma.UPDATE_REQUEST_SENT_ONSTOP); |
| } |
| @@ -150,6 +170,20 @@ public class WebApkActivity extends WebappActivity { |
| mUpdateManager = new WebApkUpdateManager(WebApkActivity.this, storage); |
| mUpdateManager.updateIfNeeded(getActivityTab(), info); |
| + |
| + maybeShowDisclosure(storage); |
|
pkotwicz
2017/05/25 22:08:42
It is possible for onDeferredStartup() to be calle
Yaron
2017/05/26 14:33:00
Done.
|
| + } |
| + |
| + /** |
| + * If we're showing a WebApk that's not with an expected package, it must be an |
| + * "Unbound WebApk" (crbug.com/714735) so show a notification that it's running in Chrome. |
| + */ |
| + private void maybeShowDisclosure(WebappDataStorage storage) { |
| + if (!getWebApkPackageName().startsWith(WEBAPK_PACKAGE_PREFIX) |
| + && !storage.hasDismissedDisclosure() && !mNotificationShown) { |
| + mNotificationShown = true; |
| + WebApkDisclosureNotificationManager.showDisclosure(mWebappInfo); |
| + } |
| } |
| @Override |