| 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..635d973ddbb22e78f2a9429ef90fe8f93551addf 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;
|
|
|
| + /** The id tag for the disclosure notification, if one is presented. */
|
| + private int mNotificationId = 0;
|
| +
|
| @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 (mNotificationId != 0) {
|
| + WebApkDisclosureNotificationManager.dismissNotification(mWebappInfo, mNotificationId);
|
| + mNotificationId = 0;
|
| + }
|
| if (mUpdateManager != null && mUpdateManager.requestPendingUpdate()) {
|
| WebApkUma.recordUpdateRequestSent(WebApkUma.UPDATE_REQUEST_SENT_ONSTOP);
|
| }
|
| @@ -150,6 +170,19 @@ public class WebApkActivity extends WebappActivity {
|
|
|
| mUpdateManager = new WebApkUpdateManager(WebApkActivity.this, storage);
|
| mUpdateManager.updateIfNeeded(getActivityTab(), info);
|
| +
|
| + maybeShowDisclosure(storage);
|
| + }
|
| +
|
| + /**
|
| + * 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() && mNotificationId == 0) {
|
| + mNotificationId = WebApkDisclosureNotificationManager.showDisclosure(mWebappInfo);
|
| + }
|
| }
|
|
|
| @Override
|
|
|