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

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

Issue 2071213005: Use metadata when launching WebAPKs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add WebAPK's metadata in WebappDataStorage. Created 4 years, 6 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
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 929de692774897865ec4a3a1b9699f0d5686d137..b5576ea3b05738365469bafa9af04113fbd84c79 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
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.webapps;
import android.content.Intent;
+import android.graphics.Bitmap;
import org.chromium.base.ContextUtils;
import org.chromium.base.library_loader.LibraryProcessType;
@@ -18,6 +19,7 @@ import org.chromium.chrome.browser.tab.TabDelegateFactory;
import org.chromium.chrome.browser.tab.TabRedirectHandler;
import org.chromium.components.navigation_interception.NavigationParams;
import org.chromium.content.browser.ChildProcessCreationParams;
+import org.chromium.content.browser.ScreenOrientationProvider;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.base.PageTransition;
import org.chromium.webapk.lib.client.WebApkServiceConnectionManager;
@@ -47,10 +49,45 @@ public class WebApkActivity extends WebappActivity {
}
@Override
- protected void initializeSplashScreenWidgets(final int backgroundColor) {
- // TODO(hanxi): Removes this function and use {@link WebApkActivity}'s implementation
- // when WebAPKs are registered in WebappRegistry.
- initializeSplashScreenWidgets(backgroundColor, null);
+ protected void initializeWebappData() {
pkotwicz 2016/06/20 18:26:14 - Can this function be in WebappActivity instead o
Xi Han 2016/06/22 15:55:28 I am not sure whether this suits Webapps, because
pkotwicz 2016/06/23 01:16:37 I don't mind waiting till the "fetch updated Web M
+ WebappRegistry.getWebappDataStorage(this, getId(),
+ new WebappRegistry.FetchWebappDataStorageCallback() {
+ @Override
+ public void onWebappDataStorageRetrieved(WebappDataStorage storage) {
+ if (storage == null) {
pkotwicz 2016/06/20 18:26:14 Currently, WebappRegistry#registerWebapp() is not
Xi Han 2016/06/22 15:55:28 Yes, we always go through the early return for now
pkotwicz 2016/06/23 01:16:37 I think that there will be multiple places which w
pkotwicz 2016/06/27 19:23:38 It looks like you missed this comment
Xi Han 2016/06/27 20:04:10 Sorry, just forgot to reply in here. I add the reg
pkotwicz 2016/06/28 19:00:11 I see the call to registerWebapp() now. Sorry that
+ initializeSplashScreenWidgets(initializeWebappDataInternal(), null);
+ return;
+ }
+ // Update WebappInfo for the WebAPK. Changes in fields like backgroundColor,
+ // themeColor, orientation won't request re-minting a WebAPK, but will
+ // update the metadata in the SharedPreference. The updated values are
+ // used when launching a WebAPK.
+ // TODO(hanxi): Introduces data fetcher to detect web manifest changes and
+ // update SharedPreference for WebAPKs.
+ mWebappInfo.setBackgroundColor(storage.getBackgroundColor());
+ final int backgroundColor = initializeWebappDataInternal();
+
+ mWebappInfo.setThemeColor(storage.getThemeColor());
+
+ int orientation = storage.getOrientation();
+ if (mWebappInfo.orientation() != orientation) {
+ mWebappInfo.setOrientation(orientation);
+ ScreenOrientationProvider.lockOrientation(
+ (byte) mWebappInfo.orientation(), WebApkActivity.this);
+ }
+
pkotwicz 2016/06/20 18:26:14 Shouldn't we also update WebappInfo#name()? I am u
Xi Han 2016/06/22 15:55:28 Good point. Creating a new WebappInfo will have th
+ storage.updateLastUsedTime();
+
+ // Retrieve the splash image if it exists.
+ storage.getSplashScreenImage(new WebappDataStorage.FetchCallback<Bitmap>() {
+ @Override
+ public void onDataRetrieved(Bitmap splashImage) {
+ initializeSplashScreenWidgets(backgroundColor, splashImage);
+ }
+ });
+ }
+ }
+ );
}
@Override

Powered by Google App Engine
This is Rietveld 408576698