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

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

Issue 2930553002: Add UMA metric to track the time elapsed since a WebAPK was last launched (Closed)
Patch Set: Merge branch 'master' into last_launched2 Created 3 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 9c85fda3d5e709d921f9b00197216815577ed8d2..650fcb7dae17c9d1552bc9e133e6c5678f3ca1d8 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_HAS_BEEN_LAUNCHED = "has_been_launched";
static final String KEY_URL = "url";
static final String KEY_SCOPE = "scope";
static final String KEY_ICON = "icon";
@@ -291,10 +292,12 @@ public class WebappDataStorage {
}
/**
- * Returns true if this web app has been launched from home screen recently (within
- * WEBAPP_LAST_OPEN_MAX_TIME milliseconds).
+ * 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 wasLaunchedRecently() {
+ public boolean wasUsedRecently() {
// WebappRegistry.register sets the last used time, so that counts as a 'launch'.
return (sClock.currentTimeMillis() - getLastUsedTime() < WEBAPP_LAST_OPEN_MAX_TIME);
}
@@ -315,6 +318,7 @@ public class WebappDataStorage {
SharedPreferences.Editor editor = mPreferences.edit();
editor.remove(KEY_LAST_USED);
+ editor.remove(KEY_HAS_BEEN_LAUNCHED);
editor.remove(KEY_URL);
editor.remove(KEY_SCOPE);
editor.remove(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME);
@@ -374,6 +378,16 @@ public class WebappDataStorage {
mPreferences.edit().putLong(KEY_LAST_USED, sClock.currentTimeMillis()).apply();
}
+ /** Returns true if the web app has been launched at least once from the home screen. */
+ boolean hasBeenLaunched() {
+ return mPreferences.getBoolean(KEY_HAS_BEEN_LAUNCHED, false);
+ }
+
+ /** Sets whether the web app was launched at least once from the home screen. */
+ void setHasBeenLaunched() {
+ mPreferences.edit().putBoolean(KEY_HAS_BEEN_LAUNCHED, true).apply();
+ }
+
/**
* Returns the package name if the data is for a WebAPK, null otherwise.
*/

Powered by Google App Engine
This is Rietveld 408576698