OLD | NEW |
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/child/notifications/notification_manager.h" | 5 #include "content/child/notifications/notification_manager.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
9 #include "content/child/notifications/notification_dispatcher.h" | 9 #include "content/child/notifications/notification_dispatcher.h" |
10 #include "content/child/thread_safe_sender.h" | 10 #include "content/child/thread_safe_sender.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const blink::WebSerializedOrigin& origin) { | 121 const blink::WebSerializedOrigin& origin) { |
122 WebNotificationPermission permission = | 122 WebNotificationPermission permission = |
123 blink::WebNotificationPermissionAllowed; | 123 blink::WebNotificationPermissionAllowed; |
124 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( | 124 thread_safe_sender_->Send(new PlatformNotificationHostMsg_CheckPermission( |
125 GURL(origin.string()), &permission)); | 125 GURL(origin.string()), &permission)); |
126 | 126 |
127 return permission; | 127 return permission; |
128 } | 128 } |
129 | 129 |
130 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { | 130 bool NotificationManager::OnMessageReceived(const IPC::Message& message) { |
131 // TODO(peter): Implement the message handlers for browser -> renderer events. | 131 bool handled = true; |
132 return false; | 132 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) |
| 133 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnShow); |
| 134 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidError, OnError); |
| 135 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnClose); |
| 136 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnClick); |
| 137 IPC_MESSAGE_UNHANDLED(handled = false) |
| 138 IPC_END_MESSAGE_MAP() |
| 139 |
| 140 return handled; |
| 141 } |
| 142 |
| 143 void NotificationManager::OnShow(int id) { |
| 144 const auto& iter = active_notifications_.find(id); |
| 145 if (iter == active_notifications_.end()) |
| 146 return; |
| 147 |
| 148 iter->second->dispatchShowEvent(); |
| 149 } |
| 150 |
| 151 void NotificationManager::OnError(int id) { |
| 152 const auto& iter = active_notifications_.find(id); |
| 153 if (iter == active_notifications_.end()) |
| 154 return; |
| 155 |
| 156 iter->second->dispatchErrorEvent(); |
| 157 } |
| 158 |
| 159 void NotificationManager::OnClose(int id) { |
| 160 const auto& iter = active_notifications_.find(id); |
| 161 if (iter == active_notifications_.end()) |
| 162 return; |
| 163 |
| 164 iter->second->dispatchCloseEvent(); |
| 165 active_notifications_.erase(iter); |
| 166 } |
| 167 |
| 168 void NotificationManager::OnClick(int id) { |
| 169 const auto& iter = active_notifications_.find(id); |
| 170 if (iter == active_notifications_.end()) |
| 171 return; |
| 172 |
| 173 iter->second->dispatchClickEvent(); |
133 } | 174 } |
134 | 175 |
135 } // namespace content | 176 } // namespace content |
OLD | NEW |