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

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

Issue 2860193002: Correctly record WebAPK install source for Launch.HomescreenSource (Closed)
Patch Set: Created 3 years, 7 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/WebApkActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java
index 68d399b017a13b7e035839f009c870809dbed48f..7a0badb700406677452cd952c6be56549604a81c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkActivity.java
@@ -12,7 +12,9 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.process_launcher.ChildProcessCreationParams;
+import org.chromium.chrome.browser.ShortcutSource;
import org.chromium.chrome.browser.externalnav.ExternalNavigationParams;
+import org.chromium.chrome.browser.metrics.LaunchMetrics;
import org.chromium.chrome.browser.metrics.WebApkUma;
import org.chromium.chrome.browser.tab.BrowserControlsVisibilityDelegate;
import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl;
@@ -41,6 +43,9 @@ public class WebApkActivity extends WebappActivity {
/** The start time that the activity becomes focused. */
private long mStartTime;
+ /** Indicates whether has committed the source info to the launch metrics. */
+ private boolean mHasCommitedLaunchMetrics;
+
@Override
protected WebappInfo createWebappInfo(Intent intent) {
return (intent == null) ? WebApkInfo.createEmpty() : WebApkInfo.create(intent);
@@ -125,6 +130,22 @@ public class WebApkActivity extends WebappActivity {
// and sets {@link ChildProcessCreationParams} for WebAPK's renderer process so the
// {@link ChildProcessLauncher} knows which application's renderer service to connect to.
initializeChildProcessCreationParams(mCanLaunchRendererInWebApkProcess);
+
+ // Records launch metrics for the WebAPK.
+ if (!mHasCommitedLaunchMetrics) {
+ mHasCommitedLaunchMetrics = true;
+ WebappDataStorage storage =
+ WebappRegistry.getInstance().getWebappDataStorage(mWebappInfo.id());
+ int source = storage != null ? storage.getSource(ShortcutSource.WEBAPK_UNKNOWN)
+ : ShortcutSource.WEBAPK_UNKNOWN;
+ if (source == ShortcutSource.UNKNOWN) {
+ source = ShortcutSource.WEBAPK_UNKNOWN;
+ storage.updateSource(source);
+ }
+ LaunchMetrics.recordHomeScreenLaunchIntoStandaloneActivity(
+ mWebappInfo.uri().toString(), source);
+ LaunchMetrics.commitLaunchMetrics(getActivityTab().getWebContents());
+ }
}
@Override
@@ -154,9 +175,8 @@ public class WebApkActivity extends WebappActivity {
protected void onDeferredStartupWithNullStorage() {
super.onDeferredStartupWithNullStorage();
- // Register the WebAPK. The WebAPK is not registered when it is created so it has to be
- // registered now. The WebAPK may also become unregistered after a user clears Chrome's
- // data.
+ // Register the WebAPK. The WebAPK was registered when it was created, but may also become
+ // unregistered after a user clears Chrome's data.
WebappRegistry.getInstance().register(
mWebappInfo.id(), new WebappRegistry.FetchWebappDataStorageCallback() {
@Override
@@ -165,6 +185,7 @@ public class WebApkActivity extends WebappActivity {
// registration time. This prevents checking for updates on the first run.
storage.updateTimeOfLastCheckForUpdatedWebManifest();
pkotwicz 2017/05/05 21:05:43 You need https://codereview.chromium.org/286677300
Xi Han 2017/05/08 20:55:28 Acknowledged.
+ storage.updateSource(ShortcutSource.WEBAPK_UNKNOWN);
onDeferredStartupWithStorage(storage);
}
});

Powered by Google App Engine
This is Rietveld 408576698