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

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

Issue 2124513002: Introduce ManifestUpgradeDetector for WebAPK to detect web manifest changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pkotwicz@ and yfriedman@'s comments. Created 4 years, 5 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 29cb18fcc650fafd93f2b9bed62fcd7ea80a5f94..949bb4097d5a6fc397b1c6a19eb22c4556f3fd49 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
@@ -320,7 +320,15 @@ public class WebappDataStorage {
shortcutIntent, ShortcutHelper.EXTRA_SHORT_NAME));
editor.putString(KEY_ICON, IntentUtils.safeGetStringExtra(
shortcutIntent, ShortcutHelper.EXTRA_ICON));
- editor.putInt(KEY_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION);
+ String webApkPakcageName = IntentUtils.safeGetStringExtra(
+ shortcutIntent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME);
+ if (webApkPakcageName != null) {
+ editor.putInt(KEY_VERSION, IntentUtils.safeGetIntExtra(shortcutIntent,
+ ShortcutHelper.EXTRA_VERSION, VERSION_INVALID));
+ } else {
+ editor.putInt(KEY_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION);
+ }
+ editor.putString(KEY_WEBAPK_PACKAGE_NAME, webApkPakcageName);
// "Standalone" was the original assumed default for all web apps.
editor.putInt(KEY_DISPLAY_MODE, IntentUtils.safeGetIntExtra(
@@ -341,14 +349,35 @@ 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();
}
/**
+ * Updates the data stored in this object to match the given WebappInfo.
+ */
+ public void updateFromWebappInfo(WebappInfo info) {
+ if (info == null) return;
+
+ SharedPreferences.Editor editor = mPreferences.edit();
+
+ editor.putString(KEY_URL, info.uri().toString());
+ editor.putString(KEY_SCOPE, info.scopeUri().toString());
+ editor.putString(KEY_NAME, info.name());
+ editor.putString(KEY_SHORT_NAME, info.shortName());
+ editor.putString(KEY_ICON, ShortcutHelper.encodeBitmapAsString(info.icon()));
+ editor.putInt(KEY_DISPLAY_MODE, info.displayMode());
+ editor.putInt(KEY_ORIENTATION, info.orientation());
+ editor.putLong(KEY_THEME_COLOR, info.themeColor());
+ editor.putLong(KEY_BACKGROUND_COLOR, info.backgroundColor());
+ editor.putBoolean(KEY_IS_ICON_GENERATED, info.isIconGenerated());
+ editor.putInt(KEY_SOURCE, info.source());
+ editor.putString(KEY_WEBAPK_PACKAGE_NAME, info.webApkPackageName());
+ editor.apply();
+ }
+
+ /**
* Returns the scope stored in this object, or URL_INVALID if it is not stored.
*/
String getScope() {

Powered by Google App Engine
This is Rietveld 408576698