| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 23 #include "extensions/browser/api_activity_monitor.h" | 23 #include "extensions/browser/api_activity_monitor.h" |
| 24 #include "extensions/browser/event_router_factory.h" | 24 #include "extensions/browser/event_router_factory.h" |
| 25 #include "extensions/browser/extension_host.h" | 25 #include "extensions/browser/extension_host.h" |
| 26 #include "extensions/browser/extension_prefs.h" | 26 #include "extensions/browser/extension_prefs.h" |
| 27 #include "extensions/browser/extension_registry.h" | 27 #include "extensions/browser/extension_registry.h" |
| 28 #include "extensions/browser/extension_system.h" | 28 #include "extensions/browser/extension_system.h" |
| 29 #include "extensions/browser/extension_util.h" |
| 29 #include "extensions/browser/extensions_browser_client.h" | 30 #include "extensions/browser/extensions_browser_client.h" |
| 30 #include "extensions/browser/lazy_background_task_queue.h" | 31 #include "extensions/browser/lazy_background_task_queue.h" |
| 31 #include "extensions/browser/notification_types.h" | 32 #include "extensions/browser/notification_types.h" |
| 32 #include "extensions/browser/process_manager.h" | 33 #include "extensions/browser/process_manager.h" |
| 33 #include "extensions/browser/process_map.h" | 34 #include "extensions/browser/process_map.h" |
| 34 #include "extensions/common/constants.h" | 35 #include "extensions/common/constants.h" |
| 35 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
| 36 #include "extensions/common/extension_api.h" | 37 #include "extensions/common/extension_api.h" |
| 37 #include "extensions/common/extension_messages.h" | 38 #include "extensions/common/extension_messages.h" |
| 38 #include "extensions/common/extension_urls.h" | 39 #include "extensions/common/extension_urls.h" |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 process_map->GetMostLikelyContextType(extension, process->GetID()); | 593 process_map->GetMostLikelyContextType(extension, process->GetID()); |
| 593 | 594 |
| 594 // We shouldn't be dispatching an event to a webpage, since all such events | 595 // We shouldn't be dispatching an event to a webpage, since all such events |
| 595 // (e.g. messaging) don't go through EventRouter. | 596 // (e.g. messaging) don't go through EventRouter. |
| 596 DCHECK_NE(Feature::WEB_PAGE_CONTEXT, target_context) | 597 DCHECK_NE(Feature::WEB_PAGE_CONTEXT, target_context) |
| 597 << "Trying to dispatch event " << event->event_name << " to a webpage," | 598 << "Trying to dispatch event " << event->event_name << " to a webpage," |
| 598 << " but this shouldn't be possible"; | 599 << " but this shouldn't be possible"; |
| 599 | 600 |
| 600 Feature::Availability availability = | 601 Feature::Availability availability = |
| 601 ExtensionAPI::GetSharedInstance()->IsAvailable( | 602 ExtensionAPI::GetSharedInstance()->IsAvailable( |
| 602 event->event_name, extension, target_context, listener_url); | 603 event->event_name, extension, target_context, |
| 604 util::GetCurrentSessionType(), listener_url); |
| 603 if (!availability.is_available()) { | 605 if (!availability.is_available()) { |
| 604 // It shouldn't be possible to reach here, because access is checked on | 606 // It shouldn't be possible to reach here, because access is checked on |
| 605 // registration. However, for paranoia, check on dispatch as well. | 607 // registration. However, for paranoia, check on dispatch as well. |
| 606 NOTREACHED() << "Trying to dispatch event " << event->event_name | 608 NOTREACHED() << "Trying to dispatch event " << event->event_name |
| 607 << " which the target does not have access to: " | 609 << " which the target does not have access to: " |
| 608 << availability.message(); | 610 << availability.message(); |
| 609 return; | 611 return; |
| 610 } | 612 } |
| 611 | 613 |
| 612 if (!event->will_dispatch_callback.is_null() && | 614 if (!event->will_dispatch_callback.is_null() && |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 const std::string& extension_id, | 895 const std::string& extension_id, |
| 894 const GURL& listener_url, | 896 const GURL& listener_url, |
| 895 content::BrowserContext* browser_context) | 897 content::BrowserContext* browser_context) |
| 896 : event_name(event_name), | 898 : event_name(event_name), |
| 897 extension_id(extension_id), | 899 extension_id(extension_id), |
| 898 listener_url(listener_url), | 900 listener_url(listener_url), |
| 899 browser_context(browser_context) { | 901 browser_context(browser_context) { |
| 900 } | 902 } |
| 901 | 903 |
| 902 } // namespace extensions | 904 } // namespace extensions |
| OLD | NEW |