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

Side by Side Diff: content/browser/notifications/notification_message_filter.cc

Issue 774573003: Start pulling away notification logic from ChromeContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/notifications/notification_message_filter.h" 5 #include "content/browser/notifications/notification_message_filter.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "content/browser/notifications/page_notification_delegate.h" 8 #include "content/browser/notifications/page_notification_delegate.h"
9 #include "content/common/platform_notification_messages.h" 9 #include "content/common/platform_notification_messages.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/content_browser_client.h" 12 #include "content/public/browser/content_browser_client.h"
13 #include "content/public/browser/desktop_notification_delegate.h" 13 #include "content/public/browser/desktop_notification_delegate.h"
14 #include "content/public/browser/platform_notification_service.h"
14 #include "content/public/common/content_client.h" 15 #include "content/public/common/content_client.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 NotificationMessageFilter::NotificationMessageFilter( 19 NotificationMessageFilter::NotificationMessageFilter(
19 int process_id, 20 int process_id,
20 ResourceContext* resource_context, 21 ResourceContext* resource_context,
21 BrowserContext* browser_context) 22 BrowserContext* browser_context)
22 : BrowserMessageFilter(PlatformNotificationMsgStart), 23 : BrowserMessageFilter(PlatformNotificationMsgStart),
23 process_id_(process_id), 24 process_id_(process_id),
(...skipping 23 matching lines...) Expand all
47 48
48 void NotificationMessageFilter::OverrideThreadForMessage( 49 void NotificationMessageFilter::OverrideThreadForMessage(
49 const IPC::Message& message, content::BrowserThread::ID* thread) { 50 const IPC::Message& message, content::BrowserThread::ID* thread) {
50 if (message.type() == PlatformNotificationHostMsg_Show::ID || 51 if (message.type() == PlatformNotificationHostMsg_Show::ID ||
51 message.type() == PlatformNotificationHostMsg_Close::ID) 52 message.type() == PlatformNotificationHostMsg_Close::ID)
52 *thread = BrowserThread::UI; 53 *thread = BrowserThread::UI;
53 } 54 }
54 55
55 void NotificationMessageFilter::OnCheckNotificationPermission( 56 void NotificationMessageFilter::OnCheckNotificationPermission(
56 const GURL& origin, blink::WebNotificationPermission* permission) { 57 const GURL& origin, blink::WebNotificationPermission* permission) {
57 *permission = 58 PlatformNotificationService* service =
58 GetContentClient()->browser()->CheckDesktopNotificationPermission( 59 GetContentClient()->browser()->GetPlatformNotificationService();
59 origin, 60 if (service) {
60 resource_context_, 61 *permission = service->CheckPermission(resource_context_,
61 process_id_); 62 origin,
63 process_id_);
64 } else
dewittj 2014/12/02 17:22:59 nit: braces around else clause
Peter Beverloo 2014/12/05 20:03:43 Done.
65 *permission = blink::WebNotificationPermissionDenied;
62 } 66 }
63 67
64 void NotificationMessageFilter::OnShowPlatformNotification( 68 void NotificationMessageFilter::OnShowPlatformNotification(
65 int notification_id, const ShowDesktopNotificationHostMsgParams& params) { 69 int notification_id, const ShowDesktopNotificationHostMsgParams& params) {
66 scoped_ptr<DesktopNotificationDelegate> delegate( 70 scoped_ptr<DesktopNotificationDelegate> delegate(
67 new PageNotificationDelegate(process_id_, notification_id)); 71 new PageNotificationDelegate(process_id_, notification_id));
68 72
69 base::Closure close_closure; 73 base::Closure close_closure;
70 GetContentClient()->browser()->ShowDesktopNotification(params, 74 PlatformNotificationService* service =
71 browser_context_, 75 GetContentClient()->browser()->GetPlatformNotificationService();
72 process_id_, 76
73 delegate.Pass(), 77 service->DisplayNotification(browser_context_,
74 &close_closure); 78 params,
79 delegate.Pass(),
80 process_id_,
81 &close_closure);
75 82
76 if (!close_closure.is_null()) 83 if (!close_closure.is_null())
77 close_closures_[notification_id] = close_closure; 84 close_closures_[notification_id] = close_closure;
78 } 85 }
79 86
80 void NotificationMessageFilter::OnClosePlatformNotification( 87 void NotificationMessageFilter::OnClosePlatformNotification(
81 int notification_id) { 88 int notification_id) {
82 if (!close_closures_.count(notification_id)) 89 if (!close_closures_.count(notification_id))
83 return; 90 return;
84 91
85 close_closures_[notification_id].Run(); 92 close_closures_[notification_id].Run();
86 close_closures_.erase(notification_id); 93 close_closures_.erase(notification_id);
87 } 94 }
88 95
89 } // namespace content 96 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698