Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import static org.chromium.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREF IX; | |
| 8 | |
| 7 import android.content.Intent; | 9 import android.content.Intent; |
| 8 import android.os.Bundle; | 10 import android.os.Bundle; |
| 9 import android.os.SystemClock; | 11 import android.os.SystemClock; |
| 10 | 12 |
| 11 import org.chromium.base.ContextUtils; | 13 import org.chromium.base.ContextUtils; |
| 12 import org.chromium.base.library_loader.LibraryProcessType; | 14 import org.chromium.base.library_loader.LibraryProcessType; |
| 13 import org.chromium.base.metrics.RecordHistogram; | 15 import org.chromium.base.metrics.RecordHistogram; |
| 14 import org.chromium.base.process_launcher.ChildProcessCreationParams; | 16 import org.chromium.base.process_launcher.ChildProcessCreationParams; |
| 15 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; | 17 import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; |
| 16 import org.chromium.chrome.browser.metrics.WebApkUma; | 18 import org.chromium.chrome.browser.metrics.WebApkUma; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 34 | 36 |
| 35 /** Indicates whether launching renderer in WebAPK process is enabled. */ | 37 /** Indicates whether launching renderer in WebAPK process is enabled. */ |
| 36 private boolean mCanLaunchRendererInWebApkProcess; | 38 private boolean mCanLaunchRendererInWebApkProcess; |
| 37 | 39 |
| 38 private final ChildProcessCreationParams mDefaultParams = | 40 private final ChildProcessCreationParams mDefaultParams = |
| 39 ChildProcessCreationParams.getDefault(); | 41 ChildProcessCreationParams.getDefault(); |
| 40 | 42 |
| 41 /** The start time that the activity becomes focused. */ | 43 /** The start time that the activity becomes focused. */ |
| 42 private long mStartTime; | 44 private long mStartTime; |
| 43 | 45 |
| 46 /** Records whether we're currently showing a disclosure notification. */ | |
| 47 private boolean mNotificationShown; | |
| 48 | |
| 44 @Override | 49 @Override |
| 45 protected WebappInfo createWebappInfo(Intent intent) { | 50 protected WebappInfo createWebappInfo(Intent intent) { |
| 46 return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(i ntent); | 51 return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(i ntent); |
| 47 } | 52 } |
| 48 | 53 |
| 49 @Override | 54 @Override |
| 50 protected void initializeUI(Bundle savedInstance) { | 55 protected void initializeUI(Bundle savedInstance) { |
| 51 super.initializeUI(savedInstance); | 56 super.initializeUI(savedInstance); |
| 52 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString( )); | 57 getActivityTab().setWebappManifestScope(mWebappInfo.scopeUri().toString( )); |
| 53 } | 58 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 } | 100 } |
| 96 | 101 |
| 97 @Override | 102 @Override |
| 98 public void onStop() { | 103 public void onStop() { |
| 99 super.onStop(); | 104 super.onStop(); |
| 100 WebApkServiceConnectionManager.getInstance().disconnect( | 105 WebApkServiceConnectionManager.getInstance().disconnect( |
| 101 ContextUtils.getApplicationContext(), getWebApkPackageName()); | 106 ContextUtils.getApplicationContext(), getWebApkPackageName()); |
| 102 } | 107 } |
| 103 | 108 |
| 104 @Override | 109 @Override |
| 110 public void onStartWithNative() { | |
| 111 super.onStartWithNative(); | |
| 112 // If WebappStorage is available, check whether to show a disclosure not ification. If it's | |
| 113 // not available, this check will happen once deferred startup returns w ith the storage | |
| 114 // instance. | |
| 115 WebappDataStorage storage = | |
| 116 WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id ()); | |
| 117 if (storage != null) maybeShowDisclosure(storage); | |
| 118 } | |
| 119 | |
| 120 @Override | |
| 105 public void onStopWithNative() { | 121 public void onStopWithNative() { |
| 106 super.onStopWithNative(); | 122 super.onStopWithNative(); |
| 123 if (mNotificationShown) { | |
| 124 WebApkDisclosureNotificationManager.dismissNotification(mWebappInfo) ; | |
| 125 mNotificationShown = false; | |
| 126 } | |
| 107 if (mUpdateManager != null && mUpdateManager.requestPendingUpdate()) { | 127 if (mUpdateManager != null && mUpdateManager.requestPendingUpdate()) { |
| 108 WebApkUma.recordUpdateRequestSent(WebApkUma.UPDATE_REQUEST_SENT_ONST OP); | 128 WebApkUma.recordUpdateRequestSent(WebApkUma.UPDATE_REQUEST_SENT_ONST OP); |
| 109 } | 129 } |
| 110 } | 130 } |
| 111 | 131 |
| 112 /** | 132 /** |
| 113 * Returns the WebAPK's package name. | 133 * Returns the WebAPK's package name. |
| 114 */ | 134 */ |
| 115 public String getWebApkPackageName() { | 135 public String getWebApkPackageName() { |
| 116 return getWebappInfo().webApkPackageName(); | 136 return getWebappInfo().webApkPackageName(); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 143 | 163 |
| 144 @Override | 164 @Override |
| 145 protected void onDeferredStartupWithStorage(WebappDataStorage storage) { | 165 protected void onDeferredStartupWithStorage(WebappDataStorage storage) { |
| 146 super.onDeferredStartupWithStorage(storage); | 166 super.onDeferredStartupWithStorage(storage); |
| 147 | 167 |
| 148 WebApkInfo info = (WebApkInfo) mWebappInfo; | 168 WebApkInfo info = (WebApkInfo) mWebappInfo; |
| 149 WebApkUma.recordShellApkVersion(info.shellApkVersion(), info.webApkPacka geName()); | 169 WebApkUma.recordShellApkVersion(info.shellApkVersion(), info.webApkPacka geName()); |
| 150 | 170 |
| 151 mUpdateManager = new WebApkUpdateManager(WebApkActivity.this, storage); | 171 mUpdateManager = new WebApkUpdateManager(WebApkActivity.this, storage); |
| 152 mUpdateManager.updateIfNeeded(getActivityTab(), info); | 172 mUpdateManager.updateIfNeeded(getActivityTab(), info); |
| 173 | |
| 174 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.
| |
| 175 } | |
| 176 | |
| 177 /** | |
| 178 * If we're showing a WebApk that's not with an expected package, it must be an | |
| 179 * "Unbound WebApk" (crbug.com/714735) so show a notification that it's runn ing in Chrome. | |
| 180 */ | |
| 181 private void maybeShowDisclosure(WebappDataStorage storage) { | |
| 182 if (!getWebApkPackageName().startsWith(WEBAPK_PACKAGE_PREFIX) | |
| 183 && !storage.hasDismissedDisclosure() && !mNotificationShown) { | |
| 184 mNotificationShown = true; | |
| 185 WebApkDisclosureNotificationManager.showDisclosure(mWebappInfo); | |
| 186 } | |
| 153 } | 187 } |
| 154 | 188 |
| 155 @Override | 189 @Override |
| 156 protected void onDeferredStartupWithNullStorage() { | 190 protected void onDeferredStartupWithNullStorage() { |
| 157 super.onDeferredStartupWithNullStorage(); | 191 super.onDeferredStartupWithNullStorage(); |
| 158 | 192 |
| 159 // Register the WebAPK. The WebAPK is not registered when it is created so it has to be | 193 // Register the WebAPK. The WebAPK is not registered when it is created so it has to be |
| 160 // registered now. The WebAPK may also become unregistered after a user clears Chrome's | 194 // registered now. The WebAPK may also become unregistered after a user clears Chrome's |
| 161 // data. | 195 // data. |
| 162 WebappRegistry.getInstance().register( | 196 WebappRegistry.getInstance().register( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 } | 237 } |
| 204 | 238 |
| 205 @Override | 239 @Override |
| 206 protected void onDestroyInternal() { | 240 protected void onDestroyInternal() { |
| 207 if (mUpdateManager != null) { | 241 if (mUpdateManager != null) { |
| 208 mUpdateManager.destroy(); | 242 mUpdateManager.destroy(); |
| 209 } | 243 } |
| 210 super.onDestroyInternal(); | 244 super.onDestroyInternal(); |
| 211 } | 245 } |
| 212 } | 246 } |
| OLD | NEW |