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

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, 8 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 5b0608c155a0a2065aad0aefb5f6124dc46a1d5d..4828551434b1e657d49be6344d0da1b6c9fb675b 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;
@@ -61,20 +65,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 +218,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 +228,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 +245,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(
- 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
}
Notification PlatformNotificationServiceImpl::CreateNotificationFromData(

Powered by Google App Engine
This is Rietveld 408576698