| 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/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/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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/extension_host.h" | 13 #include "chrome/browser/extensions/extension_host.h" |
| 14 #include "chrome/browser/extensions/extension_process_manager.h" | 14 #include "chrome/browser/extensions/extension_process_manager.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/extension_tab_util.h" | 17 #include "chrome/browser/extensions/extension_tab_util.h" |
| 18 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 18 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 19 #include "chrome/browser/extensions/process_map.h" | 19 #include "chrome/browser/extensions/process_map.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_messages.h" | 25 #include "chrome/common/extensions/extension_messages.h" |
| 26 #include "chrome/common/view_type.h" | 26 #include "chrome/common/view_type.h" |
| 27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 29 #include "content/public/browser/render_view_host.h" | 29 #include "content/public/browser/render_view_host.h" |
| 30 #include "content/public/browser/site_instance.h" | 30 #include "content/public/browser/site_instance.h" |
| 31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 32 | 32 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 void ExtensionMessageService::OpenChannelToTab( | 240 void ExtensionMessageService::OpenChannelToTab( |
| 241 int source_process_id, int source_routing_id, int receiver_port_id, | 241 int source_process_id, int source_routing_id, int receiver_port_id, |
| 242 int tab_id, const std::string& extension_id, | 242 int tab_id, const std::string& extension_id, |
| 243 const std::string& channel_name) { | 243 const std::string& channel_name) { |
| 244 content::RenderProcessHost* source = | 244 content::RenderProcessHost* source = |
| 245 content::RenderProcessHost::FromID(source_process_id); | 245 content::RenderProcessHost::FromID(source_process_id); |
| 246 if (!source) | 246 if (!source) |
| 247 return; | 247 return; |
| 248 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); | 248 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); |
| 249 | 249 |
| 250 TabContentsWrapper* contents = NULL; | 250 TabContents* contents = NULL; |
| 251 MessagePort receiver; | 251 MessagePort receiver; |
| 252 if (ExtensionTabUtil::GetTabById(tab_id, profile, true, | 252 if (ExtensionTabUtil::GetTabById(tab_id, profile, true, |
| 253 NULL, NULL, &contents, NULL)) { | 253 NULL, NULL, &contents, NULL)) { |
| 254 receiver.process = contents->web_contents()->GetRenderProcessHost(); | 254 receiver.process = contents->web_contents()->GetRenderProcessHost(); |
| 255 receiver.routing_id = | 255 receiver.routing_id = |
| 256 contents->web_contents()->GetRenderViewHost()->GetRoutingID(); | 256 contents->web_contents()->GetRenderViewHost()->GetRoutingID(); |
| 257 receiver.extension_id = extension_id; | 257 receiver.extension_id = extension_id; |
| 258 } | 258 } |
| 259 | 259 |
| 260 if (contents && contents->web_contents()->GetController().NeedsReload()) { | 260 if (contents && contents->web_contents()->GetController().NeedsReload()) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 OpenChannelParams params = params_in; | 463 OpenChannelParams params = params_in; |
| 464 params.source = content::RenderProcessHost::FromID(source_process_id); | 464 params.source = content::RenderProcessHost::FromID(source_process_id); |
| 465 if (!params.source) | 465 if (!params.source) |
| 466 return; | 466 return; |
| 467 | 467 |
| 468 params.receiver = MessagePort(host->render_process_host(), | 468 params.receiver = MessagePort(host->render_process_host(), |
| 469 MSG_ROUTING_CONTROL, | 469 MSG_ROUTING_CONTROL, |
| 470 params.target_extension_id); | 470 params.target_extension_id); |
| 471 OpenChannelImpl(params); | 471 OpenChannelImpl(params); |
| 472 } | 472 } |
| OLD | NEW |