Index: content/renderer/render_view_impl.cc |
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
index 1996ca9b3ccf192549c5b8fd41d007937b4152ae..f41957885c15cafd389e45412345925f61795706 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/platform/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/platform/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/platform/WebSerializedScriptValue.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/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; |
@@ -218,6 +225,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; |
@@ -243,6 +251,7 @@ using appcache::WebApplicationCacheHostImpl; |
using base::Time; |
using base::TimeDelta; |
using content::DocumentState; |
+using content::ProxyViewHost; |
using content::NavigationState; |
using content::RenderThread; |
using content::RenderViewObserver; |
@@ -362,6 +371,7 @@ RenderViewImpl::RenderViewImpl( |
renderer_accessibility_(NULL), |
session_storage_namespace_id_(session_storage_namespace_id), |
handling_select_range_(false), |
+ proxy_of_browsing_instance_frame_id_(-1), |
#if defined(OS_WIN) |
focused_plugin_id_(-1), |
#endif |
@@ -704,6 +714,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)) |
@@ -732,8 +744,10 @@ void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
return; |
// Swap this renderer back in if necessary. |
- if (is_swapped_out_) |
+ if (is_swapped_out_) { |
SetSwappedOut(false); |
+ proxy_of_browsing_instance_frame_id_ = -1; |
+ } |
history_list_offset_ = params.current_history_list_offset; |
history_list_length_ = params.current_history_list_length; |
@@ -798,6 +812,18 @@ 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) { |
+ // If the user navigates back to this navigation entry, we don't want to |
+ // recreate the opener proxy. |
+ if (!main_frame->opener()) { |
+ ProxyViewHost* proxy_view_host = new ProxyViewHost( |
+ this, params.opener_browsing_instance_frame_id); |
+ main_frame->setOpener(proxy_view_host->mainFrame()); |
+ } |
+ } |
main_frame->loadRequest(request); |
} |
@@ -949,6 +975,35 @@ void RenderViewImpl::OnPasteAndMatchStyle() { |
WebString::fromUTF8("PasteAndMatchStyle")); |
} |
+void RenderViewImpl::OnPostMessage(int64 frame_id, |
+ const ViewMsg_PostMessage_Params& params) { |
+ // TODO(supersat): support subframes |
Charlie Reis
2011/12/12 22:20:36
What else do you need to support subframes?
supersat
2011/12/15 19:30:49
It depends on how we do subframes. If we put them
|
+ 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.targetOrigin)); |
+ if (!frame->document().securityOrigin().canReceiveMessagesFor( |
+ &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.sourceOrigin, 0 /* source frame */, |
+ "" /* last event id, not used with postmsg */); |
+ |
+ DLOG(WARNING) << "Dispatching postMessage event"; |
+ frame->dispatchEvent(msgEvent); |
+} |
+ |
void RenderViewImpl::OnReplace(const string16& text) { |
if (!webview()) |
return; |
@@ -1249,12 +1304,19 @@ void RenderViewImpl::OpenURL(WebFrame* frame, |
const GURL& url, |
const Referrer& 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 ------------------------------------------------------------ |
@@ -3100,6 +3162,25 @@ void RenderViewImpl::registerIntentService( |
service.disposition())); |
} |
+bool RenderViewImpl::interceptPostMessage(int64 source_frame_id, |
+ WebKit::WebSecurityOrigin targetOrigin, |
+ WebKit::WebDOMMessageEvent event) { |
+ DLOG(WARNING) << "interceptPostMessage called"; |
+ |
+ if (!is_swapped_out_) |
+ return false; |
+ DCHECK_NE(proxy_of_browsing_instance_frame_id_, -1); |
+ |
+ ViewMsg_PostMessage_Params params; |
+ params.data = event.data().toString(); |
+ params.sourceOrigin = event.origin(); |
+ params.targetOrigin = targetOrigin.toString(); |
+ |
+ Send(new ViewHostMsg_SendPostMessage( |
+ proxy_of_browsing_instance_frame_id_, params)); |
+ return true; |
+} |
+ |
void RenderViewImpl::dispatchIntent(WebKit::WebFrame* frame, |
const WebKit::WebIntent& intent) { |
webkit_glue::WebIntentData intent_data(intent); |
@@ -3728,6 +3809,10 @@ void RenderViewImpl::OnExitFullscreen() { |
#endif |
} |
+void RenderViewImpl::OnSetOpenerProxy(const ViewMsg_SetOpenerProxy_Params& params) { |
+ //webview()->mainFrame()->setOpener(); |
Charlie Reis
2011/12/12 22:20:36
What's the plan for this?
supersat
2011/12/15 19:30:49
Old cruft. It's gone.
|
+} |
+ |
void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
} |
@@ -4025,14 +4110,16 @@ 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 |
+ // Replace the page with a blank dummy document. 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); |
+ |
+ WebFrame* frame = webview()->mainFrame(); |
+ frame->loadHTMLString(std::string(), GURL("about:swappedout"), |
+ GURL("about:swappedout"), false); |
Charlie Reis
2011/12/12 22:20:36
Looks like no change. Why reformat this?
supersat
2011/12/15 19:30:49
This line was changed at one point to use the new
|
+ |
+ proxy_of_browsing_instance_frame_id_ = params.browsing_instance_frame_id; |
// Just echo back the params in the ACK. |
Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |