Chromium Code Reviews| 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/extension_message_port.h" | 5 #include "chrome/browser/extensions/api/messaging/extension_message_port.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
| 9 #include "extensions/browser/extension_host.h" | 9 #include "extensions/browser/extension_host.h" |
| 10 #include "extensions/browser/process_manager.h" | 10 #include "extensions/browser/process_manager.h" |
| 11 #include "extensions/common/extension_messages.h" | 11 #include "extensions/common/extension_messages.h" |
| 12 #include "extensions/common/manifest_handlers/background_info.h" | 12 #include "extensions/common/manifest_handlers/background_info.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 ExtensionMessagePort::ExtensionMessagePort(content::RenderProcessHost* process, | 16 ExtensionMessagePort::ExtensionMessagePort(content::RenderProcessHost* process, |
| 17 int routing_id, | 17 int routing_id, |
| 18 const std::string& extension_id) | 18 const std::string& extension_id) |
| 19 : process_(process), | 19 : process_(process), |
| 20 routing_id_(routing_id), | 20 routing_id_(routing_id), |
| 21 extension_id_(extension_id), | 21 extension_id_(extension_id), |
| 22 background_host_ptr_(NULL) { | 22 background_host_ptr_(NULL) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void ExtensionMessagePort::DispatchOnConnect( | 25 void ExtensionMessagePort::DispatchOnConnect( |
| 26 int dest_port_id, | 26 int dest_port_id, |
| 27 const std::string& channel_name, | 27 const std::string& channel_name, |
| 28 const base::DictionaryValue& source_tab, | 28 const base::DictionaryValue& source_tab, |
| 29 int source_frame_id, | |
| 29 const std::string& source_extension_id, | 30 const std::string& source_extension_id, |
| 30 const std::string& target_extension_id, | 31 const std::string& target_extension_id, |
| 31 const GURL& source_url, | 32 const GURL& source_url, |
| 32 const std::string& tls_channel_id) { | 33 const std::string& tls_channel_id) { |
| 34 ExtensionMsg_TabConnectionInfo source; | |
| 35 source.tab.Swap(&source_tab); | |
|
robwu
2014/11/11 21:32:47
This line gives a compiler error because source_ta
not at google - send to devlin
2014/11/11 22:01:58
Ideally you'd pass a scoped_ptr<DictionaryValue> i
robwu
2014/11/11 22:20:49
Done.
| |
| 36 source.frame_id = source_frame_id; | |
| 37 | |
| 33 ExtensionMsg_ExternalConnectionInfo info; | 38 ExtensionMsg_ExternalConnectionInfo info; |
| 34 info.target_id = target_extension_id; | 39 info.target_id = target_extension_id; |
| 35 info.source_id = source_extension_id; | 40 info.source_id = source_extension_id; |
| 36 info.source_url = source_url; | 41 info.source_url = source_url; |
| 42 | |
| 37 process_->Send(new ExtensionMsg_DispatchOnConnect( | 43 process_->Send(new ExtensionMsg_DispatchOnConnect( |
| 38 routing_id_, dest_port_id, channel_name, source_tab, info, | 44 routing_id_, dest_port_id, channel_name, source, info, tls_channel_id)); |
| 39 tls_channel_id)); | |
| 40 } | 45 } |
| 41 | 46 |
| 42 void ExtensionMessagePort::DispatchOnDisconnect( | 47 void ExtensionMessagePort::DispatchOnDisconnect( |
| 43 int source_port_id, | 48 int source_port_id, |
| 44 const std::string& error_message) { | 49 const std::string& error_message) { |
| 45 process_->Send(new ExtensionMsg_DispatchOnDisconnect( | 50 process_->Send(new ExtensionMsg_DispatchOnDisconnect( |
| 46 routing_id_, source_port_id, error_message)); | 51 routing_id_, source_port_id, error_message)); |
| 47 } | 52 } |
| 48 | 53 |
| 49 void ExtensionMessagePort::DispatchOnMessage(const Message& message, | 54 void ExtensionMessagePort::DispatchOnMessage(const Message& message, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 72 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); | 77 ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_); |
| 73 if (host && host == background_host_ptr_) | 78 if (host && host == background_host_ptr_) |
| 74 pm->DecrementLazyKeepaliveCount(host->extension()); | 79 pm->DecrementLazyKeepaliveCount(host->extension()); |
| 75 } | 80 } |
| 76 | 81 |
| 77 content::RenderProcessHost* ExtensionMessagePort::GetRenderProcessHost() { | 82 content::RenderProcessHost* ExtensionMessagePort::GetRenderProcessHost() { |
| 78 return process_; | 83 return process_; |
| 79 } | 84 } |
| 80 | 85 |
| 81 } // namespace extensions | 86 } // namespace extensions |
| OLD | NEW |