Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java

Issue 2725813004: Init WebApkUpdateManager with a WebappDataStorage to avoid null object. (Closed)
Patch Set: Split onDeferredStorage Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 de83e602556dd75d3101b5d4dc6d72d04b8c0eb1..d7b965f15a67362bf68168ba96d8aa7209dbbca4 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
@@ -63,33 +63,6 @@ public class WebApkActivity extends WebappActivity {
}
@Override
- protected void onStorageIsNull(final int backgroundColor) {
- // Register the WebAPK. It is possible that a WebAPK's meta data was deleted when user
- // cleared Chrome's data. When it is launched again, we know that the WebAPK is still
- // installed, so re-register it.
- WebappRegistry.getInstance().register(
- mWebappInfo.id(), new WebappRegistry.FetchWebappDataStorageCallback() {
- @Override
- public void onWebappDataStorageRetrieved(WebappDataStorage storage) {
- updateStorage(storage);
- // Initialize the time of the last is-update-needed check with the
- // registration time. This prevents checking for updates on the first run.
- storage.updateTimeOfLastCheckForUpdatedWebManifest();
-
- // The downloading of the splash screen image happens before a WebAPK's
- // package name is available. If we want to use the image in the first
- // launch, we need to cache the image, register the WebAPK and store the
- // image in the SharedPreference when the WebAPK is installed
- // (before the first launch), and delete the cached image if it's not
- // installed. Therefore, lots of complexity will be introduced. To simplify
- // the logic, WebAPKs are registered during the first launch, and don't
- // retrieve splash screen image but use app icon for initialization.
- initializeSplashScreenWidgets(backgroundColor, null);
- }
- });
- }
-
- @Override
protected TabDelegateFactory createTabDelegateFactory() {
return new WebappDelegateFactory(this) {
@Override
@@ -166,11 +139,32 @@ public class WebApkActivity extends WebappActivity {
}
@Override
- public void onDeferredStartup() {
- super.onDeferredStartup();
+ protected void onDeferredStartupWithStorage(WebappDataStorage storage) {
+ super.onDeferredStartupWithStorage(storage);
+
+ // Initialize the time of the last is-update-needed check with the registration time. This
+ // prevents checking for updates on the first run.
+ storage.updateTimeOfLastCheckForUpdatedWebManifest();
+
+ mUpdateManager = new WebApkUpdateManager(WebApkActivity.this, storage);
+ mUpdateManager.updateIfNeeded(getActivityTab(),
+ (WebApkInfo) mWebappInfo);
+ }
+
+ @Override
+ protected void onDeferredStartupWithNullStorage() {
+ super.onDeferredStartupWithNullStorage();
- mUpdateManager = new WebApkUpdateManager(this);
- mUpdateManager.updateIfNeeded(getActivityTab(), (WebApkInfo) mWebappInfo);
+ // Register the WebAPK. The WebAPK is not registered when it is created so it has to be
+ // registered now. The WebAPK may also become unregistered after a user clears Chrome's
+ // data.
+ WebappRegistry.getInstance().register(
+ mWebappInfo.id(), new WebappRegistry.FetchWebappDataStorageCallback() {
+ @Override
+ public void onWebappDataStorageRetrieved(WebappDataStorage storage) {
+ onDeferredStartupWithStorage(storage);
+ }
+ });
}
@Override
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698