| Index: content/browser/notifications/notification_message_filter.cc
|
| diff --git a/content/browser/notifications/notification_message_filter.cc b/content/browser/notifications/notification_message_filter.cc
|
| index 9270ca878806bf2e8ecd2824720bc356e444ffd4..07607ee32af29d9ed437d9db3307e288f3193215 100644
|
| --- a/content/browser/notifications/notification_message_filter.cc
|
| +++ b/content/browser/notifications/notification_message_filter.cc
|
| @@ -19,6 +19,8 @@
|
|
|
| namespace content {
|
|
|
| +PlatformNotificationService* NotificationMessageFilter::service_ = nullptr;
|
| +
|
| NotificationMessageFilter::NotificationMessageFilter(
|
| int process_id,
|
| PlatformNotificationContextImpl* notification_context,
|
| @@ -84,20 +86,16 @@ void NotificationMessageFilter::OnShowPlatformNotification(
|
| scoped_ptr<DesktopNotificationDelegate> delegate(
|
| new PageNotificationDelegate(process_id_, notification_id));
|
|
|
| - PlatformNotificationService* service =
|
| - GetContentClient()->browser()->GetPlatformNotificationService();
|
| - DCHECK(service);
|
| -
|
| - if (!VerifyNotificationPermissionGranted(service, origin))
|
| + if (!VerifyNotificationPermissionGranted(origin))
|
| return;
|
|
|
| base::Closure close_closure;
|
| - service->DisplayNotification(browser_context_,
|
| - origin,
|
| - icon,
|
| - notification_data,
|
| - delegate.Pass(),
|
| - &close_closure);
|
| + service()->DisplayNotification(browser_context_,
|
| + origin,
|
| + icon,
|
| + notification_data,
|
| + delegate.Pass(),
|
| + &close_closure);
|
|
|
| if (!close_closure.is_null())
|
| close_closures_[notification_id] = close_closure;
|
| @@ -146,15 +144,13 @@ void NotificationMessageFilter::DidWritePersistentNotificationData(
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| if (success) {
|
| - PlatformNotificationService* service =
|
| - GetContentClient()->browser()->GetPlatformNotificationService();
|
| - DCHECK(service);
|
| + DCHECK(service());
|
|
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| base::Bind(&PlatformNotificationService::DisplayPersistentNotification,
|
| - base::Unretained(service), // The service is a singleton.
|
| + base::Unretained(service()), // The service is a singleton.
|
| browser_context_,
|
| persistent_notification_id,
|
| origin,
|
| @@ -204,9 +200,7 @@ void NotificationMessageFilter::OnClosePersistentNotification(
|
| return;
|
| }
|
|
|
| - PlatformNotificationService* service =
|
| - GetContentClient()->browser()->GetPlatformNotificationService();
|
| - DCHECK(service);
|
| + DCHECK(service());
|
|
|
| // There's no point in waiting until the database data has been removed before
|
| // closing the notification presented to the user. Post that task immediately.
|
| @@ -214,7 +208,7 @@ void NotificationMessageFilter::OnClosePersistentNotification(
|
| BrowserThread::UI,
|
| FROM_HERE,
|
| base::Bind(&PlatformNotificationService::ClosePersistentNotification,
|
| - base::Unretained(service), // The service is a singleton.
|
| + base::Unretained(service()), // The service is a singleton.
|
| browser_context_,
|
| persistent_notification_id));
|
|
|
| @@ -237,23 +231,24 @@ NotificationMessageFilter::GetPermissionForOriginOnIO(
|
| const GURL& origin) const {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| - PlatformNotificationService* service =
|
| - GetContentClient()->browser()->GetPlatformNotificationService();
|
| - if (!service)
|
| - return blink::WebNotificationPermissionDenied;
|
| + if (service()) {
|
| + return service()->CheckPermissionOnIOThread(resource_context_,
|
| + origin,
|
| + process_id_);
|
| + }
|
|
|
| - return service->CheckPermissionOnIOThread(resource_context_,
|
| - origin,
|
| - process_id_);
|
| + // The ContentBrowserClient does not provide a notification service.
|
| + return blink::WebNotificationPermissionDenied;
|
| }
|
|
|
| bool NotificationMessageFilter::VerifyNotificationPermissionGranted(
|
| - PlatformNotificationService* service,
|
| const GURL& origin) {
|
| + DCHECK(service());
|
| +
|
| blink::WebNotificationPermission permission =
|
| - service->CheckPermissionOnUIThread(browser_context_,
|
| - origin,
|
| - process_id_);
|
| + service()->CheckPermissionOnUIThread(browser_context_,
|
| + origin,
|
| + process_id_);
|
|
|
| if (permission == blink::WebNotificationPermissionAllowed)
|
| return true;
|
| @@ -262,4 +257,11 @@ bool NotificationMessageFilter::VerifyNotificationPermissionGranted(
|
| return false;
|
| }
|
|
|
| +PlatformNotificationService* NotificationMessageFilter::service() const {
|
| + if (NotificationMessageFilter::service_)
|
| + return NotificationMessageFilter::service_;
|
| +
|
| + return GetContentClient()->browser()->GetPlatformNotificationService();
|
| +}
|
| +
|
| } // namespace content
|
|
|