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

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

Issue 965573002: Implement support for silent notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
index 7665c5f0c9f6f14e7a65b8c499d594be4777e381..c2100afba57ddf21f1b32eceef476c74381a5808 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java
@@ -229,12 +229,13 @@ public class NotificationUIManager {
* @param icon Icon to be displayed in the notification. When this isn't a valid Bitmap, a
* default icon will be generated instead.
* @param origin Full text of the origin, including the protocol, owning this notification.
+ * @param silent Whether the default sound, vibration and lights should be suppressed.
* @param notificationData Serialized data associated with the notification.
* @return The id using which the notification can be identified.
*/
@CalledByNative
private int displayNotification(String tag, String notificationId, String title, String body,
- Bitmap icon, String origin, byte[] notificationData) {
+ Bitmap icon, String origin, boolean silent, byte[] notificationData) {
if (icon == null || icon.getWidth() == 0) {
icon = getIconGenerator().generateIconForUrl(origin, true);
}
@@ -255,7 +256,6 @@ public class NotificationUIManager {
.setStyle(new NotificationCompat.BigTextStyle().bigText(body))
.setLargeIcon(icon)
.setSmallIcon(R.drawable.notification_badge)
- .setDefaults(Notification.DEFAULT_ALL)
.setContentIntent(getPendingIntent(
NotificationConstants.ACTION_CLICK_NOTIFICATION,
notificationId, mLastNotificationId, notificationData))
@@ -267,6 +267,10 @@ public class NotificationUIManager {
pendingSettingsIntent)
.setSubText(origin);
+ // Use the system's default ringtone, vibration and indicator lights unless the notification
+ // has been marked as being silent, for example because it's low priority.
+ if (!silent) notificationBuilder.setDefaults(Notification.DEFAULT_ALL);
+
String platformTag = makePlatformTag(tag, mLastNotificationId, origin);
mNotificationManager.notify(platformTag, mLastNotificationId, notificationBuilder.build());
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationUIManagerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698