| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/browser/event_router.h" | 5 #include "extensions/browser/event_router.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 const Extension* extension = | 516 const Extension* extension = |
| 517 ExtensionRegistry::Get(browser_context_)->enabled_extensions().GetByID( | 517 ExtensionRegistry::Get(browser_context_)->enabled_extensions().GetByID( |
| 518 extension_id); | 518 extension_id); |
| 519 | 519 |
| 520 // The extension could have been removed, but we do not unregister it until | 520 // The extension could have been removed, but we do not unregister it until |
| 521 // the extension process is unloaded. | 521 // the extension process is unloaded. |
| 522 if (!extension) | 522 if (!extension) |
| 523 return; | 523 return; |
| 524 | 524 |
| 525 BrowserContext* listener_context = process->GetBrowserContext(); | 525 BrowserContext* listener_context = process->GetBrowserContext(); |
| 526 ProcessMap* process_map = | 526 ProcessMap* process_map = ProcessMap::Get(listener_context); |
| 527 ExtensionSystem::GetForBrowserContext(listener_context) | |
| 528 ->extension_service() | |
| 529 ->process_map(); | |
| 530 // If the event is privileged, only send to extension processes. Otherwise, | 527 // If the event is privileged, only send to extension processes. Otherwise, |
| 531 // it's OK to send to normal renderers (e.g., for content scripts). | 528 // it's OK to send to normal renderers (e.g., for content scripts). |
| 532 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && | 529 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && |
| 533 !process_map->Contains(extension->id(), process->GetID())) { | 530 !process_map->Contains(extension->id(), process->GetID())) { |
| 534 return; | 531 return; |
| 535 } | 532 } |
| 536 | 533 |
| 537 // If the event is restricted to a URL, only dispatch if the extension has | 534 // If the event is restricted to a URL, only dispatch if the extension has |
| 538 // permission for it (or if the event originated from itself). | 535 // permission for it (or if the event originated from itself). |
| 539 if (!event->event_url.is_empty() && | 536 if (!event->event_url.is_empty() && |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 EventDispatchInfo::EventDispatchInfo(const std::string& extension_id, | 784 EventDispatchInfo::EventDispatchInfo(const std::string& extension_id, |
| 788 const std::string& event_name, | 785 const std::string& event_name, |
| 789 scoped_ptr<ListValue> event_args) | 786 scoped_ptr<ListValue> event_args) |
| 790 : extension_id(extension_id), | 787 : extension_id(extension_id), |
| 791 event_name(event_name), | 788 event_name(event_name), |
| 792 event_args(event_args.Pass()) {} | 789 event_args(event_args.Pass()) {} |
| 793 | 790 |
| 794 EventDispatchInfo::~EventDispatchInfo() {} | 791 EventDispatchInfo::~EventDispatchInfo() {} |
| 795 | 792 |
| 796 } // namespace extensions | 793 } // namespace extensions |
| OLD | NEW |