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

Side by Side Diff: chrome/browser/extensions/extension_event_router.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_event_router.h" 5 #include "chrome/browser/extensions/extension_event_router.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/extension_devtools_manager.h" 8 #include "chrome/browser/extensions/extension_devtools_manager.h"
9 #include "chrome/browser/extensions/extension_processes_api.h" 9 #include "chrome/browser/extensions/extension_processes_api.h"
10 #include "chrome/browser/extensions/extension_processes_api_constants.h" 10 #include "chrome/browser/extensions/extension_processes_api_constants.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 ListValue args; 58 ListValue args;
59 args.Set(0, Value::CreateStringValue(event_name)); 59 args.Set(0, Value::CreateStringValue(event_name));
60 args.Set(1, Value::CreateStringValue(event_args)); 60 args.Set(1, Value::CreateStringValue(event_args));
61 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL, 61 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL,
62 extension_id, kDispatchEvent, args, event_url)); 62 extension_id, kDispatchEvent, args, event_url));
63 } 63 }
64 64
65 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) 65 ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
66 : profile_(profile), 66 : profile_(profile),
67 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) { 67 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) {
68 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, 68 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
69 NotificationService::AllSources()); 69 NotificationService::AllSources());
70 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, 70 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
71 NotificationService::AllSources()); 71 NotificationService::AllSources());
72 } 72 }
73 73
74 ExtensionEventRouter::~ExtensionEventRouter() { 74 ExtensionEventRouter::~ExtensionEventRouter() {
75 } 75 }
76 76
77 void ExtensionEventRouter::AddEventListener( 77 void ExtensionEventRouter::AddEventListener(
78 const std::string& event_name, 78 const std::string& event_name,
79 RenderProcessHost* process, 79 RenderProcessHost* process,
80 const std::string& extension_id) { 80 const std::string& extension_id) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 event_name, cross_incognito_args, event_url); 214 event_name, cross_incognito_args, event_url);
215 } 215 }
216 continue; 216 continue;
217 } 217 }
218 218
219 DispatchEvent(listener->process, listener->extension_id, 219 DispatchEvent(listener->process, listener->extension_id,
220 event_name, event_args, event_url); 220 event_name, event_args, event_url);
221 } 221 }
222 } 222 }
223 223
224 void ExtensionEventRouter::Observe(NotificationType type, 224 void ExtensionEventRouter::Observe(int type,
225 const NotificationSource& source, 225 const NotificationSource& source,
226 const NotificationDetails& details) { 226 const NotificationDetails& details) {
227 switch (type.value) { 227 switch (type) {
228 case NotificationType::RENDERER_PROCESS_TERMINATED: 228 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED:
229 case NotificationType::RENDERER_PROCESS_CLOSED: { 229 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
230 RenderProcessHost* renderer = Source<RenderProcessHost>(source).ptr(); 230 RenderProcessHost* renderer = Source<RenderProcessHost>(source).ptr();
231 // Remove all event listeners associated with this renderer 231 // Remove all event listeners associated with this renderer
232 for (ListenerMap::iterator it = listeners_.begin(); 232 for (ListenerMap::iterator it = listeners_.begin();
233 it != listeners_.end(); ) { 233 it != listeners_.end(); ) {
234 ListenerMap::iterator current_it = it++; 234 ListenerMap::iterator current_it = it++;
235 for (std::set<EventListener>::iterator jt = current_it->second.begin(); 235 for (std::set<EventListener>::iterator jt = current_it->second.begin();
236 jt != current_it->second.end(); ) { 236 jt != current_it->second.end(); ) {
237 std::set<EventListener>::iterator current_jt = jt++; 237 std::set<EventListener>::iterator current_jt = jt++;
238 if (current_jt->process == renderer) { 238 if (current_jt->process == renderer) {
239 RemoveEventListener(current_it->first, 239 RemoveEventListener(current_it->first,
240 current_jt->process, 240 current_jt->process,
241 current_jt->extension_id); 241 current_jt->extension_id);
242 } 242 }
243 } 243 }
244 } 244 }
245 break; 245 break;
246 } 246 }
247 default: 247 default:
248 NOTREACHED(); 248 NOTREACHED();
249 return; 249 return;
250 } 250 }
251 } 251 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_event_router.h ('k') | chrome/browser/extensions/extension_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698