Index: chrome/browser/notifications/platform_notification_service_impl.cc |
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc |
index 8b8136942c41f37b3988226f8d5eb8a3a393cb3c..c698e375a8d244e8d18515b67ec6adfee48a5871 100644 |
--- a/chrome/browser/notifications/platform_notification_service_impl.cc |
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc |
@@ -36,6 +36,10 @@ |
#include "extensions/common/permissions/permissions_data.h" |
#endif |
+#if defined(OS_ANDROID) |
+#include "base/strings/string_number_conversions.h" |
+#endif |
+ |
using content::BrowserThread; |
using message_center::NotifierId; |
@@ -59,25 +63,6 @@ PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() |
PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} |
-void PlatformNotificationServiceImpl::OnPersistentNotificationClick( |
- content::BrowserContext* browser_context, |
- int64 service_worker_registration_id, |
- const std::string& notification_id, |
- const GURL& origin, |
- const content::PlatformNotificationData& notification_data, |
- const base::Callback<void(content::PersistentNotificationStatus)>& |
- callback) const { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- content::NotificationEventDispatcher::GetInstance() |
- ->DispatchNotificationClickEvent( |
- browser_context, |
- origin, |
- service_worker_registration_id, |
- notification_id, |
- notification_data, |
- callback); |
-} |
- |
blink::WebNotificationPermission |
PlatformNotificationServiceImpl::CheckPermissionOnUIThread( |
content::BrowserContext* browser_context, |
@@ -218,7 +203,7 @@ void PlatformNotificationServiceImpl::DisplayNotification( |
void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
content::BrowserContext* browser_context, |
- int64 service_worker_registration_id, |
+ int64_t persistent_notification_id, |
const GURL& origin, |
const SkBitmap& icon, |
const content::PlatformNotificationData& notification_data) { |
@@ -228,14 +213,15 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
DCHECK(profile); |
PersistentNotificationDelegate* delegate = new PersistentNotificationDelegate( |
- browser_context, |
- service_worker_registration_id, |
- origin, |
- notification_data); |
+ browser_context, persistent_notification_id, origin); |
Notification notification = CreateNotificationFromData( |
profile, origin, icon, notification_data, delegate); |
+ // TODO(peter): Remove this mapping when we have reliable id generation for |
+ // the message_center::Notification objects. |
+ persistent_notifications_[persistent_notification_id] = notification.id(); |
+ |
GetNotificationUIManager()->Add(notification, profile); |
profile->GetHostContentSettingsMap()->UpdateLastUsage( |
@@ -244,14 +230,30 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
void PlatformNotificationServiceImpl::ClosePersistentNotification( |
content::BrowserContext* browser_context, |
- const std::string& persistent_notification_id) { |
+ int64_t persistent_notification_id) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Profile* profile = Profile::FromBrowserContext(browser_context); |
DCHECK(profile); |
+#if defined(OS_ANDROID) |
+ // TODO(peter): Remove this conversion when the notification ids are being |
+ // generated by the caller of this method. |
+ std::string textual_persistent_notification_id = |
+ base::Int64ToString(persistent_notification_id); |
GetNotificationUIManager()->CancelById( |
johnme
2015/04/08 17:33:32
Eww eww eww. CancelById takes a delegate_id (rando
Peter Beverloo
2015/04/08 18:57:48
This is a strictly temporary measure which will go
johnme
2015/04/09 10:06:11
Fine. Added a task to the spreadsheet.
|
- persistent_notification_id, NotificationUIManager::GetProfileID(profile)); |
+ textual_persistent_notification_id, |
+ NotificationUIManager::GetProfileID(profile)); |
+#else |
+ auto iter = persistent_notifications_.find(persistent_notification_id); |
+ if (iter == persistent_notifications_.end()) |
+ return; |
+ |
+ GetNotificationUIManager()->CancelById( |
+ iter->second, NotificationUIManager::GetProfileID(profile)); |
+ |
+ persistent_notifications_.erase(iter); |
+#endif // defined(OS_ANDROID) |
} |
Notification PlatformNotificationServiceImpl::CreateNotificationFromData( |