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

Side by Side Diff: content/child/notifications/notification_manager.cc

Issue 681783004: Implement the PageNotificationDelegate for the new Web Notification path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/Ids/ids/ Created 6 years, 1 month 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/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
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
OLDNEW
« no previous file with comments | « content/child/notifications/notification_manager.h ('k') | content/common/platform_notification_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698