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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.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/WebappDataStorage.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
index 5ddee243bc56c741a54ca135ace38b0085a04ec7..b52f1a61f8a2f57b175e0812f6b9a9ec0bb53be9 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
@@ -44,6 +44,7 @@ public class WebappDataStorage {
static final String KEY_ACTION = "action";
static final String KEY_IS_ICON_GENERATED = "is_icon_generated";
static final String KEY_VERSION = "version";
+ static final String KEY_WEBAPK_PACKAGE_NAME = "webapk_package_name";
// Unset/invalid constants for last used times and URLs. 0 is used as the null last
// used time as WebappRegistry assumes that this is always a valid timestamp.
@@ -279,6 +280,31 @@ public class WebappDataStorage {
}
/**
+ * Creates a {@link WebappInfo} from the metadata.
+ */
+ public WebappInfo createWebappInfo(WebappInfo fallbackInfo) {
+ assert !ThreadUtils.runningOnUiThread();
+ String icon = mPreferences.getString(KEY_ICON, null);
+ if (icon == null && fallbackInfo.icon() != null) {
+ icon = ShortcutHelper.encodeBitmapAsString(fallbackInfo.icon());
+ }
+ return WebappInfo.create(mId,
+ // Note: we never use cached URL since it is possible to launch a WebAPK from a URL
+ // that is not the start URL.
+ fallbackInfo.uri().toString(),
+ icon,
+ mPreferences.getString(KEY_NAME, fallbackInfo.name()),
+ mPreferences.getString(KEY_SHORT_NAME, fallbackInfo.shortName()),
+ mPreferences.getInt(KEY_DISPLAY_MODE, fallbackInfo.displayMode()),
+ mPreferences.getInt(KEY_ORIENTATION, fallbackInfo.orientation()),
+ mPreferences.getInt(KEY_SOURCE, fallbackInfo.source()),
+ mPreferences.getLong(KEY_THEME_COLOR, fallbackInfo.themeColor()),
+ mPreferences.getLong(KEY_BACKGROUND_COLOR, fallbackInfo.backgroundColor()),
+ mPreferences.getBoolean(KEY_IS_ICON_GENERATED, fallbackInfo.isIconGenerated()),
+ mPreferences.getString(KEY_WEBAPK_PACKAGE_NAME, fallbackInfo.webApkPackageName()));
+ }
+
+ /**
* Updates the data stored in this object to match that in the supplied intent.
* @param shortcutIntent The intent to pull web app data from.
*/
@@ -340,6 +366,8 @@ public class WebappDataStorage {
editor.putInt(KEY_SOURCE, IntentUtils.safeGetIntExtra(
shortcutIntent, ShortcutHelper.EXTRA_SOURCE,
ShortcutSource.UNKNOWN));
+ editor.putString(KEY_WEBAPK_PACKAGE_NAME, IntentUtils.safeGetStringExtra(
+ shortcutIntent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME));
updated = true;
}
if (updated) editor.apply();
@@ -374,6 +402,12 @@ public class WebappDataStorage {
}
/**
+ * Returns the package name if the data is for a WebAPK, NULL otherwise.
+ */
+ String getWebApkPakcageName() {
+ return mPreferences.getString(KEY_WEBAPK_PACKAGE_NAME, null);
+ }
+ /**
* Returns true if this web app has been launched from home screen recently (within
* WEBAPP_LAST_OPEN_MAX_TIME milliseconds).
*/

Powered by Google App Engine
This is Rietveld 408576698