Skip to content

Commit

Permalink
[Android WebAPK] Add UMA for whether WebAPK navigation is in scope
Browse files Browse the repository at this point in the history
This CL adds a new UMA metric WebApk.Navigation.InScope which is
recorded on every WebAPK navigation. It records whether WebAPK
navigations are within the WebAPK's scope.

BUG=999648

Change-Id: I0d8fc678f396e8fd55c48aabd41b8878ee8fdcd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1788304
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695828}
  • Loading branch information
pkotwicz authored and Commit Bot committed Sep 11, 2019
1 parent a798c10 commit d57b258
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ public static void recordNetworkErrorWhenLaunch(int errorCode) {
RecordHistogram.recordSparseHistogram("WebApk.Launch.NetworkError", -errorCode);
}

/**
* Records whether a WebAPK navigation is within the WebAPK's scope.
*/
public static void recordNavigation(boolean isNavigationInScope) {
RecordHistogram.recordBooleanHistogram("WebApk.Navigation.InScope", isNavigationInScope);
}

/**
* Log necessary disk usage and cache size UMAs when WebAPK installation fails.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.chromium.chrome.browser.customtabs.CustomTabAppMenuPropertiesDelegate;
import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.document.DocumentUtils;
import org.chromium.chrome.browser.metrics.WebApkUma;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabBrowserControlsState;
Expand Down Expand Up @@ -600,13 +601,17 @@ public void onDidFinishNavigation(Tab tab, NavigationHandle navigation) {

updateToolbarCloseButtonVisibility();

if (!WebappScopePolicy.isUrlInScope(
scopePolicy(), mWebappInfo, navigation.getUrl())) {
boolean isNavigationInScope = WebappScopePolicy.isUrlInScope(
scopePolicy(), mWebappInfo, navigation.getUrl());
if (!isNavigationInScope) {
// Briefly show the toolbar for off-scope navigations.
getFullscreenManager()
.getBrowserVisibilityDelegate()
.showControlsTransient();
}
if (mWebappInfo.isForWebApk()) {
WebApkUma.recordNavigation(isNavigationInScope);
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153197,6 +153197,17 @@ regressions. -->
</summary>
</histogram>

<histogram name="WebApk.Navigation.InScope" enum="Boolean"
expires_after="2020-04-01">
<owner>hartmanng@chromium.org</owner>
<owner>pkotwicz@chromium.org</owner>
<owner>yfriedman@chromium.org</owner>
<summary>
Recorded each time that a WebAPK is navigated. Records whether the
navigation is within the scope of the WebAPK's Web Manifest.
</summary>
</histogram>

<histogram name="WebApk.Notification.Permission.Status"
enum="BooleanWebApkNotificationPermission" expires_after="2020-02-23">
<owner>hanxi@chromium.org</owner>
Expand Down

0 comments on commit d57b258

Please sign in to comment.