Index: chrome/browser/notifications/notification_ui_manager_android.cc |
diff --git a/chrome/browser/notifications/notification_ui_manager_android.cc b/chrome/browser/notifications/notification_ui_manager_android.cc |
index 270b330da9133cc96313c56bd75732f5e6ea2217..f73c01391edd559fc5dc74753ad7ebf8547934e6 100644 |
--- a/chrome/browser/notifications/notification_ui_manager_android.cc |
+++ b/chrome/browser/notifications/notification_ui_manager_android.cc |
@@ -144,6 +144,7 @@ bool NotificationUIManagerAndroid::OnNotificationClicked( |
JNIEnv* env, |
jobject java_object, |
jstring notification_id, |
+ jint platform_id, |
jbyteArray serialized_notification_data) { |
std::string id = ConvertJavaStringToUTF8(env, notification_id); |
@@ -176,6 +177,9 @@ bool NotificationUIManagerAndroid::OnNotificationClicked( |
return false; |
} |
+ // Store the platform Id of this notification so that it can be closed. |
+ platform_notifications_[id] = platform_id; |
+ |
PlatformNotificationServiceImpl* service = |
PlatformNotificationServiceImpl::GetInstance(); |
@@ -304,10 +308,24 @@ bool NotificationUIManagerAndroid::CancelById(const std::string& delegate_id, |
ProfileNotification::GetProfileNotificationId(delegate_id, profile_id); |
ProfileNotification* profile_notification = |
FindProfileNotification(profile_notification_id); |
- if (!profile_notification) |
+ if (profile_notification) { |
+ RemoveProfileNotification(profile_notification); |
+ return true; |
+ } |
+ |
+ // On Android, it's still possible that the notification can be closed in case |
+ // the platform Id is known, even if no delegate exists. This happens when the |
+ // browser process is started because of interaction with a Notification. |
+ auto platform_id_iter = platform_notifications_.find(delegate_id); |
+ if (platform_id_iter == platform_notifications_.end()) |
dewittj
2015/01/08 01:06:17
Can this code be consolidated with the common code
Peter Beverloo
2015/01/08 19:28:19
Oops, missed that! Thanks and done :-)
|
return false; |
- RemoveProfileNotification(profile_notification); |
+ Java_NotificationUIManager_closeNotification(AttachCurrentThread(), |
+ java_object_.obj(), |
+ platform_id_iter->second); |
+ |
+ platform_notifications_.erase(platform_id_iter); |
+ |
return true; |
} |