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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUmaTracker.java

Issue 2751913005: NTP: track shown/blocked suggestions notifications (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.content.SharedPreferences; 7 import android.content.SharedPreferences;
8 import android.support.annotation.IntDef; 8 import android.support.annotation.IntDef;
9 import android.support.v4.app.NotificationManagerCompat; 9 import android.support.v4.app.NotificationManagerCompat;
10 10
11 import org.chromium.base.ContextUtils; 11 import org.chromium.base.ContextUtils;
12 import org.chromium.base.library_loader.LibraryLoader; 12 import org.chromium.base.library_loader.LibraryLoader;
13 import org.chromium.base.metrics.RecordHistogram; 13 import org.chromium.base.metrics.RecordHistogram;
14 14
15 import java.lang.annotation.Retention; 15 import java.lang.annotation.Retention;
16 import java.lang.annotation.RetentionPolicy; 16 import java.lang.annotation.RetentionPolicy;
17 17
18 /** 18 /**
19 * Helper class to make tracking notification UMA stats easier for various featu res. Having a 19 * Helper class to make tracking notification UMA stats easier for various featu res. Having a
20 * single entry point here to make more complex tracking easier to add in the fu ture. 20 * single entry point here to make more complex tracking easier to add in the fu ture.
21 */ 21 */
22 public class NotificationUmaTracker { 22 public class NotificationUmaTracker {
23 @Retention(RetentionPolicy.SOURCE) 23 @Retention(RetentionPolicy.SOURCE)
24 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY}) 24 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION ,
25 SYSTEM_NOTIFICATION_TYPE_BOUNDARY})
dgn 2017/03/16 19:32:26 Unrelated: IMO SYSTEM_NOTIFICATION_TYPE_BOUNDARY s
25 public @interface SystemNotificationType {} 26 public @interface SystemNotificationType {}
26 27
27 /* 28 /*
28 * A list of notification types. To add a type to this list please update 29 * A list of notification types. To add a type to this list please update
29 * SystemNotificationType in histograms.xml and make sure to keep this list in sync. Additions 30 * SystemNotificationType in histograms.xml and make sure to keep this list in sync. Additions
30 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam e over time. 31 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam e over time.
31 * 32 *
32 * A SystemNotificationType value can also be saved in shared preferences. 33 * A SystemNotificationType value can also be saved in shared preferences.
33 */ 34 */
34 public static final int DOWNLOAD_FILES = 0; 35 public static final int DOWNLOAD_FILES = 0;
35 public static final int DOWNLOAD_PAGES = 1; 36 public static final int DOWNLOAD_PAGES = 1;
36 public static final int CLOSE_INCOGNITO = 2; 37 public static final int CLOSE_INCOGNITO = 2;
38 public static final int CONTENT_SUGGESTION = 3;
37 39
38 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 3; 40 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 4;
39 41
40 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY = 42 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY =
41 "NotificationUmaTracker.LastShownNotificationType"; 43 "NotificationUmaTracker.LastShownNotificationType";
42 44
43 private static class LazyHolder { 45 private static class LazyHolder {
44 private static final NotificationUmaTracker INSTANCE = new NotificationU maTracker(); 46 private static final NotificationUmaTracker INSTANCE = new NotificationU maTracker();
45 } 47 }
46 48
47 /** Cached objects. */ 49 /** Cached objects. */
48 private final SharedPreferences mSharedPreferences; 50 private final SharedPreferences mSharedPreferences;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (lastType == -1) return; 85 if (lastType == -1) return;
84 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply (); 86 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply ();
85 87
86 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType) ; 88 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType) ;
87 } 89 }
88 90
89 private static void recordHistogram(String name, @SystemNotificationType int type) { 91 private static void recordHistogram(String name, @SystemNotificationType int type) {
90 if (!LibraryLoader.isInitialized()) return; 92 if (!LibraryLoader.isInitialized()) return;
91 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY); 93 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY);
92 } 94 }
93 } 95 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698