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 c8b2e8ddc10a190f4aa2b84d92012d6f199e749b..fdf9c5669f497f9786d298035d2c1d308223021c 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 |
| @@ -33,6 +33,7 @@ public class WebappDataStorage { |
| static final String SHARED_PREFS_FILE_PREFIX = "webapp_"; |
| static final String KEY_SPLASH_ICON = "splash_icon"; |
| static final String KEY_LAST_USED = "last_used"; |
| + static final String KEY_WAS_LAUNCHED = "was_launched"; |
|
dominickn
2017/06/08 05:15:27
I'd call this "HAS_BEEN_LAUNCHED"
|
| static final String KEY_URL = "url"; |
| static final String KEY_SCOPE = "scope"; |
| static final String KEY_ICON = "icon"; |
| @@ -301,7 +302,13 @@ public class WebappDataStorage { |
| * Returns true if this web app has been launched from home screen recently (within |
| * WEBAPP_LAST_OPEN_MAX_TIME milliseconds). |
| */ |
| - public boolean wasLaunchedRecently() { |
| + /** |
|
Xi Han
2017/06/09 14:55:35
Please merge the comments above with the ones belo
|
| + * Returns true if this web app recently (within WEBAPP_LAST_OPEN_MAX_TIME milliseconds) was |
| + * either: |
| + * - registered with WebappRegistry |
| + * - launched from the homescreen |
| + */ |
| + public boolean wasUsedRecently() { |
|
dominickn
2017/06/08 05:15:27
I'd prefer that this method kept the same name. Th
pkotwicz
2017/06/12 20:34:46
I think that having *used* in the name of the func
|
| // WebappRegistry.register sets the last used time, so that counts as a 'launch'. |
| return (sClock.currentTimeMillis() - getLastUsedTime() < WEBAPP_LAST_OPEN_MAX_TIME); |
| } |
| @@ -325,6 +332,7 @@ public class WebappDataStorage { |
| // If the web app is not launched prior to the next cleanup, then its remaining data will be |
| // removed. Otherwise, the next launch from home screen will update the last used time. |
| editor.putLong(KEY_LAST_USED, LAST_USED_UNSET); |
| + editor.remove(KEY_WAS_LAUNCHED); |
| editor.remove(KEY_URL); |
| editor.remove(KEY_SCOPE); |
| editor.remove(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME); |
| @@ -384,6 +392,16 @@ public class WebappDataStorage { |
| mPreferences.edit().putLong(KEY_LAST_USED, sClock.currentTimeMillis()).apply(); |
| } |
| + /** Returns whether the web app was launched from the home screen. */ |
| + boolean wasLaunched() { |
|
dominickn
2017/06/08 05:15:27
Call this "hasBeenLaunched()", and update the comm
|
| + return mPreferences.getBoolean(KEY_WAS_LAUNCHED, false); |
| + } |
| + |
| + /** Sets the web app as having been launched from the home screen. */ |
| + void setWasLaunched() { |
|
dominickn
2017/06/08 05:15:27
setHasBeenLaunched(). Ditto with the comment.
|
| + mPreferences.edit().putBoolean(KEY_WAS_LAUNCHED, true).apply(); |
| + } |
| + |
| /** |
| * Returns the package name if the data is for a WebAPK, null otherwise. |
| */ |