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

Side by Side Diff: content/renderer/proxy_view_host.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 unified diff | Download patch
OLDNEW
(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 "proxy_view_host.h"
6 #include "base/logging.h"
7 #include "content/common/view_messages.h"
8 #include "content/public/renderer/render_thread.h"
9 #include "content/renderer/dom_proxy_listener.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
16
17 using WebKit::WebDOMMessageEvent;
18
19 namespace content {
20
21 ProxyViewHost::ProxyViewHost(RenderView* owner,
22 int64 opener_browsing_instance_frame_id)
23 : RenderViewObserver(owner),
24 opener_browsing_instance_frame_id_(opener_browsing_instance_frame_id) {
25 webview_ = WebView::create(this);
26 webview_->settings()->setJavaScriptEnabled(true);
27 webview_->initializeMainFrame(this);
28
29 WebFrame* frame = webview_->mainFrame();
30
31 frame->loadHTMLString(std::string(), GURL("about:swappedout"),
32 GURL("about:swappedout"), false);
33 }
34
35 bool ProxyViewHost::interceptPostMessage(int64 frame_id,
36 WebSecurityOrigin target,
37 WebDOMMessageEvent event) {
38 ViewMsg_PostMessage_Params params;
39 params.data = event.data().toString();
40 params.sourceOrigin = event.origin();
41 params.targetOrigin = target.toString();
42
43 RenderThread::Get()->Send(new ViewHostMsg_SendPostMessage(
44 opener_browsing_instance_frame_id_, params));
45 return true;
46 }
47
48 void ProxyViewHost::Navigate(const GURL& url) {
49 // TODO(supersat): Does window.opener get reset on navigations?
50 }
51
52 void ProxyViewHost::ClosePage() {
53 // If the owner frame closes, the opener proxy is no longer needed.
54 delete this;
55 }
56
57 WebFrame* ProxyViewHost::mainFrame() {
58 return webview_->mainFrame();
59 }
60
61 ProxyViewHost::~ProxyViewHost() {
62 webview_->close();
63 }
64
65 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698