OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_message_service.h" | 5 #include "chrome/browser/extensions/extension_message_service.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/extensions/extension_process_manager.h" | 11 #include "chrome/browser/extensions/extension_process_manager.h" |
12 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
13 #include "chrome/browser/extensions/process_map.h" | 13 #include "chrome/browser/extensions/process_map.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/extensions/extension_messages.h" | 18 #include "chrome/common/extensions/extension_messages.h" |
19 #include "content/browser/child_process_security_policy.h" | 19 #include "content/browser/child_process_security_policy.h" |
20 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
21 #include "content/browser/site_instance.h" | |
22 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/site_instance.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 | 26 |
27 using content::WebContents; | 27 using content::WebContents; |
28 | 28 |
29 // Since we have 2 ports for every channel, we just index channels by half the | 29 // Since we have 2 ports for every channel, we just index channels by half the |
30 // port ID. | 30 // port ID. |
31 #define GET_CHANNEL_ID(port_id) ((port_id) / 2) | 31 #define GET_CHANNEL_ID(port_id) ((port_id) / 2) |
32 #define GET_CHANNEL_OPENER_ID(channel_id) ((channel_id) * 2) | 32 #define GET_CHANNEL_OPENER_ID(channel_id) ((channel_id) * 2) |
33 #define GET_CHANNEL_RECEIVERS_ID(channel_id) ((channel_id) * 2 + 1) | 33 #define GET_CHANNEL_RECEIVERS_ID(channel_id) ((channel_id) * 2 + 1) |
34 | 34 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 static void DispatchOnMessage(const ExtensionMessageService::MessagePort& port, | 93 static void DispatchOnMessage(const ExtensionMessageService::MessagePort& port, |
94 const std::string& message, int target_port_id) { | 94 const std::string& message, int target_port_id) { |
95 port.sender->Send( | 95 port.sender->Send( |
96 new ExtensionMsg_DeliverMessage( | 96 new ExtensionMsg_DeliverMessage( |
97 port.routing_id, target_port_id, message)); | 97 port.routing_id, target_port_id, message)); |
98 } | 98 } |
99 | 99 |
100 static content::RenderProcessHost* GetExtensionProcess(Profile* profile, | 100 static content::RenderProcessHost* GetExtensionProcess(Profile* profile, |
101 const std::string& extension_id) { | 101 const std::string& extension_id) { |
102 SiteInstance* site_instance = | 102 content::SiteInstance* site_instance = |
103 profile->GetExtensionProcessManager()->GetSiteInstanceForURL( | 103 profile->GetExtensionProcessManager()->GetSiteInstanceForURL( |
104 Extension::GetBaseURLFromExtensionId(extension_id)); | 104 Extension::GetBaseURLFromExtensionId(extension_id)); |
105 | 105 |
106 if (!site_instance->HasProcess()) | 106 if (!site_instance->HasProcess()) |
107 return NULL; | 107 return NULL; |
108 | 108 |
109 return site_instance->GetProcess(); | 109 return site_instance->GetProcess(); |
110 } | 110 } |
111 | 111 |
112 } // namespace | 112 } // namespace |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 if (current->second->opener.sender == sender) { | 379 if (current->second->opener.sender == sender) { |
380 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), | 380 CloseChannelImpl(current, GET_CHANNEL_OPENER_ID(current->first), |
381 notify_other_port); | 381 notify_other_port); |
382 } else if (current->second->receiver.sender == sender) { | 382 } else if (current->second->receiver.sender == sender) { |
383 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), | 383 CloseChannelImpl(current, GET_CHANNEL_RECEIVERS_ID(current->first), |
384 notify_other_port); | 384 notify_other_port); |
385 } | 385 } |
386 } | 386 } |
387 } | 387 } |
OLD | NEW |