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
3 // found in the LICENSE file.
5 #include "content/browser/notification_message_filter.h"
7 #include "content/common/platform_notification_messages.h"
8 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/common/content_client.h"
13 NotificationMessageFilter::NotificationMessageFilter(
15 ResourceContext
* resource_context
)
16 : BrowserMessageFilter(PlatformNotificationMsgStart
),
17 process_id_(process_id
),
18 resource_context_(resource_context
) {}
20 NotificationMessageFilter::~NotificationMessageFilter() {}
22 bool NotificationMessageFilter::OnMessageReceived(const IPC::Message
& message
) {
24 IPC_BEGIN_MESSAGE_MAP(NotificationMessageFilter
, message
)
25 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_CheckPermission
,
26 OnCheckNotificationPermission
)
27 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_Show
,
28 OnShowPlatformNotification
)
29 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_Close
,
30 OnClosePlatformNotification
)
31 IPC_MESSAGE_UNHANDLED(handled
= false)
37 void NotificationMessageFilter::OverrideThreadForMessage(
38 const IPC::Message
& message
, content::BrowserThread::ID
* thread
) {
39 if (message
.type() == PlatformNotificationHostMsg_Show::ID
||
40 message
.type() == PlatformNotificationHostMsg_Close::ID
)
41 *thread
= BrowserThread::UI
;
44 void NotificationMessageFilter::OnCheckNotificationPermission(
45 const GURL
& origin
, blink::WebNotificationPermission
* permission
) {
47 GetContentClient()->browser()->CheckDesktopNotificationPermission(
53 void NotificationMessageFilter::OnShowPlatformNotification(
54 int notification_id
, const ShowDesktopNotificationHostMsgParams
& params
) {
55 // TODO(peter): Implement the DesktopNotificationDelegate.
59 void NotificationMessageFilter::OnClosePlatformNotification(
60 int notification_id
) {
61 // TODO(peter): Implement the ability to close notifications.
65 } // namespace content