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 28547bfbc1c1751139565e3e3d2f1112552c8a49..ec94fde2ca24117c5f989d63d968a758663db9df 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 |
| @@ -7,6 +7,7 @@ package org.chromium.chrome.browser.webapps; |
| import android.content.Intent; |
| import org.chromium.base.ContextUtils; |
| +import org.chromium.base.Log; |
| import org.chromium.base.library_loader.LibraryProcessType; |
| import org.chromium.chrome.browser.ChromeApplication; |
| import org.chromium.chrome.browser.ShortcutHelper; |
| @@ -23,11 +24,16 @@ import org.chromium.content_public.browser.LoadUrlParams; |
| import org.chromium.ui.base.PageTransition; |
| import org.chromium.webapk.lib.client.WebApkServiceConnectionManager; |
| +import java.util.Set; |
| + |
| /** |
| * An Activity is designed for WebAPKs (native Android apps) and displays a webapp in a nearly |
| * UI-less Chrome. |
| */ |
| public class WebApkActivity extends WebappActivity { |
| + private static final String TAG = "cr_WebApkActivity"; |
| + private ManifestUpgradeDetector mManifestUpgradeDetector = null; |
| + |
| @Override |
| protected void onNewIntent(Intent intent) { |
| super.onNewIntent(intent); |
| @@ -59,7 +65,7 @@ public class WebApkActivity extends WebappActivity { |
| @Override |
| public void onWebappDataStorageRetrieved( |
| WebappDataStorage storage) { |
| - storage.updateFromShortcutIntent(getIntent()); |
| + storage.updateFromShortcutIntent(getIntent(), true); |
| } |
| }); |
| return; |
| @@ -78,6 +84,7 @@ public class WebApkActivity extends WebappActivity { |
| (byte) mWebappInfo.orientation(), WebApkActivity.this); |
| } |
| mWebappInfo.updateThemeColor(storage.getThemeColor()); |
| + mWebappInfo.updateShortName(storage.getShortName()); |
|
pkotwicz
2016/07/12 21:04:28
This change should be part of a separate CL which
pkotwicz
2016/07/13 01:08:20
The name should be the one being updated. The shor
Xi Han
2016/07/13 19:25:14
Removed.
Xi Han
2016/07/13 19:25:14
Will do.
|
| recordSplashScreenThemeColorUma(); |
| storage.updateLastUsedTime(); |
| retrieveSplashScreenImage(storage); |
| @@ -112,6 +119,31 @@ public class WebApkActivity extends WebappActivity { |
| }; |
| } |
| + private ManifestUpgradeDetector.Observer createObserver() { |
| + return new ManifestUpgradeDetector.Observer() { |
| + @Override |
| + public void onManifestAvaliable(boolean isUpgraded, |
| + final WebappInfo newInfo, final Set<String> iconUrls) { |
| + Log.w(TAG, "Should request to update the installed WebAPK: " + isUpgraded); |
| + if (isUpgraded) { |
| + // call WebApkUpdateManager to request update from WebAPK minting server. |
| + // Note: always send the WebApk minting server the old metadata for checking |
| + // updates before updating Chrome's sharedPreference. |
| + } |
| + WebappRegistry.getWebappDataStorage(WebApkActivity.this, |
| + newInfo.id(), |
| + new WebappRegistry.FetchWebappDataStorageCallback() { |
| + @Override |
| + public void onWebappDataStorageRetrieved( |
| + WebappDataStorage storage) { |
| + storage.updateFromWebappInfo(newInfo, iconUrls); |
| + } |
| + } |
| + ); |
| + } |
| + }; |
| + } |
| + |
| @Override |
| public void onStop() { |
| super.onStop(); |
| @@ -144,6 +176,23 @@ public class WebApkActivity extends WebappActivity { |
| } |
| @Override |
| + protected void checkUpdates() { |
| + if (shouldCheckUpdate()) { |
| + if (mManifestUpgradeDetector == null) { |
| + mManifestUpgradeDetector = |
| + new ManifestUpgradeDetector(getActivityTab(), mWebappInfo); |
| + mManifestUpgradeDetector.setManifestUpgradeDetectorObserver(createObserver()); |
| + } |
| + mManifestUpgradeDetector.start(); |
| + } |
| + } |
| + |
| + private boolean shouldCheckUpdate() { |
| + // TODO(hanxi): Asks WebApk's update manager whether to check resources updates. |
| + return mManifestUpgradeDetector == null; |
| + } |
| + |
| + @Override |
| public void onPause() { |
| super.onPause(); |
| initializeChildProcessCreationParams(false); |
| @@ -165,4 +214,11 @@ public class WebApkActivity extends WebappActivity { |
| } |
| ChildProcessCreationParams.set(params); |
| } |
| + |
| + @Override |
| + protected void onDestroyInternal() { |
| + if (mManifestUpgradeDetector != null) { |
| + mManifestUpgradeDetector.destroy(); |
| + } |
| + } |
| } |