| 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..bce7a357724ef76d30282b9300d744d64d232d5b 100644
|
| --- a/chrome/browser/notifications/platform_notification_service_impl.cc
|
| +++ b/chrome/browser/notifications/platform_notification_service_impl.cc
|
| @@ -61,20 +61,16 @@ PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
|
|
|
| void PlatformNotificationServiceImpl::OnPersistentNotificationClick(
|
| content::BrowserContext* browser_context,
|
| - int64 service_worker_registration_id,
|
| - const std::string& notification_id,
|
| + int64_t persistent_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,
|
| + persistent_notification_id,
|
| origin,
|
| - service_worker_registration_id,
|
| - notification_id,
|
| - notification_data,
|
| callback);
|
| }
|
|
|
| @@ -218,7 +214,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 +224,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 +241,24 @@ 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);
|
|
|
| + auto iter = persistent_notifications_.find(persistent_notification_id);
|
| + if (iter == persistent_notifications_.end()) {
|
| +#if defined(OS_ANDROID)
|
| + DLOG(ERROR) << "Implement Android behavior";
|
| +#endif
|
| + return;
|
| + }
|
| +
|
| GetNotificationUIManager()->CancelById(
|
| - persistent_notification_id, NotificationUIManager::GetProfileID(profile));
|
| + iter->second, NotificationUIManager::GetProfileID(profile));
|
| +
|
| + persistent_notifications_.erase(iter);
|
| }
|
|
|
| Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
|
|
|