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

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

Issue 5730004: Rename ExtensionsService to ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/child_process_security_policy.h" 8 #include "chrome/browser/child_process_security_policy.h"
9 #include "chrome/browser/extensions/extension_devtools_manager.h" 9 #include "chrome/browser/extensions/extension_devtools_manager.h"
10 #include "chrome/browser/extensions/extension_processes_api.h" 10 #include "chrome/browser/extensions/extension_processes_api.h"
11 #include "chrome/browser/extensions/extension_processes_api_constants.h" 11 #include "chrome/browser/extensions/extension_processes_api_constants.h"
12 #include "chrome/browser/extensions/extension_tabs_module.h" 12 #include "chrome/browser/extensions/extension_tabs_module.h"
13 #include "chrome/browser/extensions/extensions_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/renderer_host/render_process_host.h" 15 #include "chrome/browser/renderer_host/render_process_host.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
18 #include "chrome/common/render_messages.h" 18 #include "chrome/common/render_messages.h"
19 19
20 namespace { 20 namespace {
21 21
22 const char kDispatchEvent[] = "Event.dispatchJSON"; 22 const char kDispatchEvent[] = "Event.dispatchJSON";
23 23
(...skipping 25 matching lines...) Expand all
49 if (process == that.process && extension_id < that.extension_id) 49 if (process == that.process && extension_id < that.extension_id)
50 return true; 50 return true;
51 return false; 51 return false;
52 } 52 }
53 }; 53 };
54 54
55 // static 55 // static
56 bool ExtensionEventRouter::CanCrossIncognito(Profile* profile, 56 bool ExtensionEventRouter::CanCrossIncognito(Profile* profile,
57 const std::string& extension_id) { 57 const std::string& extension_id) {
58 const Extension* extension = 58 const Extension* extension =
59 profile->GetExtensionsService()->GetExtensionById(extension_id, false); 59 profile->GetExtensionService()->GetExtensionById(extension_id, false);
60 return CanCrossIncognito(profile, extension); 60 return CanCrossIncognito(profile, extension);
61 } 61 }
62 62
63 // static 63 // static
64 bool ExtensionEventRouter::CanCrossIncognito(Profile* profile, 64 bool ExtensionEventRouter::CanCrossIncognito(Profile* profile,
65 const Extension* extension) { 65 const Extension* extension) {
66 // We allow the extension to see events and data from another profile iff it 66 // We allow the extension to see events and data from another profile iff it
67 // uses "spanning" behavior and it has incognito access. "split" mode 67 // uses "spanning" behavior and it has incognito access. "split" mode
68 // extensions only see events for a matching profile. 68 // extensions only see events for a matching profile.
69 return (profile->GetExtensionsService()->IsIncognitoEnabled(extension) && 69 return (profile->GetExtensionService()->IsIncognitoEnabled(extension) &&
70 !extension->incognito_split_mode()); 70 !extension->incognito_split_mode());
71 } 71 }
72 72
73 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) 73 ExtensionEventRouter::ExtensionEventRouter(Profile* profile)
74 : profile_(profile), 74 : profile_(profile),
75 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) { 75 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) {
76 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, 76 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED,
77 NotificationService::AllSources()); 77 NotificationService::AllSources());
78 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, 78 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED,
79 NotificationService::AllSources()); 79 NotificationService::AllSources());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return; 161 return;
162 162
163 // We don't expect to get events from a completely different profile. 163 // We don't expect to get events from a completely different profile.
164 DCHECK(!restrict_to_profile || profile_->IsSameProfile(restrict_to_profile)); 164 DCHECK(!restrict_to_profile || profile_->IsSameProfile(restrict_to_profile));
165 165
166 ListenerMap::iterator it = listeners_.find(event_name); 166 ListenerMap::iterator it = listeners_.find(event_name);
167 if (it == listeners_.end()) 167 if (it == listeners_.end())
168 return; 168 return;
169 169
170 std::set<EventListener>& listeners = it->second; 170 std::set<EventListener>& listeners = it->second;
171 ExtensionsService* service = profile_->GetExtensionsService(); 171 ExtensionService* service = profile_->GetExtensionService();
172 172
173 // Send the event only to renderers that are listening for it. 173 // Send the event only to renderers that are listening for it.
174 for (std::set<EventListener>::iterator listener = listeners.begin(); 174 for (std::set<EventListener>::iterator listener = listeners.begin();
175 listener != listeners.end(); ++listener) { 175 listener != listeners.end(); ++listener) {
176 if (!ChildProcessSecurityPolicy::GetInstance()-> 176 if (!ChildProcessSecurityPolicy::GetInstance()->
177 HasExtensionBindings(listener->process->id())) { 177 HasExtensionBindings(listener->process->id())) {
178 // Don't send browser-level events to unprivileged processes. 178 // Don't send browser-level events to unprivileged processes.
179 continue; 179 continue;
180 } 180 }
181 181
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 } 218 }
219 } 219 }
220 break; 220 break;
221 } 221 }
222 default: 222 default:
223 NOTREACHED(); 223 NOTREACHED();
224 return; 224 return;
225 } 225 }
226 } 226 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_dom_ui.cc ('k') | chrome/browser/extensions/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698