Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java |
index 6635ecca72c969545d3f25e12d52abd9980284de..f3c79fc3f9cf5fd62a95362690e130ffcbc9a165 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java |
@@ -4,6 +4,7 @@ |
package org.chromium.chrome.browser.notifications; |
+import android.annotation.SuppressLint; |
import android.annotation.TargetApi; |
import android.app.Notification; |
import android.app.PendingIntent; |
@@ -429,6 +430,21 @@ public abstract class NotificationBuilderBase { |
} |
} |
+ /** |
+ * Sets the notification group for the builder, determined by the origin provided. |
+ * Note, after this notification is built and posted, a further summary notification must be |
+ * posted for notifications in the group to appear grouped in the notification shade. |
+ */ |
+ @SuppressLint("NewApi") // For setGroup |
+ static void setGroupOnBuilder(Notification.Builder builder, CharSequence origin) { |
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH || origin == null) return; |
+ builder.setGroup(NotificationConstants.GROUP_WEB_PREFIX + origin); |
+ // TODO(crbug.com/674927) Post a group summary notification. |
+ // Notifications with the same group will only actually be stacked if we post a group |
+ // summary notification. Calling setGroup at least prevents them being autobundled with |
+ // all Chrome notifications on N though (see crbug.com/674015). |
+ } |
+ |
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH) // For Notification.Action.Builder |
@SuppressWarnings("deprecation") // For Builder(int, CharSequence, PendingIntent) |
private static Notification.Action.Builder getActionBuilder(Action action) { |