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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java

Issue 2922443002: [Web apks] Stop setting channels on web apk notifications (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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
index bbb20d2782af7fd5038af5b5d2fd61124980c193..2495103e4660dd8d8e0cbb7a5484fd1393599055 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
@@ -513,9 +513,9 @@ public class NotificationPlatformBridge {
incognito, tag, webApkPackage, -1 /* actionIndex */);
boolean hasImage = image != null;
-
+ boolean forWebApk = !webApkPackage.isEmpty();
NotificationBuilderBase notificationBuilder =
- createNotificationBuilder(context, hasImage)
+ createNotificationBuilder(context, forWebApk, hasImage)
.setTitle(title)
.setBody(body)
.setImage(image)
@@ -558,7 +558,10 @@ public class NotificationPlatformBridge {
notificationBuilder.setVibrate(makeVibrationPattern(vibrationPattern));
String platformTag = makePlatformTag(notificationId, origin, tag);
- if (webApkPackage.isEmpty()) {
+ if (forWebApk) {
+ WebApkNotificationClient.notifyNotification(
+ webApkPackage, notificationBuilder, platformTag, PLATFORM_ID);
+ } else {
// Set up a pending intent for going to the settings screen for |origin|.
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(
context, SingleWebsitePreferences.class.getName());
@@ -587,17 +590,19 @@ public class NotificationPlatformBridge {
mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBuilder.build());
NotificationUmaTracker.getInstance().onNotificationShown(
NotificationUmaTracker.SITES, ChannelDefinitions.CHANNEL_ID_SITES);
- } else {
- WebApkNotificationClient.notifyNotification(
- webApkPackage, notificationBuilder, platformTag, PLATFORM_ID);
}
}
- private NotificationBuilderBase createNotificationBuilder(Context context, boolean hasImage) {
+ private NotificationBuilderBase createNotificationBuilder(
+ Context context, boolean forWebApk, boolean hasImage) {
+ // Don't set a channelId for web apk notifications because the channel won't be
+ // initialized for the web apk and it will crash on notify - see crbug.com/727178.
+ // (It's okay to not set a channel on them because web apks don't target O yet.)
+ String channelId = forWebApk ? null : ChannelDefinitions.CHANNEL_ID_SITES;
if (useCustomLayouts(hasImage)) {
- return new CustomNotificationBuilder(context);
+ return new CustomNotificationBuilder(context, channelId);
}
- return new StandardNotificationBuilder(context);
+ return new StandardNotificationBuilder(context, channelId);
}
/**

Powered by Google App Engine
This is Rietveld 408576698