Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchFromNotificationUMA.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchFromNotificationUMA.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchFromNotificationUMA.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6c141e0c49cbdfac478f907648ae299836b07895 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchFromNotificationUMA.java |
| @@ -0,0 +1,36 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.metrics; |
| + |
| +import android.content.Intent; |
| + |
| +/** |
| + * Helper class to record which kind of notifications does the user click to go back to Chrome. |
| + */ |
| +public class LaunchFromNotificationUMA { |
|
gone
2016/04/20 22:17:14
LaunchFromNotificationUma, not UMA. media/ unique
Zhiqiang Zhang (Slow)
2016/04/21 16:36:53
Done.
|
| + public static final int SOURCE_INVALID = -1; |
| + public static final int SOURCE_MEDIA = 0; |
| + public static final int SOURCE_PRESENTATION = 1; |
| + public static final int SOURCE_MEDIA_FLING = 2; |
| + public static final int SOURCE_MAX = 3; |
| + |
| + public static final String INTENT_EXTRA_NAME = "Launch.NotificationSource"; |
|
gone
2016/04/20 22:17:14
This doesn't have to match the histogram name. Al
Zhiqiang Zhang (Slow)
2016/04/21 16:36:52
Done.
|
| + |
| + private static final LaunchMetrics |
|
gone
2016/04/20 22:17:14
Formatting is super wacky here. can you import La
Zhiqiang Zhang (Slow)
2016/04/21 16:36:53
Done.
|
| + .EnumeratedHistogramSample sNotificationLaunchSourceHistogram = |
| + new LaunchMetrics.EnumeratedHistogramSample("Launch.NotificationSource", SOURCE_MAX); |
| + |
| + /** |
| + * Record the UMA as specified by {@link intent}. The {@link intent} should contain intent extra |
| + * of name {@link INTENT_EXTRA_NAME} indicating the type. |
| + * @param intent The intent starting the activity. |
| + */ |
| + public static void recordSource(Intent intent) { |
| + if (intent == null) return; |
| + int source = intent.getIntExtra(INTENT_EXTRA_NAME, SOURCE_INVALID); |
| + if (source == SOURCE_INVALID) return; |
|
gone
2016/04/20 22:17:14
if (source <= SOURCE_INVALID || source >= SOURCE_M
Zhiqiang Zhang (Slow)
2016/04/21 16:36:52
Done.
|
| + sNotificationLaunchSourceHistogram.record(source); |
| + } |
| +} |