Chromium Code Reviews| 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 a68fd7a57bbb1fe0662424f69a697fda92d40b97..78d1523a4b74f8baa7bc70a14267ff953b187456 100644 |
| --- a/chrome/browser/notifications/platform_notification_service_impl.cc |
| +++ b/chrome/browser/notifications/platform_notification_service_impl.cc |
| @@ -19,6 +19,8 @@ |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/desktop_notification_delegate.h" |
| #include "content/public/browser/notification_event_dispatcher.h" |
| +#include "content/public/browser/platform_notification_context.h" |
| +#include "content/public/browser/storage_partition.h" |
| #include "content/public/common/platform_notification_data.h" |
| #include "net/base/net_util.h" |
| #include "ui/message_center/notifier_settings.h" |
| @@ -40,11 +42,20 @@ |
| #include "base/strings/string_number_conversions.h" |
| #endif |
| +using content::BrowserContext; |
| using content::BrowserThread; |
| +using content::PlatformNotificationContext; |
| using message_center::NotifierId; |
| namespace { |
| +// Callback to provide when deleting the data associated with persistent Web |
| +// Notifications from the notification database. |
| +void OnPersistentNotificationDataDeleted(bool success) { |
| + // TODO(peter): Record UMA for notification deletion requests created by the |
| + // PlatformNotificationService. |
| +} |
| + |
| void CancelNotification(const std::string& id, ProfileID profile_id) { |
| PlatformNotificationServiceImpl::GetInstance() |
| ->GetNotificationUIManager()->CancelById(id, profile_id); |
| @@ -64,7 +75,7 @@ PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() |
| PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} |
| void PlatformNotificationServiceImpl::OnPersistentNotificationClick( |
| - content::BrowserContext* browser_context, |
| + BrowserContext* browser_context, |
| int64_t persistent_notification_id, |
| const GURL& origin, |
| const base::Callback<void(content::PersistentNotificationStatus)>& |
| @@ -78,9 +89,28 @@ void PlatformNotificationServiceImpl::OnPersistentNotificationClick( |
| callback); |
| } |
| +void PlatformNotificationServiceImpl::OnPersistentNotificationClose( |
| + BrowserContext* browser_context, |
| + int64_t persistent_notification_id, |
| + const GURL& origin) const { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + PlatformNotificationContext* context = |
| + BrowserContext::GetStoragePartitionForSite(browser_context, origin) |
| + ->GetPlatformNotificationContext(); |
| + |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, |
| + FROM_HERE, |
| + base::Bind(&PlatformNotificationContext::DeleteNotificationData, |
| + base::Unretained(context), |
|
johnme
2015/04/10 11:54:39
This doesn't look safe. Possible solution: move th
dewittj
2015/04/10 17:18:30
Other classes hanging off of StoragePartition use
Peter Beverloo
2015/04/20 16:47:20
Done.
|
| + persistent_notification_id, |
| + origin, |
| + base::Bind(&OnPersistentNotificationDataDeleted))); |
| +} |
| + |
| blink::WebNotificationPermission |
| PlatformNotificationServiceImpl::CheckPermissionOnUIThread( |
| - content::BrowserContext* browser_context, |
| + BrowserContext* browser_context, |
| const GURL& origin, |
| int render_process_id) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| @@ -190,7 +220,7 @@ PlatformNotificationServiceImpl::CheckPermissionOnIOThread( |
| } |
| void PlatformNotificationServiceImpl::DisplayNotification( |
| - content::BrowserContext* browser_context, |
| + BrowserContext* browser_context, |
| const GURL& origin, |
| const SkBitmap& icon, |
| const content::PlatformNotificationData& notification_data, |
| @@ -217,7 +247,7 @@ void PlatformNotificationServiceImpl::DisplayNotification( |
| } |
| void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
| - content::BrowserContext* browser_context, |
| + BrowserContext* browser_context, |
| int64_t persistent_notification_id, |
| const GURL& origin, |
| const SkBitmap& icon, |
| @@ -244,7 +274,7 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
| } |
| void PlatformNotificationServiceImpl::ClosePersistentNotification( |
| - content::BrowserContext* browser_context, |
| + BrowserContext* browser_context, |
| int64_t persistent_notification_id) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |