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

Unified Diff: chrome/browser/notifications/notification_ui_manager_android.cc

Issue 826883003: Android Notifications should be closable without a delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a-serialize-pickle
Patch Set: Created 5 years, 11 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/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;
}

Powered by Google App Engine
This is Rietveld 408576698