OLD | NEW |
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" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 172 |
172 // Send the event only to renderers that are listening for it. | 173 // Send the event only to renderers that are listening for it. |
173 for (std::set<EventListener>::iterator listener = listeners.begin(); | 174 for (std::set<EventListener>::iterator listener = listeners.begin(); |
174 listener != listeners.end(); ++listener) { | 175 listener != listeners.end(); ++listener) { |
175 if (!ChildProcessSecurityPolicy::GetInstance()-> | 176 if (!ChildProcessSecurityPolicy::GetInstance()-> |
176 HasExtensionBindings(listener->process->id())) { | 177 HasExtensionBindings(listener->process->id())) { |
177 // Don't send browser-level events to unprivileged processes. | 178 // Don't send browser-level events to unprivileged processes. |
178 continue; | 179 continue; |
179 } | 180 } |
180 | 181 |
181 if (!extension_id.empty() && extension_id != listener->extension_id) | 182 if (!extension_id.empty() && extension_id != listener->extension_id) |
182 continue; | 183 continue; |
183 | 184 |
184 // Is this event from a different profile than the renderer (ie, an | 185 // Is this event from a different profile than the renderer (ie, an |
185 // incognito tab event sent to a normal process, or vice versa). | 186 // incognito tab event sent to a normal process, or vice versa). |
186 bool cross_incognito = restrict_to_profile && | 187 bool cross_incognito = restrict_to_profile && |
187 listener->process->profile() != restrict_to_profile; | 188 listener->process->profile() != restrict_to_profile; |
188 if (cross_incognito && !CanCrossIncognito(profile_, listener->extension_id)) | 189 const Extension* extension = service->GetExtensionById( |
| 190 listener->extension_id, false); |
| 191 if (cross_incognito && !service->CanCrossIncognito(extension)) |
189 continue; | 192 continue; |
190 | 193 |
191 DispatchEvent(listener->process, listener->extension_id, | 194 DispatchEvent(listener->process, listener->extension_id, |
192 event_name, event_args, event_url); | 195 event_name, event_args, event_url); |
193 } | 196 } |
194 } | 197 } |
195 | 198 |
196 void ExtensionEventRouter::Observe(NotificationType type, | 199 void ExtensionEventRouter::Observe(NotificationType type, |
197 const NotificationSource& source, | 200 const NotificationSource& source, |
198 const NotificationDetails& details) { | 201 const NotificationDetails& details) { |
(...skipping 15 matching lines...) Expand all Loading... |
214 } | 217 } |
215 } | 218 } |
216 } | 219 } |
217 break; | 220 break; |
218 } | 221 } |
219 default: | 222 default: |
220 NOTREACHED(); | 223 NOTREACHED(); |
221 return; | 224 return; |
222 } | 225 } |
223 } | 226 } |
OLD | NEW |