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

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

Issue 2876863002: [Android] Show notification for opening new tab in background of Browser Actions (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 unified diff | Download patch
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.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 11 matching lines...) Expand all
22 import java.lang.reflect.Method; 22 import java.lang.reflect.Method;
23 23
24 /** 24 /**
25 * Helper class to make tracking notification UMA stats easier for various featu res. Having a 25 * Helper class to make tracking notification UMA stats easier for various featu res. Having a
26 * single entry point here to make more complex tracking easier to add in the fu ture. 26 * single entry point here to make more complex tracking easier to add in the fu ture.
27 */ 27 */
28 public class NotificationUmaTracker { 28 public class NotificationUmaTracker {
29 private static final String TAG = "NotifsUMATracker"; 29 private static final String TAG = "NotifsUMATracker";
30 @Retention(RetentionPolicy.SOURCE) 30 @Retention(RetentionPolicy.SOURCE)
31 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION , MEDIA_CAPTURE, 31 @IntDef({DOWNLOAD_FILES, DOWNLOAD_PAGES, CLOSE_INCOGNITO, CONTENT_SUGGESTION , MEDIA_CAPTURE,
32 PHYSICAL_WEB, MEDIA, SITES, SYNC, SYSTEM_NOTIFICATION_TYPE_BOUNDARY} ) 32 PHYSICAL_WEB, MEDIA, SITES, SYNC, BROWSER_ACTIONS, SYSTEM_NOTIFICATI ON_TYPE_BOUNDARY})
David Trainor- moved to gerrit 2017/05/11 20:26:52 Needto update histograms.xml as well. See the com
ltian 2017/05/11 22:29:53 Done.
33 public @interface SystemNotificationType {} 33 public @interface SystemNotificationType {}
34 34
35 /* 35 /*
36 * A list of notification types. To add a type to this list please update 36 * A list of notification types. To add a type to this list please update
37 * SystemNotificationType in histograms.xml and make sure to keep this list in sync. Additions 37 * SystemNotificationType in histograms.xml and make sure to keep this list in sync. Additions
38 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam e over time. 38 * should be treated as APPEND ONLY to keep the UMA metric semantics the sam e over time.
39 * 39 *
40 * A SystemNotificationType value can also be saved in shared preferences. 40 * A SystemNotificationType value can also be saved in shared preferences.
41 */ 41 */
42 public static final int DOWNLOAD_FILES = 0; 42 public static final int DOWNLOAD_FILES = 0;
43 43
44 public static final int DOWNLOAD_PAGES = 1; 44 public static final int DOWNLOAD_PAGES = 1;
45 45
46 public static final int CLOSE_INCOGNITO = 2; 46 public static final int CLOSE_INCOGNITO = 2;
47 47
48 public static final int CONTENT_SUGGESTION = 3; 48 public static final int CONTENT_SUGGESTION = 3;
49 public static final int MEDIA_CAPTURE = 4; 49 public static final int MEDIA_CAPTURE = 4;
50 public static final int PHYSICAL_WEB = 5; 50 public static final int PHYSICAL_WEB = 5;
51 public static final int MEDIA = 6; 51 public static final int MEDIA = 6;
52 public static final int SITES = 7; 52 public static final int SITES = 7;
53 public static final int SYNC = 8; 53 public static final int SYNC = 8;
54 public static final int BROWSER_ACTIONS = 9;
54 55
55 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 9; 56 private static final int SYSTEM_NOTIFICATION_TYPE_BOUNDARY = 10;
56 57
57 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY = 58 private static final String LAST_SHOWN_NOTIFICATION_TYPE_KEY =
58 "NotificationUmaTracker.LastShownNotificationType"; 59 "NotificationUmaTracker.LastShownNotificationType";
59 60
60 private static class LazyHolder { 61 private static class LazyHolder {
61 private static final NotificationUmaTracker INSTANCE = new NotificationU maTracker(); 62 private static final NotificationUmaTracker INSTANCE = new NotificationU maTracker();
62 } 63 }
63 64
64 /** Cached objects. */ 65 /** Cached objects. */
65 private final SharedPreferences mSharedPreferences; 66 private final SharedPreferences mSharedPreferences;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply (); 134 mSharedPreferences.edit().remove(LAST_SHOWN_NOTIFICATION_TYPE_KEY).apply ();
134 135
135 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType) ; 136 recordHistogram("Mobile.SystemNotification.BlockedAfterShown", lastType) ;
136 } 137 }
137 138
138 private static void recordHistogram(String name, @SystemNotificationType int type) { 139 private static void recordHistogram(String name, @SystemNotificationType int type) {
139 if (!LibraryLoader.isInitialized()) return; 140 if (!LibraryLoader.isInitialized()) return;
140 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY); 141 RecordHistogram.recordEnumeratedHistogram(name, type, SYSTEM_NOTIFICATIO N_TYPE_BOUNDARY);
141 } 142 }
142 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698