Index: content/renderer/proxy_view_host.cc |
diff --git a/content/renderer/proxy_view_host.cc b/content/renderer/proxy_view_host.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a26f35c18c2ff750e25a4b03af39f97f6bda8914 |
--- /dev/null |
+++ b/content/renderer/proxy_view_host.cc |
@@ -0,0 +1,54 @@ |
+// 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 "proxy_view_host.h" |
+#include "base/logging.h" |
+#include "content/renderer/dom_proxy_listener.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
+ |
+namespace content { |
+ |
+ProxyViewHost::ProxyViewHost(RenderView* owner, |
+ int64 opener_browsing_instance_frame_id) |
+ : RenderViewObserver(owner), |
+ opener_browsing_instance_frame_id_(opener_browsing_instance_frame_id) { |
+ webview_ = WebView::create(this); |
+ webview_->settings()->setJavaScriptEnabled(true); |
+ webview_->initializeMainFrame(this); |
+ |
+ WebFrame* frame = webview_->mainFrame(); |
+ |
+ frame->loadHTMLString(std::string(), GURL("about:swappedout"), |
+ GURL("about:swappedout"), false); |
+} |
+ |
+void ProxyViewHost::didFinishDocumentLoad(WebFrame* frame) { |
+ DCHECK_EQ(frame, webview_->mainFrame()); |
+ dom_proxy_listener_ = new DOMProxyListener( |
+ frame, opener_browsing_instance_frame_id_); |
+} |
+ |
+void ProxyViewHost::Navigate(const GURL& url) { |
+ // TODO(supersat): Does window.opener get reset on navigations? |
+} |
+ |
+void ProxyViewHost::ClosePage() { |
+ // If the owner frame closes, the opener proxy is no longer needed. |
+ delete this; |
+} |
+ |
+WebFrame* ProxyViewHost::mainFrame() { |
+ return webview_->mainFrame(); |
+} |
+ |
+ProxyViewHost::~ProxyViewHost() { |
+ delete dom_proxy_listener_; |
+ webview_->close(); |
+} |
+ |
+} // namespace content |