OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_message_service.h" | 5 #include "chrome/browser/extensions/extension_message_service.h" |
6 | 6 |
7 #include "base/json_writer.h" | 7 #include "base/json_writer.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/child_process_security_policy.h" |
11 #include "chrome/browser/chrome_thread.h" | 12 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/extensions/extension_tabs_module.h" | 13 #include "chrome/browser/extensions/extension_tabs_module.h" |
13 #include "chrome/browser/extensions/extension_view.h" | 14 #include "chrome/browser/extensions/extension_view.h" |
14 #include "chrome/browser/renderer_host/render_view_host.h" | 15 #include "chrome/browser/renderer_host/render_view_host.h" |
15 #include "chrome/browser/renderer_host/resource_message_filter.h" | 16 #include "chrome/browser/renderer_host/resource_message_filter.h" |
16 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
17 #include "chrome/browser/tab_contents/tab_util.h" | 18 #include "chrome/browser/tab_contents/tab_util.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
20 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 const std::string& event_name, const std::string& event_args) { | 269 const std::string& event_name, const std::string& event_args) { |
269 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 270 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
270 | 271 |
271 std::set<int>& pids = listeners_[event_name]; | 272 std::set<int>& pids = listeners_[event_name]; |
272 | 273 |
273 // Send the event only to renderers that are listening for it. | 274 // Send the event only to renderers that are listening for it. |
274 for (std::set<int>::iterator pid = pids.begin(); pid != pids.end(); ++pid) { | 275 for (std::set<int>::iterator pid = pids.begin(); pid != pids.end(); ++pid) { |
275 RenderProcessHost* renderer = RenderProcessHost::FromID(*pid); | 276 RenderProcessHost* renderer = RenderProcessHost::FromID(*pid); |
276 if (!renderer) | 277 if (!renderer) |
277 continue; | 278 continue; |
| 279 if (!ChildProcessSecurityPolicy::GetInstance()-> |
| 280 HasExtensionBindings(*pid)) { |
| 281 // Don't send browser-level events to unprivileged processes. |
| 282 continue; |
| 283 } |
| 284 |
278 renderer->Send(new ViewMsg_ExtensionHandleEvent(event_name, event_args)); | 285 renderer->Send(new ViewMsg_ExtensionHandleEvent(event_name, event_args)); |
279 } | 286 } |
280 } | 287 } |
281 | 288 |
282 void ExtensionMessageService::Observe(NotificationType type, | 289 void ExtensionMessageService::Observe(NotificationType type, |
283 const NotificationSource& source, | 290 const NotificationSource& source, |
284 const NotificationDetails& details) { | 291 const NotificationDetails& details) { |
285 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 292 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
286 | 293 |
287 DCHECK(type.value == NotificationType::RENDERER_PROCESS_TERMINATED || | 294 DCHECK(type.value == NotificationType::RENDERER_PROCESS_TERMINATED || |
(...skipping 14 matching lines...) Expand all Loading... |
302 | 309 |
303 // Close any channels that share this renderer. | 310 // Close any channels that share this renderer. |
304 // TODO(mpcomplete): should we notify the other side of the port? | 311 // TODO(mpcomplete): should we notify the other side of the port? |
305 for (MessageChannelMap::iterator it = channels_.begin(); | 312 for (MessageChannelMap::iterator it = channels_.begin(); |
306 it != channels_.end(); ) { | 313 it != channels_.end(); ) { |
307 MessageChannelMap::iterator current = it++; | 314 MessageChannelMap::iterator current = it++; |
308 if (current->second.port1 == renderer || current->second.port2 == renderer) | 315 if (current->second.port1 == renderer || current->second.port2 == renderer) |
309 channels_.erase(current); | 316 channels_.erase(current); |
310 } | 317 } |
311 } | 318 } |
OLD | NEW |