Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2304)

Unified Diff: content/renderer/dom_proxy_listener.cc

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: New patch, still not quite done Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/dom_proxy_listener.cc
diff --git a/content/renderer/dom_proxy_listener.cc b/content/renderer/dom_proxy_listener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0163378a4fa2a135fa628d1209b4f62530a58d01
--- /dev/null
+++ b/content/renderer/dom_proxy_listener.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/view_messages.h"
+#include "content/renderer/dom_proxy_listener.h"
+#include "content/public/renderer/render_thread.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+
+using WebKit::WebDOMMessageEvent;
+
+namespace content {
+
+DOMProxyListener::DOMProxyListener(WebFrame* frame,
+ int64 browsing_instance_frame_id)
+ : frame_(frame),
+ browsing_instance_frame_id_(browsing_instance_frame_id) {
+ DCHECK_NE(browsing_instance_frame_id, -1);
+ DLOG(WARNING) << "installing DOM proxy for bifi "
+ << browsing_instance_frame_id;
+
+ frame_->document().securityOrigin().grantReceivePostMessagesFromAnyOrigin();
+ frame_->addEventListener("message", this, false);
+}
+
+DOMProxyListener::~DOMProxyListener() {
+}
+
+void DOMProxyListener::handleEvent(const WebDOMEvent& event) {
+ if (event.isMessageEvent()) {
+ DLOG(WARNING) << "DOMProxyListener::handleEvent called";
+ const WebDOMMessageEvent msg_event = event.toConst<WebDOMMessageEvent>();
+
+ ViewMsg_PostMessage_Params params;
+ params.data = msg_event.data();
+ params.origin = msg_event.origin();
+ params.lastEventId = msg_event.lastEventId();
+
+ RenderThread::Get()->Send(new ViewHostMsg_SendPostMessage(
+ browsing_instance_frame_id_, params));
+ }
+}
+
+} // namespace content
+

Powered by Google App Engine
This is Rietveld 408576698