Index: content/renderer/render_view_impl.cc |
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
index c8d35b7ad626b7e5a8acc177c9059cb61547314c..7932405df3d0355fa5f0362b8e1d8355e9c8a744 100644 |
--- a/content/renderer/render_view_impl.cc |
+++ b/content/renderer/render_view_impl.cc |
@@ -50,6 +50,7 @@ |
#include "content/public/renderer/render_view_visitor.h" |
#include "content/renderer/device_orientation_dispatcher.h" |
#include "content/renderer/devtools_agent.h" |
+#include "content/renderer/dom_proxy_installer.h" |
#include "content/renderer/external_popup_menu.h" |
#include "content/renderer/geolocation_dispatcher.h" |
#include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
@@ -65,6 +66,7 @@ |
#include "content/renderer/notification_provider.h" |
#include "content/renderer/p2p/socket_dispatcher.h" |
#include "content/renderer/plugin_channel_host.h" |
+#include "content/renderer/proxy_view_host.h" |
#include "content/renderer/render_process.h" |
#include "content/renderer/render_thread_impl.h" |
#include "content/renderer/render_widget_fullscreen_pepper.h" |
@@ -88,6 +90,8 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.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/WebDragData.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h" |
@@ -117,6 +121,7 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h" |
@@ -179,6 +184,8 @@ using WebKit::WebCookieJar; |
using WebKit::WebData; |
using WebKit::WebDataSource; |
using WebKit::WebDocument; |
+using WebKit::WebDOMEvent; |
+using WebKit::WebDOMMessageEvent; |
using WebKit::WebDragData; |
using WebKit::WebDragOperation; |
using WebKit::WebDragOperationsMask; |
@@ -217,6 +224,7 @@ using WebKit::WebScriptSource; |
using WebKit::WebSearchableFormData; |
using WebKit::WebSecurityOrigin; |
using WebKit::WebSecurityPolicy; |
+using WebKit::WebSerializedScriptValue; |
using WebKit::WebSettings; |
using WebKit::WebSharedWorker; |
using WebKit::WebSize; |
@@ -242,6 +250,8 @@ using appcache::WebApplicationCacheHostImpl; |
using base::Time; |
using base::TimeDelta; |
using content::DocumentState; |
+using content::DOMProxyInstaller; |
+using content::ProxyViewHost; |
using content::NavigationState; |
using content::RenderThread; |
using content::RenderViewObserver; |
@@ -694,6 +704,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) |
IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
+ IPC_MESSAGE_HANDLER(ViewMsg_PostMessage, OnPostMessage) |
+ IPC_MESSAGE_HANDLER(ViewMsg_SetOpenerProxy, OnSetOpenerProxy) |
// Have the super handle all other messages. |
IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
@@ -788,6 +800,14 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
} |
} |
+ DLOG(WARNING) << "Navigating to " << params.url << " with opener = " << |
+ params.opener_browsing_instance_frame_id; |
+ |
+ if (params.opener_browsing_instance_frame_id != -1) { |
+ ProxyViewHost* proxy_view_host = new ProxyViewHost( |
+ this, params.opener_browsing_instance_frame_id); |
+ main_frame->setOpener(proxy_view_host->mainFrame()); |
+ } |
Charlie Reis
2011/12/01 23:13:02
Hmm, what happens if we go back to the NavigationE
supersat
2011/12/09 23:08:20
Yeah, and we shouldn't. Fixed. (But we should test
|
main_frame->loadRequest(request); |
} |
@@ -939,6 +959,35 @@ void RenderViewImpl::OnPasteAndMatchStyle() { |
WebString::fromUTF8("PasteAndMatchStyle")); |
} |
+void RenderViewImpl::OnPostMessage(int64 frame_id, |
+ const ViewMsg_PostMessage_Params& params) { |
+ // TODO(supersat): support subframes |
+ WebFrame *frame = webview()->mainFrame(); |
+ |
+ // We need to check whether we can send this message to the frame, since the |
+ // asynchrony of postMessage means that the target frame's origin can change |
+ // in the middle of a postMessage dispatch |
+ WebSecurityOrigin messageSpecifiedOrigin = |
+ WebSecurityOrigin::createFromString(WebString(params.origin)); |
+ if (!frame->document().securityOrigin().canReceivePostMessage( |
+ &messageSpecifiedOrigin)) |
+ return; |
+ |
+ WebDOMEvent event = frame->document().createEvent("MessageEvent"); |
+ WebDOMMessageEvent msgEvent = event.to<WebDOMMessageEvent>(); |
+ |
+ // TODO(supersat): fix the source frame parameter |
+ msgEvent.initMessageEvent("message", |
+ // canBubble and cancellable are always false |
+ false, false, |
+ WebSerializedScriptValue::fromString(params.data), |
+ params.origin, 0 /* source frame */, |
+ params.lastEventId); |
+ |
+ DLOG(WARNING) << "Dispatching postMessage event"; |
+ frame->dispatchEvent(msgEvent); |
+} |
+ |
void RenderViewImpl::OnReplace(const string16& text) { |
if (!webview()) |
return; |
@@ -1238,12 +1287,19 @@ void RenderViewImpl::OpenURL(WebFrame* frame, |
const GURL& url, |
const GURL& referrer, |
WebNavigationPolicy policy) { |
- Send(new ViewHostMsg_OpenURL( |
- routing_id_, |
- url, |
- referrer, |
- NavigationPolicyToDisposition(policy), |
- frame->identifier())); |
+ long long opener_frame_id = -1; |
+ if (frame->opener()) { |
+ opener_frame_id = frame->opener()->identifier(); |
+ } |
+ |
+ ViewHostMsg_OpenURL_Params params; |
+ params.url = url; |
+ params.referrer = referrer; |
+ params.disposition = NavigationPolicyToDisposition(policy); |
+ params.source_frame_id = frame->identifier(); |
+ params.opener_frame_id = opener_frame_id; |
+ |
+ Send(new ViewHostMsg_OpenURL(routing_id_, params)); |
} |
// WebViewDelegate ------------------------------------------------------------ |
@@ -1987,12 +2043,6 @@ void RenderViewImpl::loadURLExternally( |
WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
- // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
Charlie Reis
2011/12/01 23:13:02
This can't be removed any more, can it?
supersat
2011/12/09 23:08:20
No. Done.
|
- if (is_swapped_out_) { |
- DCHECK(request.url() == GURL("about:swappedout")); |
- return default_policy; |
- } |
- |
// Webkit is asking whether to navigate to a new URL. |
// This is fine normally, except if we're showing UI from one security |
// context and they're trying to navigate to a different context. |
@@ -3701,6 +3751,10 @@ void RenderViewImpl::OnExitFullscreen() { |
#endif |
} |
+void RenderViewImpl::OnSetOpenerProxy(const ViewMsg_SetOpenerProxy_Params& params) { |
+ //webview()->mainFrame()->setOpener(); |
+} |
+ |
void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
} |
@@ -3988,14 +4042,22 @@ void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { |
// Swap out and stop sending any IPC messages that are not ACKs. |
SetSwappedOut(true); |
- // Replace the page with a blank dummy URL. The unload handler will not be |
- // run a second time, thanks to a check in FrameLoader::stopLoading. |
- // TODO(creis): Need to add a better way to do this that avoids running the |
- // beforeunload handler. For now, we just run it a second time silently. |
- webview()->mainFrame()->loadHTMLString(std::string(), |
- GURL("about:swappedout"), |
- GURL("about:swappedout"), |
- false); |
+ // Replace the page with a blank dummy document. |
+/* |
+ //webview()->mainFrame()->clearDocument(); |
+ WebDocument dummyDocument = WebDocument::create(*frame, |
+ "text/html", |
+ GURL()); |
+ dummyDocument.securityOrigin().grantUniversalAccess(); |
+ frame->setDocument(dummyDocument); |
+*/ |
+ |
+ WebFrame* frame = webview()->mainFrame(); |
+ frame->loadHTMLString(std::string(), GURL("about:swappedout"), |
+ GURL("about:swappedout"), false); |
+ |
+ // Set up the postMessage event proxy |
+ new DOMProxyInstaller(this, params.browsing_instance_frame_id); |
Charlie Reis
2011/12/01 23:13:02
I wonder if there's a clearer way to handle this.
supersat
2011/12/09 23:08:20
If we go with Adam's approach, we don't need the D
|
// Just echo back the params in the ACK. |
Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |