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

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

Issue 1026853002: Integrate the notification database with the normal code path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-ConfirmShow
Patch Set: Created 5 years, 9 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/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";
johnme 2015/04/02 17:21:06 Did this use to work before? Would it be hard to k
Peter Beverloo 2015/04/07 17:46:11 This is working now.
+#endif
+ return;
+ }
+
GetNotificationUIManager()->CancelById(
- persistent_notification_id, NotificationUIManager::GetProfileID(profile));
+ iter->second, NotificationUIManager::GetProfileID(profile));
+
+ persistent_notifications_.erase(iter);
}
Notification PlatformNotificationServiceImpl::CreateNotificationFromData(

Powered by Google App Engine
This is Rietveld 408576698