Chromium Code Reviews| 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..db2e3a127dc6e38934b900aea1ea16248fe39244 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 |
| @@ -284,6 +284,10 @@ public class WebappDataStorage { |
| * @param shortcutIntent The intent to pull web app data from. |
| */ |
| public void updateFromShortcutIntent(Intent shortcutIntent) { |
| + updateFromShortcutIntent(shortcutIntent, false); |
| + } |
| + |
| + public void updateFromShortcutIntent(Intent shortcutIntent, boolean bypassVersionCheck) { |
|
Yaron
2016/07/20 02:27:59
what's this about bypassing the version check?
Xi Han
2016/07/20 18:55:00
The version of Webapp is always set to ShortcutHel
|
| if (shortcutIntent == null) return; |
| SharedPreferences.Editor editor = mPreferences.edit(); |
| @@ -313,7 +317,7 @@ public class WebappDataStorage { |
| // updated. All fields except for the last used time, scope, and URL are either set or |
| // cleared together. |
| if (mPreferences.getInt(KEY_VERSION, VERSION_INVALID) |
| - != ShortcutHelper.WEBAPP_SHORTCUT_VERSION) { |
| + != ShortcutHelper.WEBAPP_SHORTCUT_VERSION || bypassVersionCheck) { |
| editor.putString(KEY_NAME, IntentUtils.safeGetStringExtra( |
| shortcutIntent, ShortcutHelper.EXTRA_NAME)); |
| editor.putString(KEY_SHORT_NAME, IntentUtils.safeGetStringExtra( |
| @@ -349,6 +353,30 @@ public class WebappDataStorage { |
| } |
| /** |
| + * 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(); |
| + |
| + String url = info.uri().toString(); |
| + editor.putString(KEY_URL, url); |
| + editor.putString(KEY_SCOPE, ShortcutHelper.getScopeFromUrl(url)); |
|
pkotwicz
2016/07/19 18:02:38
Should we use WebappInfo#scope()?
Yaron
2016/07/20 02:27:59
I think that's right
Xi Han
2016/07/20 18:55:00
Good catch!
|
| + 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() { |