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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_devtools_manager.h" 10 #include "chrome/browser/extensions/extension_devtools_manager.h"
11 #include "chrome/browser/extensions/extension_host.h" 11 #include "chrome/browser/extensions/extension_host.h"
12 #include "chrome/browser/extensions/extension_process_manager.h" 12 #include "chrome/browser/extensions/extension_process_manager.h"
13 #include "chrome/browser/extensions/extension_processes_api.h" 13 #include "chrome/browser/extensions/extension_processes_api.h"
14 #include "chrome/browser/extensions/extension_processes_api_constants.h" 14 #include "chrome/browser/extensions/extension_processes_api_constants.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_tabs_module.h" 16 #include "chrome/browser/extensions/extension_tabs_module.h"
17 #include "chrome/browser/extensions/extension_webrequest_api.h" 17 #include "chrome/browser/extensions/extension_webrequest_api.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/extension_messages.h" 21 #include "chrome/common/extensions/extension_messages.h"
22 #include "content/browser/child_process_security_policy.h" 22 #include "content/browser/child_process_security_policy.h"
23 #include "content/browser/renderer_host/render_process_host.h" 23 #include "content/browser/renderer_host/render_process_host.h"
24 #include "content/common/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 25
26 namespace { 26 namespace {
27 27
28 const char kDispatchEvent[] = "Event.dispatchJSON"; 28 const char kDispatchEvent[] = "Event.dispatchJSON";
29 29
30 static void NotifyEventListenerRemovedOnIOThread( 30 static void NotifyEventListenerRemovedOnIOThread(
31 void* profile, 31 void* profile,
32 const std::string& extension_id, 32 const std::string& extension_id,
33 const std::string& sub_event_name) { 33 const std::string& sub_event_name) {
34 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( 34 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 args.Set(0, Value::CreateStringValue(event_name)); 85 args.Set(0, Value::CreateStringValue(event_name));
86 args.Set(1, Value::CreateStringValue(event_args)); 86 args.Set(1, Value::CreateStringValue(event_args));
87 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL, 87 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL,
88 extension_id, kDispatchEvent, args, event_url)); 88 extension_id, kDispatchEvent, args, event_url));
89 } 89 }
90 90
91 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) 91 ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
92 : profile_(profile), 92 : profile_(profile),
93 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) { 93 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) {
94 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 94 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
95 NotificationService::AllSources()); 95 content::NotificationService::AllSources());
96 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 96 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
97 NotificationService::AllSources()); 97 content::NotificationService::AllSources());
98 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 98 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
99 content::Source<Profile>(profile_)); 99 content::Source<Profile>(profile_));
100 // TODO(tessamac): also get notified for background page crash/failure. 100 // TODO(tessamac): also get notified for background page crash/failure.
101 } 101 }
102 102
103 ExtensionEventRouter::~ExtensionEventRouter() {} 103 ExtensionEventRouter::~ExtensionEventRouter() {}
104 104
105 void ExtensionEventRouter::AddEventListener( 105 void ExtensionEventRouter::AddEventListener(
106 const std::string& event_name, 106 const std::string& event_name,
107 RenderProcessHost* process, 107 RenderProcessHost* process,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 ExtensionHost* eh = content::Details<ExtensionHost>(details).ptr(); 361 ExtensionHost* eh = content::Details<ExtensionHost>(details).ptr();
362 DispatchPendingEvents(eh->extension_id()); 362 DispatchPendingEvents(eh->extension_id());
363 break; 363 break;
364 } 364 }
365 // TODO(tessamac): if background page crashed/failed clear queue. 365 // TODO(tessamac): if background page crashed/failed clear queue.
366 default: 366 default:
367 NOTREACHED(); 367 NOTREACHED();
368 return; 368 return;
369 } 369 }
370 } 370 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_debugger_api.cc ('k') | chrome/browser/extensions/extension_history_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698