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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 518 |
519 // The extension could have been removed, but we do not unregister it until | 519 // The extension could have been removed, but we do not unregister it until |
520 // the extension process is unloaded. | 520 // the extension process is unloaded. |
521 if (!extension) | 521 if (!extension) |
522 return; | 522 return; |
523 | 523 |
524 BrowserContext* listener_context = process->GetBrowserContext(); | 524 BrowserContext* listener_context = process->GetBrowserContext(); |
525 ProcessMap* process_map = ProcessMap::Get(listener_context); | 525 ProcessMap* process_map = ProcessMap::Get(listener_context); |
526 // If the event is privileged, only send to extension processes. Otherwise, | 526 // If the event is privileged, only send to extension processes. Otherwise, |
527 // it's OK to send to normal renderers (e.g., for content scripts). | 527 // it's OK to send to normal renderers (e.g., for content scripts). |
528 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && | 528 if (!process_map->Contains(extension->id(), process->GetID()) && |
529 !process_map->Contains(extension->id(), process->GetID())) { | 529 !ExtensionAPI::GetSharedInstance()->IsAvailableInUntrustedContext( |
| 530 event->event_name, extension)) { |
530 return; | 531 return; |
531 } | 532 } |
532 | 533 |
533 // 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 |
534 // permission for it (or if the event originated from itself). | 535 // permission for it (or if the event originated from itself). |
535 if (!event->event_url.is_empty() && | 536 if (!event->event_url.is_empty() && |
536 event->event_url.host() != extension->id() && | 537 event->event_url.host() != extension->id() && |
537 !extension->permissions_data() | 538 !extension->permissions_data() |
538 ->active_permissions() | 539 ->active_permissions() |
539 ->HasEffectiveAccessToURL(event->event_url)) { | 540 ->HasEffectiveAccessToURL(event->event_url)) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 } | 771 } |
771 | 772 |
772 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 773 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
773 const std::string& extension_id, | 774 const std::string& extension_id, |
774 content::BrowserContext* browser_context) | 775 content::BrowserContext* browser_context) |
775 : event_name(event_name), | 776 : event_name(event_name), |
776 extension_id(extension_id), | 777 extension_id(extension_id), |
777 browser_context(browser_context) {} | 778 browser_context(browser_context) {} |
778 | 779 |
779 } // namespace extensions | 780 } // namespace extensions |
OLD | NEW |