| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.notifications; | 5 package org.chromium.chrome.browser.notifications; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.app.NotificationManager; | 8 import android.app.NotificationManager; |
| 9 import android.content.SharedPreferences; | 9 import android.content.SharedPreferences; |
| 10 import android.support.annotation.IntDef; | 10 import android.support.annotation.IntDef; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import java.lang.reflect.Method; | 23 import java.lang.reflect.Method; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Helper class to make tracking notification UMA stats easier for various featu
res. Having a | 26 * Helper class to make tracking notification UMA stats easier for various featu
res. Having a |
| 27 * single entry point here to make more complex tracking easier to add in the fu
ture. | 27 * single entry point here to make more complex tracking easier to add in the fu
ture. |
| 28 */ | 28 */ |
| 29 public class NotificationUmaTracker { | 29 public class NotificationUmaTracker { |
| 30 private static final String TAG = "NotifsUMATracker"; | 30 private static final String TAG = "NotifsUMATracker"; |
| 31 @Retention(RetentionPolicy.SOURCE) | 31 @Retention(RetentionPolicy.SOURCE) |
| 32 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION
, MEDIA_CAPTURE, | 32 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION
, MEDIA_CAPTURE, |
| 33 PHYSICAL_WEB, MEDIA, SITES, SYNC, WEBAPK, SYSTEM_NOTIFICATION_TYPE_B
OUNDARY}) | 33 PHYSICAL_WEB, MEDIA, SITES, SYNC, WEBAPK, BROWSER_ACTIONS, |
| 34 SYSTEM_NOTIFICATION_TYPE_BOUNDARY}) |
| 34 public @interface SystemNotificationType {} | 35 public @interface SystemNotificationType {} |
| 35 | 36 |
| 36 /* | 37 /* |
| 37 * A list of notification types. To add a type to this list please update | 38 * A list of notification types. To add a type to this list please update |
| 38 * SystemNotificationType in histograms.xml and make sure to keep this list
in sync. Additions | 39 * SystemNotificationType in histograms.xml and make sure to keep this list
in sync. Additions |
| 39 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam
e over time. | 40 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam
e over time. |
| 40 * | 41 * |
| 41 * A SystemNotificationType value can also be saved in shared preferences. | 42 * A SystemNotificationType value can also be saved in shared preferences. |
| 42 */ | 43 */ |
| 43 public static final int DOWNLOAD_FILES = 0; | 44 public static final int DOWNLOAD_FILES = 0; |
| 44 | 45 |
| 45 public static final int DOWNLOAD_PAGES = 1; | 46 public static final int DOWNLOAD_PAGES = 1; |
| 46 | 47 |
| 47 public static final int CLOSE_INCOGNITO = 2; | 48 public static final int CLOSE_INCOGNITO = 2; |
| 48 | 49 |
| 49 public static final int CONTENT_SUGGESTION = 3; | 50 public static final int CONTENT_SUGGESTION = 3; |
| 50 public static final int MEDIA_CAPTURE = 4; | 51 public static final int MEDIA_CAPTURE = 4; |
| 51 public static final int PHYSICAL_WEB = 5; | 52 public static final int PHYSICAL_WEB = 5; |
| 52 public static final int MEDIA = 6; | 53 public static final int MEDIA = 6; |
| 53 public static final int SITES = 7; | 54 public static final int SITES = 7; |
| 54 public static final int SYNC = 8; | 55 public static final int SYNC = 8; |
| 55 public static final int WEBAPK = 9; | 56 public static final int WEBAPK = 9; |
| 57 public static final int BROWSER_ACTIONS = 10; |
| 56 | 58 |
| 57 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 10; | 59 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 11; |
| 58 | 60 |
| 59 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY = | 61 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY = |
| 60 "NotificationUmaTracker.LastShownNotificationType"; | 62 "NotificationUmaTracker.LastShownNotificationType"; |
| 61 | 63 |
| 62 private static class LazyHolder { | 64 private static class LazyHolder { |
| 63 private static final NotificationUmaTracker INSTANCE = new NotificationU
maTracker(); | 65 private static final NotificationUmaTracker INSTANCE = new NotificationU
maTracker(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 /** Cached objects. */ | 68 /** Cached objects. */ |
| 67 private final SharedPreferences mSharedPreferences; | 69 private final SharedPreferences mSharedPreferences; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply
(); | 137 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply
(); |
| 136 | 138 |
| 137 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType)
; | 139 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType)
; |
| 138 } | 140 } |
| 139 | 141 |
| 140 private static void recordHistogram(String name, @SystemNotificationType int
type) { | 142 private static void recordHistogram(String name, @SystemNotificationType int
type) { |
| 141 if (!LibraryLoader.isInitialized()) return; | 143 if (!LibraryLoader.isInitialized()) return; |
| 142 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO
N_TYPE_BOUNDARY); | 144 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO
N_TYPE_BOUNDARY); |
| 143 } | 145 } |
| 144 } | 146 } |
| OLD | NEW |