| 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..5a5d175b83a79160cf1f4c4735739634b91eb2f8 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,10 +4,14 @@
|
|
|
| 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;
|
|
|
| +import org.chromium.base.ActivityState;
|
| +import org.chromium.base.ApplicationStatus;
|
| import org.chromium.base.ContextUtils;
|
| import org.chromium.base.library_loader.LibraryProcessType;
|
| import org.chromium.base.metrics.RecordHistogram;
|
| @@ -41,6 +45,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 mNotificationShowing;
|
| +
|
| @Override
|
| protected WebappInfo createWebappInfo(Intent intent) {
|
| return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(intent);
|
| @@ -102,8 +109,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 (mNotificationShowing) {
|
| + WebApkDisclosureNotificationManager.dismissNotification(mWebappInfo);
|
| + mNotificationShowing = false;
|
| + }
|
| if (mUpdateManager != null && mUpdateManager.requestPendingUpdate()) {
|
| WebApkUma.recordUpdateRequestSent(WebApkUma.UPDATE_REQUEST_SENT_ONSTOP);
|
| }
|
| @@ -150,6 +172,24 @@ 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() && !mNotificationShowing) {
|
| + int activityState = ApplicationStatus.getStateForActivity(this);
|
| + if (activityState == ActivityState.STARTED || activityState == ActivityState.RESUMED
|
| + || activityState == ActivityState.PAUSED) {
|
| + mNotificationShowing = true;
|
| + WebApkDisclosureNotificationManager.showDisclosure(mWebappInfo);
|
| + }
|
| + }
|
| }
|
|
|
| @Override
|
|
|