| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/messaging_bindings.h" | 5 #include "extensions/renderer/messaging_bindings.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 void DispatchOnConnectToScriptContext( | 70 void DispatchOnConnectToScriptContext( |
| 71 int global_target_port_id, | 71 int global_target_port_id, |
| 72 const std::string& channel_name, | 72 const std::string& channel_name, |
| 73 const ExtensionMsg_TabConnectionInfo* source, | 73 const ExtensionMsg_TabConnectionInfo* source, |
| 74 const ExtensionMsg_ExternalConnectionInfo& info, | 74 const ExtensionMsg_ExternalConnectionInfo& info, |
| 75 const std::string& tls_channel_id, | 75 const std::string& tls_channel_id, |
| 76 bool* port_created, | 76 bool* port_created, |
| 77 ScriptContext* script_context) { | 77 ScriptContext* script_context) { |
| 78 if (info.source_is_in_same_process && |
| 79 info.source_render_frame_routing_id == |
| 80 script_context->GetRenderFrame()->GetRoutingID()) |
| 81 return; |
| 82 |
| 78 MessagingBindings* bindings = g_messaging_map.Get()[script_context]; | 83 MessagingBindings* bindings = g_messaging_map.Get()[script_context]; |
| 79 DCHECK(bindings); | 84 DCHECK(bindings); |
| 80 | 85 |
| 81 int opposite_port_id = global_target_port_id ^ 1; | 86 int opposite_port_id = global_target_port_id ^ 1; |
| 82 if (bindings->GetPortWithGlobalId(opposite_port_id)) | 87 if (bindings->GetPortWithGlobalId(opposite_port_id)) |
| 83 return; // The channel was opened by this same context; ignore it. | 88 return; // The channel was opened by this same context; ignore it. |
| 84 | 89 |
| 85 ExtensionPort* port = | 90 ExtensionPort* port = |
| 86 bindings->CreateNewPortWithGlobalId(global_target_port_id); | 91 bindings->CreateNewPortWithGlobalId(global_target_port_id); |
| 87 int local_port_id = port->local_id(); | 92 int local_port_id = port->local_id(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 115 if (externally_connectable && | 120 if (externally_connectable && |
| 116 externally_connectable->accepts_tls_channel_id) { | 121 externally_connectable->accepts_tls_channel_id) { |
| 117 v8::Local<v8::String> v8_tls_channel_id; | 122 v8::Local<v8::String> v8_tls_channel_id; |
| 118 if (ToV8String(isolate, tls_channel_id.c_str(), &v8_tls_channel_id)) | 123 if (ToV8String(isolate, tls_channel_id.c_str(), &v8_tls_channel_id)) |
| 119 tls_channel_id_value = v8_tls_channel_id; | 124 tls_channel_id_value = v8_tls_channel_id; |
| 120 } | 125 } |
| 121 | 126 |
| 122 if (info.guest_process_id != content::ChildProcessHost::kInvalidUniqueID) { | 127 if (info.guest_process_id != content::ChildProcessHost::kInvalidUniqueID) { |
| 123 guest_process_id = v8::Integer::New(isolate, info.guest_process_id); | 128 guest_process_id = v8::Integer::New(isolate, info.guest_process_id); |
| 124 guest_render_frame_routing_id = | 129 guest_render_frame_routing_id = |
| 125 v8::Integer::New(isolate, info.guest_render_frame_routing_id); | 130 v8::Integer::New(isolate, info.source_render_frame_routing_id); |
| 126 } | 131 } |
| 127 } | 132 } |
| 128 | 133 |
| 129 v8::Local<v8::String> v8_channel_name; | 134 v8::Local<v8::String> v8_channel_name; |
| 130 v8::Local<v8::String> v8_source_id; | 135 v8::Local<v8::String> v8_source_id; |
| 131 v8::Local<v8::String> v8_target_extension_id; | 136 v8::Local<v8::String> v8_target_extension_id; |
| 132 v8::Local<v8::String> v8_source_url_spec; | 137 v8::Local<v8::String> v8_source_url_spec; |
| 133 if (!ToV8String(isolate, channel_name.c_str(), &v8_channel_name) || | 138 if (!ToV8String(isolate, channel_name.c_str(), &v8_channel_name) || |
| 134 !ToV8String(isolate, info.source_id.c_str(), &v8_source_id) || | 139 !ToV8String(isolate, info.source_id.c_str(), &v8_source_id) || |
| 135 !ToV8String(isolate, target_extension_id.c_str(), | 140 !ToV8String(isolate, target_extension_id.c_str(), |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 DCHECK(iter != disconnected_ports_.end()); | 590 DCHECK(iter != disconnected_ports_.end()); |
| 586 iter->second->SetGlobalId(global_id); | 591 iter->second->SetGlobalId(global_id); |
| 587 // Setting the global id dispatches pending messages, so we can delete the | 592 // Setting the global id dispatches pending messages, so we can delete the |
| 588 // port now. | 593 // port now. |
| 589 disconnected_ports_.erase(iter); | 594 disconnected_ports_.erase(iter); |
| 590 } | 595 } |
| 591 | 596 |
| 592 int MessagingBindings::GetNextLocalId() { return next_local_id_++; } | 597 int MessagingBindings::GetNextLocalId() { return next_local_id_++; } |
| 593 | 598 |
| 594 } // namespace extensions | 599 } // namespace extensions |
| OLD | NEW |