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

Unified Diff: content/browser/notifications/notification_message_filter.cc

Issue 776813004: Introduce new content APIs for persistent notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-sw-contentclient
Patch Set: Created 6 years 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: 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 93263bbc2ed49439912c9a1cfb5afdd6aedf25da..3faac0a15dc0949c5bf79d90c0a981af97174521 100644
--- a/content/browser/notifications/notification_message_filter.cc
+++ b/content/browser/notifications/notification_message_filter.cc
@@ -61,6 +61,7 @@ void NotificationMessageFilter::OverrideThreadForMessage(
void NotificationMessageFilter::OnCheckNotificationPermission(
const GURL& origin, blink::WebNotificationPermission* permission) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
PlatformNotificationService* service =
GetContentClient()->browser()->GetPlatformNotificationService();
if (service) {
@@ -77,11 +78,13 @@ void NotificationMessageFilter::OnShowPlatformNotification(
scoped_ptr<DesktopNotificationDelegate> delegate(
new PageNotificationDelegate(process_id_, notification_id));
- base::Closure close_closure;
PlatformNotificationService* service =
GetContentClient()->browser()->GetPlatformNotificationService();
DCHECK(service);
+ // TODO(peter): Verify that permission has been granted for params.origin.
+
+ base::Closure close_closure;
service->DisplayNotification(browser_context_,
params,
delegate.Pass(),
@@ -96,10 +99,19 @@ void NotificationMessageFilter::OnShowPersistentNotification(
int request_id,
int64 service_worker_registration_id,
const ShowDesktopNotificationHostMsgParams& params) {
- NOTIMPLEMENTED();
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ PlatformNotificationService* service =
+ GetContentClient()->browser()->GetPlatformNotificationService();
+ DCHECK(service);
+
+ // TODO(peter): Verify that permission has been granted for params.origin.
+
+ service->DisplayPersistentNotification(browser_context_,
+ service_worker_registration_id,
+ params,
+ process_id_);
- // Despite this being NOTIMPLEMENTED, inform the renderer that we did show the
- // notification to avoid leaving the promise in an unsettled state.
Send(new PlatformNotificationMsg_DidShowPersistent(request_id));
}
@@ -114,7 +126,14 @@ void NotificationMessageFilter::OnClosePlatformNotification(
void NotificationMessageFilter::OnClosePersistentNotification(
const std::string& persistent_notification_id) {
- NOTIMPLEMENTED();
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ PlatformNotificationService* service =
+ GetContentClient()->browser()->GetPlatformNotificationService();
+ DCHECK(service);
+
+ service->ClosePersistentNotification(browser_context_,
+ persistent_notification_id);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698