OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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/common/view_messages.h" | |
6 #include "content/renderer/dom_proxy_listener.h" | |
7 #include "content/public/renderer/render_thread.h" | |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" | |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | |
12 | |
13 using WebKit::WebDOMMessageEvent; | |
14 | |
15 namespace content { | |
16 | |
17 DOMProxyListener::DOMProxyListener(WebFrame* frame, | |
18 int64 browsing_instance_frame_id) | |
19 : frame_(frame), | |
20 browsing_instance_frame_id_(browsing_instance_frame_id) { | |
21 DCHECK_NE(browsing_instance_frame_id, -1); | |
22 DLOG(WARNING) << "installing DOM proxy for bifi " | |
23 << browsing_instance_frame_id; | |
24 | |
25 frame_->document().securityOrigin().grantReceivePostMessagesFromAnyOrigin(); | |
26 frame_->addEventListener("message", this, false); | |
27 } | |
28 | |
29 DOMProxyListener::~DOMProxyListener() { | |
30 } | |
31 | |
32 void DOMProxyListener::handleEvent(const WebDOMEvent& event) { | |
33 if (event.isMessageEvent()) { | |
34 DLOG(WARNING) << "DOMProxyListener::handleEvent called"; | |
35 const WebDOMMessageEvent msg_event = event.toConst<WebDOMMessageEvent>(); | |
36 | |
37 ViewMsg_PostMessage_Params params; | |
38 params.data = msg_event.data(); | |
39 params.origin = msg_event.origin(); | |
40 params.lastEventId = msg_event.lastEventId(); | |
41 | |
42 RenderThread::Get()->Send(new ViewHostMsg_SendPostMessage( | |
43 browsing_instance_frame_id_, params)); | |
Charlie Reis
2011/12/01 23:13:02
How will we extend this to handle other types of e
supersat
2011/12/09 23:08:20
We'll get WebFrameClient callbacks like willClose(
| |
44 } | |
45 } | |
46 | |
47 } // namespace content | |
48 | |
OLD | NEW |