| Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderFactory.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderFactory.java
|
| index 609be47354a260390696b7334e5fbc25332087ce..5b00acf333bd0512475f8064250d355ef00507b8 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderFactory.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderFactory.java
|
| @@ -4,6 +4,8 @@
|
|
|
| package org.chromium.chrome.browser.notifications;
|
|
|
| +import android.annotation.SuppressLint;
|
| +import android.app.NotificationManager;
|
| import android.content.Context;
|
|
|
| import org.chromium.base.BuildInfo;
|
| @@ -20,26 +22,29 @@ public class NotificationBuilderFactory {
|
| *
|
| * TODO(crbug.com/704152) Remove this once we've updated to revision 26 of the support library.
|
| * Then we can use NotificationCompat.Builder and set the channel directly everywhere.
|
| + * Although we will still need to ensure the channel is always initialized first.
|
| *
|
| * @param preferCompat true if a NotificationCompat.Builder is preferred.
|
| * A Notification.Builder will be used regardless on Android O.
|
| - * @param channelId The ID of the channel the notification should be posted to.
|
| - * @param channelName The name of the channel the notification should be posted to.
|
| - * Used to create the channel if a channel with channelId does not exist.
|
| - * @param channelGroupId The ID of the channel group the channel belongs to. Used when creating
|
| - * the channel if a channel with channelId does not exist.
|
| - * @param channelGroupName The name of the channel group the channel belongs to.
|
| - * Used to create the channel group if a channel group with
|
| - * channelGroupId does not already exist.
|
| + * @param channelId The ID of the channel the notification should be posted to. This channel
|
| + * will be created if it did not already exist. Must be a known channel within
|
| + * {@link ChannelsInitializer#ensureInitialized(String)}.
|
| */
|
| - public static ChromeNotificationBuilder createChromeNotificationBuilder(boolean preferCompat,
|
| - String channelId, String channelName, String channelGroupId, String channelGroupName) {
|
| + public static ChromeNotificationBuilder createChromeNotificationBuilder(
|
| + boolean preferCompat, @ChannelsInitializer.ChannelId String channelId) {
|
| Context context = ContextUtils.getApplicationContext();
|
| if (BuildInfo.isAtLeastO()) {
|
| - return new NotificationBuilderForO(ContextUtils.getApplicationContext(), channelId,
|
| - channelName, channelGroupId, channelGroupName);
|
| + return createNotificationBuilderForO(channelId, context);
|
| }
|
| return preferCompat ? new NotificationCompatBuilder(context)
|
| : new NotificationBuilder(context);
|
| }
|
| +
|
| + @SuppressLint("NewApi") // for Context.getSystemService(Class)
|
| + private static ChromeNotificationBuilder createNotificationBuilderForO(
|
| + @ChannelsInitializer.ChannelId String channelId, Context context) {
|
| + return new NotificationBuilderForO(context, channelId,
|
| + new ChannelsInitializer(new NotificationManagerProxyImpl(
|
| + context.getSystemService(NotificationManager.class))));
|
| + }
|
| }
|
|
|