| 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 "content/public/browser/message_port_provider.h" | 5 #include "content/public/browser/message_port_provider.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
| 9 #include "content/browser/message_port_message_filter.h" | 9 #include "content/browser/message_port_message_filter.h" |
| 10 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 WebContents* web_contents, | 21 WebContents* web_contents, |
| 22 const base::string16& source_origin, | 22 const base::string16& source_origin, |
| 23 const base::string16& target_origin, | 23 const base::string16& target_origin, |
| 24 const base::string16& data, | 24 const base::string16& data, |
| 25 const std::vector<TransferredMessagePort>& ports) { | 25 const std::vector<TransferredMessagePort>& ports) { |
| 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 27 | 27 |
| 28 FrameMsg_PostMessage_Params params; | 28 FrameMsg_PostMessage_Params params; |
| 29 params.is_data_raw_string = true; | 29 params.is_data_raw_string = true; |
| 30 params.data = data; | 30 params.data = data; |
| 31 // Blink requires a source frame to transfer ports. This is why a | |
| 32 // source routing id is set here. See WebDOMMessageEvent::initMessageEvent() | |
| 33 // TODO(alexmos, sgurun): Clean this up once crbug.com/473258 is fixed. | |
| 34 // Once message ports can work with a null source frame, | |
| 35 // source_view_routing_id can be removed, and this can just pass in | |
| 36 // MSG_ROUTING_NONE for the source frame. | |
| 37 params.source_view_routing_id = web_contents->GetRoutingID(); | |
| 38 params.source_routing_id = MSG_ROUTING_NONE; | 31 params.source_routing_id = MSG_ROUTING_NONE; |
| 39 params.source_origin = source_origin; | 32 params.source_origin = source_origin; |
| 40 params.target_origin = target_origin; | 33 params.target_origin = target_origin; |
| 41 params.message_ports = ports; | 34 params.message_ports = ports; |
| 42 | 35 |
| 43 RenderProcessHostImpl* rph = | 36 RenderProcessHostImpl* rph = |
| 44 static_cast<RenderProcessHostImpl*>(web_contents->GetRenderProcessHost()); | 37 static_cast<RenderProcessHostImpl*>(web_contents->GetRenderProcessHost()); |
| 45 BrowserThread::PostTask( | 38 BrowserThread::PostTask( |
| 46 BrowserThread::IO, FROM_HERE, | 39 BrowserThread::IO, FROM_HERE, |
| 47 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | 40 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // static | 100 // static |
| 108 void MessagePortProvider::UpdateMessagePort(int message_port_id, | 101 void MessagePortProvider::UpdateMessagePort(int message_port_id, |
| 109 MessagePortDelegate* delegate) { | 102 MessagePortDelegate* delegate) { |
| 110 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 103 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 111 MessagePortService::GetInstance()->UpdateMessagePort(message_port_id, | 104 MessagePortService::GetInstance()->UpdateMessagePort(message_port_id, |
| 112 delegate, | 105 delegate, |
| 113 message_port_id); | 106 message_port_id); |
| 114 } | 107 } |
| 115 | 108 |
| 116 } // namespace content | 109 } // namespace content |
| OLD | NEW |