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

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 more tests and nits. 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 7451339ceffe6380806654b5633e306eca19baee..745585d86cd4ff7c979603e75afa317acd2731f1 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
@@ -18,6 +18,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;
@@ -46,10 +47,40 @@ 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 onDataStorageFetched(WebappDataStorage storage) {
+ if (storage == null) {
+ recordSplashScreenThemeColorUma();
+ initializeSplashScreenWidgets(null);
+ // Register the WebAPK.
+ WebappRegistry.registerWebapp(WebApkActivity.this, getId(),
+ new WebappRegistry.FetchWebappDataStorageCallback() {
+ @Override
+ public void onWebappDataStorageRetrieved(
+ WebappDataStorage storage) {
+ storage.updateFromShortcutIntent(getIntent());
+ }
+ });
+ return;
+ }
+ // Update WebappInfo from WebappDataStorage because the information in WebappDataStorage
+ // is more up to date than the information in the launch intent. Whenever the Web Manifest
+ // changes, WebappDataStorage is updated. Depending on which of the Web Manifest's fields
+ // change a new WebAPK may or may not be downloaded from the WebAPK server.
+ // TODO(hanxi): Introduces data fetcher to detect web manifest changes and
+ // update SharedPreference for WebAPKs.
+ WebappInfo info = storage.createWebappInfo(mWebappInfo);
+ boolean orientationChanged =
+ info.orientation() != mWebappInfo.orientation();
+ mWebappInfo = info;
+
+ if (orientationChanged) {
+ ScreenOrientationProvider.lockOrientation(
+ (byte) mWebappInfo.orientation(), WebApkActivity.this);
+ }
+ recordSplashScreenThemeColorUma();
+ storage.updateLastUsedTime();
+ updateTaskDescription();
+ retrieveSplashScreenImage(storage);
}
@Override

Powered by Google App Engine
This is Rietveld 408576698