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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool handled = true; | 131 bool handled = true; |
132 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) | 132 IPC_BEGIN_MESSAGE_MAP(NotificationManager, message) |
133 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnShow); | 133 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidShow, OnShow); |
134 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidError, OnError); | |
135 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnClose); | 134 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClose, OnClose); |
136 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnClick); | 135 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_DidClick, OnClick); |
137 IPC_MESSAGE_UNHANDLED(handled = false) | 136 IPC_MESSAGE_UNHANDLED(handled = false) |
138 IPC_END_MESSAGE_MAP() | 137 IPC_END_MESSAGE_MAP() |
139 | 138 |
140 return handled; | 139 return handled; |
141 } | 140 } |
142 | 141 |
143 void NotificationManager::OnShow(int id) { | 142 void NotificationManager::OnShow(int id) { |
144 const auto& iter = active_notifications_.find(id); | 143 const auto& iter = active_notifications_.find(id); |
145 if (iter == active_notifications_.end()) | 144 if (iter == active_notifications_.end()) |
146 return; | 145 return; |
147 | 146 |
148 iter->second->dispatchShowEvent(); | 147 iter->second->dispatchShowEvent(); |
149 } | 148 } |
150 | 149 |
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) { | 150 void NotificationManager::OnClose(int id) { |
160 const auto& iter = active_notifications_.find(id); | 151 const auto& iter = active_notifications_.find(id); |
161 if (iter == active_notifications_.end()) | 152 if (iter == active_notifications_.end()) |
162 return; | 153 return; |
163 | 154 |
164 iter->second->dispatchCloseEvent(); | 155 iter->second->dispatchCloseEvent(); |
165 active_notifications_.erase(iter); | 156 active_notifications_.erase(iter); |
166 } | 157 } |
167 | 158 |
168 void NotificationManager::OnClick(int id) { | 159 void NotificationManager::OnClick(int id) { |
169 const auto& iter = active_notifications_.find(id); | 160 const auto& iter = active_notifications_.find(id); |
170 if (iter == active_notifications_.end()) | 161 if (iter == active_notifications_.end()) |
171 return; | 162 return; |
172 | 163 |
173 iter->second->dispatchClickEvent(); | 164 iter->second->dispatchClickEvent(); |
174 } | 165 } |
175 | 166 |
176 } // namespace content | 167 } // namespace content |
OLD | NEW |