| 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 "chrome/browser/extensions/event_router.h" | 5 #include "chrome/browser/extensions/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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "base/version.h" | 14 #include "base/version.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/activity_log/activity_log.h" | 17 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 18 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 18 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 19 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 19 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 20 #include "chrome/browser/extensions/event_names.h" | 20 #include "chrome/browser/extensions/event_names.h" |
| 21 #include "chrome/browser/extensions/extension_host.h" | 21 #include "chrome/browser/extensions/extension_host.h" |
| 22 #include "chrome/browser/extensions/extension_process_manager.h" | 22 #include "chrome/browser/extensions/extension_process_manager.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/extensions/extension_system.h" | 24 #include "chrome/browser/extensions/extension_system.h" |
| 25 #include "chrome/browser/extensions/extension_util.h" |
| 25 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 26 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 26 #include "chrome/browser/extensions/process_map.h" | 27 #include "chrome/browser/extensions/process_map.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/chrome_version_info.h" | 31 #include "chrome/common/chrome_version_info.h" |
| 31 #include "chrome/common/extensions/api/extension_api.h" | 32 #include "chrome/common/extensions/api/extension_api.h" |
| 32 #include "chrome/common/extensions/background_info.h" | 33 #include "chrome/common/extensions/background_info.h" |
| 33 #include "chrome/common/extensions/extension.h" | 34 #include "chrome/common/extensions/extension.h" |
| 34 #include "chrome/common/extensions/extension_messages.h" | 35 #include "chrome/common/extensions/extension_messages.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 IncrementInFlightEvents(listener_profile, extension); | 625 IncrementInFlightEvents(listener_profile, extension); |
| 625 } | 626 } |
| 626 | 627 |
| 627 bool EventRouter::CanDispatchEventToProfile(Profile* profile, | 628 bool EventRouter::CanDispatchEventToProfile(Profile* profile, |
| 628 const Extension* extension, | 629 const Extension* extension, |
| 629 const linked_ptr<Event>& event) { | 630 const linked_ptr<Event>& event) { |
| 630 // Is this event from a different profile than the renderer (ie, an | 631 // Is this event from a different profile than the renderer (ie, an |
| 631 // incognito tab event sent to a normal process, or vice versa). | 632 // incognito tab event sent to a normal process, or vice versa). |
| 632 bool cross_incognito = | 633 bool cross_incognito = |
| 633 event->restrict_to_profile && profile != event->restrict_to_profile; | 634 event->restrict_to_profile && profile != event->restrict_to_profile; |
| 634 if (cross_incognito && | 635 if (cross_incognito && !extension_util::CanCrossIncognito( |
| 635 !ExtensionSystem::Get(profile)->extension_service()-> | 636 extension, |
| 636 CanCrossIncognito(extension)) { | 637 ExtensionSystem::Get(profile)->extension_service())) { |
| 637 return false; | 638 return false; |
| 638 } | 639 } |
| 639 | 640 |
| 640 return true; | 641 return true; |
| 641 } | 642 } |
| 642 | 643 |
| 643 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( | 644 bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( |
| 644 Profile* profile, | 645 Profile* profile, |
| 645 const Extension* extension, | 646 const Extension* extension, |
| 646 const linked_ptr<Event>& event) { | 647 const linked_ptr<Event>& event) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 copy->will_dispatch_callback = will_dispatch_callback; | 861 copy->will_dispatch_callback = will_dispatch_callback; |
| 861 return copy; | 862 return copy; |
| 862 } | 863 } |
| 863 | 864 |
| 864 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 865 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
| 865 const std::string& extension_id) | 866 const std::string& extension_id) |
| 866 : event_name(event_name), | 867 : event_name(event_name), |
| 867 extension_id(extension_id) {} | 868 extension_id(extension_id) {} |
| 868 | 869 |
| 869 } // namespace extensions | 870 } // namespace extensions |
| OLD | NEW |