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/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/tab_contents/tab_util.h" | 25 #include "chrome/browser/tab_contents/tab_util.h" |
26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
28 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/render_widget_host.h" | 29 #include "content/public/browser/render_widget_host.h" |
30 #include "content/public/browser/render_widget_host_view.h" | 30 #include "content/public/browser/render_widget_host_view.h" |
31 #include "content/public/browser/site_instance.h" | 31 #include "content/public/browser/site_instance.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
33 #include "extensions/browser/extension_host.h" | 33 #include "extensions/browser/extension_host.h" |
| 34 #include "extensions/browser/extension_registry.h" |
34 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
35 #include "extensions/browser/extensions_browser_client.h" | 36 #include "extensions/browser/extensions_browser_client.h" |
36 #include "extensions/browser/lazy_background_task_queue.h" | 37 #include "extensions/browser/lazy_background_task_queue.h" |
37 #include "extensions/browser/pref_names.h" | 38 #include "extensions/browser/pref_names.h" |
38 #include "extensions/browser/process_manager.h" | 39 #include "extensions/browser/process_manager.h" |
39 #include "extensions/common/extension.h" | 40 #include "extensions/common/extension.h" |
40 #include "extensions/common/manifest_constants.h" | 41 #include "extensions/common/manifest_constants.h" |
41 #include "extensions/common/manifest_handlers/background_info.h" | 42 #include "extensions/common/manifest_handlers/background_info.h" |
42 #include "extensions/common/manifest_handlers/externally_connectable.h" | 43 #include "extensions/common/manifest_handlers/externally_connectable.h" |
43 #include "extensions/common/manifest_handlers/incognito_info.h" | 44 #include "extensions/common/manifest_handlers/incognito_info.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 const std::string& target_extension_id, | 238 const std::string& target_extension_id, |
238 const GURL& source_url, | 239 const GURL& source_url, |
239 const std::string& channel_name, | 240 const std::string& channel_name, |
240 bool include_tls_channel_id) { | 241 bool include_tls_channel_id) { |
241 content::RenderProcessHost* source = | 242 content::RenderProcessHost* source = |
242 content::RenderProcessHost::FromID(source_process_id); | 243 content::RenderProcessHost::FromID(source_process_id); |
243 if (!source) | 244 if (!source) |
244 return; | 245 return; |
245 BrowserContext* context = source->GetBrowserContext(); | 246 BrowserContext* context = source->GetBrowserContext(); |
246 | 247 |
247 ExtensionSystem* extension_system = ExtensionSystem::Get(context); | 248 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
248 DCHECK(extension_system); | 249 const Extension* target_extension = |
249 const Extension* target_extension = extension_system->extension_service()-> | 250 registry->enabled_extensions().GetByID(target_extension_id); |
250 extensions()->GetByID(target_extension_id); | |
251 if (!target_extension) { | 251 if (!target_extension) { |
252 DispatchOnDisconnect( | 252 DispatchOnDisconnect( |
253 source, receiver_port_id, kReceivingEndDoesntExistError); | 253 source, receiver_port_id, kReceivingEndDoesntExistError); |
254 return; | 254 return; |
255 } | 255 } |
256 | 256 |
257 bool is_web_connection = false; | 257 bool is_web_connection = false; |
258 | 258 |
259 if (source_extension_id != target_extension_id) { | 259 if (source_extension_id != target_extension_id) { |
260 // It's an external connection. Check the externally_connectable manifest | 260 // It's an external connection. Check the externally_connectable manifest |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 | 717 |
718 PendingTlsChannelIdMap::iterator pending_for_tls_channel_id = | 718 PendingTlsChannelIdMap::iterator pending_for_tls_channel_id = |
719 pending_tls_channel_id_channels_.find(channel_id); | 719 pending_tls_channel_id_channels_.find(channel_id); |
720 if (pending_for_tls_channel_id == pending_tls_channel_id_channels_.end()) { | 720 if (pending_for_tls_channel_id == pending_tls_channel_id_channels_.end()) { |
721 NOTREACHED(); | 721 NOTREACHED(); |
722 return; | 722 return; |
723 } | 723 } |
724 | 724 |
725 BrowserContext* context = params->source->GetBrowserContext(); | 725 BrowserContext* context = params->source->GetBrowserContext(); |
726 | 726 |
| 727 ExtensionRegistry* registry = ExtensionRegistry::Get(context); |
727 const Extension* target_extension = | 728 const Extension* target_extension = |
728 ExtensionSystem::Get(context)->extension_service()->extensions()->GetByID( | 729 registry->enabled_extensions().GetByID(params->target_extension_id); |
729 params->target_extension_id); | |
730 if (!target_extension) { | 730 if (!target_extension) { |
731 pending_tls_channel_id_channels_.erase(channel_id); | 731 pending_tls_channel_id_channels_.erase(channel_id); |
732 DispatchOnDisconnect( | 732 DispatchOnDisconnect( |
733 params->source, params->receiver_port_id, | 733 params->source, params->receiver_port_id, |
734 kReceivingEndDoesntExistError); | 734 kReceivingEndDoesntExistError); |
735 return; | 735 return; |
736 } | 736 } |
737 PendingMessagesQueue& pending_messages = pending_for_tls_channel_id->second; | 737 PendingMessagesQueue& pending_messages = pending_for_tls_channel_id->second; |
738 if (MaybeAddPendingLazyBackgroundPageOpenChannelTask( | 738 if (MaybeAddPendingLazyBackgroundPageOpenChannelTask( |
739 context, target_extension, params.get())) { | 739 context, target_extension, params.get())) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 } | 783 } |
784 | 784 |
785 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, | 785 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, |
786 int port_id, | 786 int port_id, |
787 const std::string& error_message) { | 787 const std::string& error_message) { |
788 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 788 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
789 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); | 789 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); |
790 } | 790 } |
791 | 791 |
792 } // namespace extensions | 792 } // namespace extensions |
OLD | NEW |