Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java |
index 040d7881d4ac5fd996636a08e0de21689e38fc1a..bfece56a43c9a77a906d897bd9477810edaa6f3c 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java |
@@ -35,6 +35,11 @@ public class ChannelsInitializer { |
// Map defined in static inner class so it's only initialized lazily. |
@TargetApi(Build.VERSION_CODES.N) // for NotificationManager.IMPORTANCE_* constants |
private static class PredefinedChannels { |
+ /** |
+ * The set of predefined channels to be initialized on startup. |
+ * {@link ChannelsUpdater#CHANNELS_VERSION} must be incremented every time an entry is |
Peter Beverloo
2017/04/11 19:08:29
Maybe consider making this a static member of Chan
awdf
2017/04/12 13:58:15
Done.
|
+ * modified, removed or added to this map. |
+ */ |
private static final Map<String, Channel> MAP; |
static { |
Map<String, Channel> map = new HashMap<>(); |
@@ -68,6 +73,18 @@ public class ChannelsInitializer { |
mNotificationManager = notificationManagerProxy; |
} |
+ public void initializeStartupChannels() { |
+ for (@ChannelId String channelId : PredefinedChannels.MAP.keySet()) { |
+ ensureInitialized(channelId); |
+ } |
+ } |
+ |
+ void deleteAllChannels() { |
+ for (String channelId : mNotificationManager.getNotificationChannelIds()) { |
+ mNotificationManager.deleteNotificationChannel(channelId); |
+ } |
+ } |
+ |
/** |
* Ensures the given channel has been created on the notification manager so a notification |
* can be safely posted to it. This should only be used for channels that are predefined in |
@@ -93,7 +110,7 @@ public class ChannelsInitializer { |
*/ |
public static class Channel { |
@ChannelId |
- final String mId; |
+ public final String mId; |
final int mNameResId; |
final int mImportance; |
@ChannelGroupId |