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 454e21de5bbda0abb290ee8cd0ddddadcdf61519..dd411bea3752e7397a2ea3a8c7c81b6c8f51045c 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 |
@@ -125,19 +125,28 @@ public class NotificationUIManager { |
String notificationId = intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_ID); |
if (NotificationConstants.ACTION_CLICK_NOTIFICATION.equals(intent.getAction())) { |
- return sInstance.onNotificationClicked(notificationId); |
- } else if (NotificationConstants.ACTION_CLOSE_NOTIFICATION.equals(intent.getAction())) { |
+ if (!intent.hasExtra(NotificationConstants.EXTRA_NOTIFICATION_DATA)) |
Miguel Garcia
2015/01/07 11:07:40
nit: java code always uses {} even for one liners
Michael van Ouwerkerk
2015/01/07 13:39:10
Wanna log something here?
Peter Beverloo
2015/01/07 15:16:29
Done.
Peter Beverloo
2015/01/07 15:16:30
Done.
|
+ return false; |
+ |
+ byte[] notificationData = |
+ intent.getByteArrayExtra(NotificationConstants.EXTRA_NOTIFICATION_DATA); |
+ return sInstance.onNotificationClicked(notificationId, notificationData); |
+ } |
+ |
+ if (NotificationConstants.ACTION_CLOSE_NOTIFICATION.equals(intent.getAction())) { |
return sInstance.onNotificationClosed(notificationId); |
- } else { |
- Log.e(TAG, "Unrecognized Notification action: " + intent.getAction()); |
- return false; |
} |
+ |
+ Log.e(TAG, "Unrecognized Notification action: " + intent.getAction()); |
+ return false; |
} |
- private PendingIntent getPendingIntent(String notificationId, int platformId, String action) { |
+ private PendingIntent getPendingIntent(String notificationId, int platformId, |
+ byte[] notificationData, String action) { |
Michael van Ouwerkerk
2015/01/07 13:39:10
nit: it seems action would be better as the first
Peter Beverloo
2015/01/07 15:16:29
Done.
|
Intent intent = new Intent(action); |
intent.setClass(mAppContext, NotificationService.Receiver.class); |
intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_ID, notificationId); |
+ intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_DATA, notificationData); |
return PendingIntent.getBroadcast(mAppContext, platformId, intent, |
PendingIntent.FLAG_UPDATE_CURRENT); |
@@ -153,11 +162,12 @@ 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 notificationData Serialized data associated with the notification. |
* @return The id using which the notification can be identified. |
*/ |
@CalledByNative |
private int displayNotification(String notificationId, String title, String body, Bitmap icon, |
- String origin) { |
+ String origin, byte[] notificationData) { |
if (icon == null || icon.getWidth() == 0) { |
icon = getIconGenerator().generateIconForUrl(origin); |
} |
@@ -169,10 +179,10 @@ public class NotificationUIManager { |
.setLargeIcon(icon) |
.setSmallIcon(R.drawable.notification_badge) |
.setContentIntent(getPendingIntent( |
- notificationId, mLastNotificationId, |
+ notificationId, mLastNotificationId, notificationData, |
NotificationConstants.ACTION_CLICK_NOTIFICATION)) |
.setDeleteIntent(getPendingIntent( |
- notificationId, mLastNotificationId, |
+ notificationId, mLastNotificationId, notificationData, |
NotificationConstants.ACTION_CLOSE_NOTIFICATION)) |
.setSubText(origin); |
@@ -219,8 +229,9 @@ public class NotificationUIManager { |
mNotificationManager.cancel(platformId); |
} |
- private boolean onNotificationClicked(String notificationId) { |
- return nativeOnNotificationClicked(mNativeNotificationManager, notificationId); |
+ private boolean onNotificationClicked(String notificationId, byte[] notificationData) { |
+ return nativeOnNotificationClicked( |
+ mNativeNotificationManager, notificationId, notificationData); |
} |
private boolean onNotificationClosed(String notificationId) { |
@@ -230,7 +241,8 @@ public class NotificationUIManager { |
private static native void nativeInitializeNotificationUIManager(); |
private native boolean nativeOnNotificationClicked( |
- long nativeNotificationUIManagerAndroid, String notificationId); |
+ long nativeNotificationUIManagerAndroid, String notificationId, |
+ byte[] notificationData); |
private native boolean nativeOnNotificationClosed( |
long nativeNotificationUIManagerAndroid, String notificationId); |
} |