OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/public/browser/message_port_provider.h" | |
6 | |
7 #include "base/basictypes.h" | |
8 #include "content/browser/message_port_message_filter.h" | |
9 #include "content/browser/message_port_service.h" | |
10 #include "content/browser/renderer_host/render_process_host_impl.h" | |
11 #include "content/common/view_messages.h" | |
12 #include "content/public/browser/browser_thread.h" | |
13 #include "content/public/browser/render_view_host.h" | |
14 #include "content/public/browser/web_contents.h" | |
jochen (gone - plz use gerrit)
2014/11/18 13:29:41
files in content/ should use the _impl.h versions
jochen (gone - plz use gerrit)
2014/11/18 13:29:41
files in content/ should use the _impl.h versions
sgurun-gerrit only
2014/11/18 22:51:55
Done.
sgurun-gerrit only
2014/11/18 22:51:55
Done.
| |
15 | |
16 using base::string16; | |
jochen (gone - plz use gerrit)
2014/11/18 13:29:41
please don't add using for base:: types
sgurun-gerrit only
2014/11/18 22:51:55
Done.
| |
17 | |
18 namespace content { | |
19 | |
20 void MessagePortProvider::PostMessageToFrame(WebContents* web_contents, | |
21 string16* source_origin, | |
22 string16* target_origin, | |
23 string16* data, | |
24 std::vector<int>* ports) { | |
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
26 | |
27 RenderViewHost* rvh = web_contents->GetRenderViewHost(); | |
28 if (!rvh) | |
29 return; | |
30 | |
31 ViewMsg_PostMessage_Params params; | |
32 params.is_data_raw_string = true; | |
33 params.data = *data; | |
34 params.source_routing_id = web_contents->GetRoutingID(); | |
35 params.source_origin = *source_origin; | |
36 params.target_origin = *target_origin; | |
37 | |
38 RenderProcessHostImpl* rph = | |
39 static_cast<RenderProcessHostImpl*>( | |
40 web_contents->GetRenderProcessHost()); | |
41 MessagePortMessageFilter* mf = rph->message_port_message_filter(); | |
42 | |
43 if (!ports->empty()) { | |
44 params.message_port_ids = *ports; | |
45 mf->UpdateMessagePortsWithNewRoutes(params.message_port_ids, | |
46 ¶ms.new_routing_ids); | |
47 } | |
48 rvh->Send(new ViewMsg_PostMessageEvent( | |
49 web_contents->GetRenderViewHost()->GetRoutingID(), | |
50 params)); | |
51 } | |
52 | |
53 void MessagePortProvider::CreateMessageChannel(WebContents* web_contents, | |
54 int* port1, int* port2) { | |
jochen (gone - plz use gerrit)
2014/11/18 13:29:41
is this clang-formated?
sgurun-gerrit only
2014/11/18 22:51:55
Done.
| |
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
56 | |
57 *port1 = 0; | |
58 *port2 = 0; | |
59 | |
60 RenderProcessHostImpl* rph = | |
61 static_cast<RenderProcessHostImpl*>( | |
62 web_contents->GetRenderProcessHost()); | |
63 MessagePortMessageFilter* mf = rph->message_port_message_filter(); | |
64 MessagePortService* msp = MessagePortService::GetInstance(); | |
65 msp->Create(mf->GetNextRoutingID(), mf, port1); | |
66 msp->Create(mf->GetNextRoutingID(), mf, port2); | |
67 } | |
68 | |
69 } // namespace content | |
OLD | NEW |