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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 9108001: Adds support for calling postMessage on a frame living in a different renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 8 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 #include "media/base/media_switches.h" 95 #include "media/base/media_switches.h"
96 #include "media/base/message_loop_factory.h" 96 #include "media/base/message_loop_factory.h"
97 #include "media/filters/audio_renderer_impl.h" 97 #include "media/filters/audio_renderer_impl.h"
98 #include "media/filters/gpu_video_decoder.h" 98 #include "media/filters/gpu_video_decoder.h"
99 #include "net/base/escape.h" 99 #include "net/base/escape.h"
100 #include "net/base/net_errors.h" 100 #include "net/base/net_errors.h"
101 #include "net/http/http_util.h" 101 #include "net/http/http_util.h"
102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" 102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h"
103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h"
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h"
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h"
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h" 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h"
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo. h" 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo. h"
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h"
121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h"
123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" 126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 127 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 128 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
127 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 129 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
128 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" 130 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h"
129 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 131 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
130 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 132 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
131 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 134 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
132 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" 135 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h"
133 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" 136 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
134 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 137 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
135 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" 138 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
136 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 139 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
137 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h" 140 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h"
138 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 141 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
139 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" 142 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h"
140 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00Handler.h" 143 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00Handler.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 using WebKit::WebApplicationCacheHostClient; 200 using WebKit::WebApplicationCacheHostClient;
198 using WebKit::WebCString; 201 using WebKit::WebCString;
199 using WebKit::WebColor; 202 using WebKit::WebColor;
200 using WebKit::WebColorName; 203 using WebKit::WebColorName;
201 using WebKit::WebConsoleMessage; 204 using WebKit::WebConsoleMessage;
202 using WebKit::WebContextMenuData; 205 using WebKit::WebContextMenuData;
203 using WebKit::WebCookieJar; 206 using WebKit::WebCookieJar;
204 using WebKit::WebData; 207 using WebKit::WebData;
205 using WebKit::WebDataSource; 208 using WebKit::WebDataSource;
206 using WebKit::WebDocument; 209 using WebKit::WebDocument;
210 using WebKit::WebDOMEvent;
211 using WebKit::WebDOMMessageEvent;
207 using WebKit::WebDragData; 212 using WebKit::WebDragData;
208 using WebKit::WebDragOperation; 213 using WebKit::WebDragOperation;
209 using WebKit::WebDragOperationsMask; 214 using WebKit::WebDragOperationsMask;
210 using WebKit::WebEditingAction; 215 using WebKit::WebEditingAction;
211 using WebKit::WebElement; 216 using WebKit::WebElement;
212 using WebKit::WebExternalPopupMenu; 217 using WebKit::WebExternalPopupMenu;
213 using WebKit::WebExternalPopupMenuClient; 218 using WebKit::WebExternalPopupMenuClient;
214 using WebKit::WebFileChooserCompletion; 219 using WebKit::WebFileChooserCompletion;
215 using WebKit::WebFileSystem; 220 using WebKit::WebFileSystem;
216 using WebKit::WebFileSystemCallbacks; 221 using WebKit::WebFileSystemCallbacks;
(...skipping 28 matching lines...) Expand all
245 using WebKit::WebPluginParams; 250 using WebKit::WebPluginParams;
246 using WebKit::WebPoint; 251 using WebKit::WebPoint;
247 using WebKit::WebPopupMenuInfo; 252 using WebKit::WebPopupMenuInfo;
248 using WebKit::WebRange; 253 using WebKit::WebRange;
249 using WebKit::WebRect; 254 using WebKit::WebRect;
250 using WebKit::WebReferrerPolicy; 255 using WebKit::WebReferrerPolicy;
251 using WebKit::WebScriptSource; 256 using WebKit::WebScriptSource;
252 using WebKit::WebSearchableFormData; 257 using WebKit::WebSearchableFormData;
253 using WebKit::WebSecurityOrigin; 258 using WebKit::WebSecurityOrigin;
254 using WebKit::WebSecurityPolicy; 259 using WebKit::WebSecurityPolicy;
260 using WebKit::WebSerializedScriptValue;
255 using WebKit::WebSettings; 261 using WebKit::WebSettings;
256 using WebKit::WebSharedWorker; 262 using WebKit::WebSharedWorker;
257 using WebKit::WebSize; 263 using WebKit::WebSize;
258 using WebKit::WebSocketStreamHandle; 264 using WebKit::WebSocketStreamHandle;
259 using WebKit::WebStorageNamespace; 265 using WebKit::WebStorageNamespace;
260 using WebKit::WebStorageQuotaCallbacks; 266 using WebKit::WebStorageQuotaCallbacks;
261 using WebKit::WebStorageQuotaError; 267 using WebKit::WebStorageQuotaError;
262 using WebKit::WebStorageQuotaType; 268 using WebKit::WebStorageQuotaType;
263 using WebKit::WebString; 269 using WebKit::WebString;
264 using WebKit::WebTextAffinity; 270 using WebKit::WebTextAffinity;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 573
568 ProcessViewLayoutFlags(command_line); 574 ProcessViewLayoutFlags(command_line);
569 575
570 content::GetContentClient()->renderer()->RenderViewCreated(this); 576 content::GetContentClient()->renderer()->RenderViewCreated(this);
571 577
572 // If we have an opener_id but we weren't created by a renderer, then 578 // If we have an opener_id but we weren't created by a renderer, then
573 // it's the browser asking us to set our opener to another RenderView. 579 // it's the browser asking us to set our opener to another RenderView.
574 // TODO(creis): This doesn't yet handle openers that are subframes. 580 // TODO(creis): This doesn't yet handle openers that are subframes.
575 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { 581 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) {
576 RenderViewImpl* opener_view = static_cast<RenderViewImpl*>( 582 RenderViewImpl* opener_view = static_cast<RenderViewImpl*>(
577 ChildThread::current()->ResolveRoute(opener_id)); 583 ChildThread::current()->ResolveRoute(opener_id));
Matt Perry 2012/05/11 22:37:23 This can use FromRouteID too.
Charlie Reis 2012/05/11 22:43:53 Oh, nice catch. Done.
578 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); 584 if (opener_view)
585 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame());
579 } 586 }
580 587
581 // If we are initially swapped out, navigate to kSwappedOutURL. 588 // If we are initially swapped out, navigate to kSwappedOutURL.
582 // This ensures we are in a unique origin that others cannot script. 589 // This ensures we are in a unique origin that others cannot script.
583 if (is_swapped_out_) 590 if (is_swapped_out_)
584 NavigateToSwappedOutURL(); 591 NavigateToSwappedOutURL();
585 } 592 }
586 593
587 RenderViewImpl::~RenderViewImpl() { 594 RenderViewImpl::~RenderViewImpl() {
588 history_page_ids_.clear(); 595 history_page_ids_.clear();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 return it == views->end() ? NULL : it->second; 634 return it == views->end() ? NULL : it->second;
628 } 635 }
629 636
630 /*static*/ 637 /*static*/
631 content::RenderView* 638 content::RenderView*
632 content::RenderView::FromWebView(WebKit::WebView* webview) { 639 content::RenderView::FromWebView(WebKit::WebView* webview) {
633 return RenderViewImpl::FromWebView(webview); 640 return RenderViewImpl::FromWebView(webview);
634 } 641 }
635 642
636 /*static*/ 643 /*static*/
644 RenderViewImpl* RenderViewImpl::FromRoutingID(int32 routing_id) {
645 return static_cast<RenderViewImpl*>(
646 ChildThread::current()->ResolveRoute(routing_id));
647 }
648
649 /*static*/
637 void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { 650 void content::RenderView::ForEach(content::RenderViewVisitor* visitor) {
638 ViewMap* views = g_view_map.Pointer(); 651 ViewMap* views = g_view_map.Pointer();
639 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { 652 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) {
640 if (!visitor->Visit(it->second)) 653 if (!visitor->Visit(it->second))
641 return; 654 return;
642 } 655 }
643 } 656 }
644 657
645 /*static*/ 658 /*static*/
646 RenderViewImpl* RenderViewImpl::Create( 659 RenderViewImpl* RenderViewImpl::Create(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) 809 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck)
797 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 810 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
798 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 811 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
799 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) 812 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor)
800 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 813 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
801 OnSetZoomLevelForLoadingURL) 814 OnSetZoomLevelForLoadingURL)
802 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 815 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
803 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 816 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
804 OnResetPageEncodingToDefault) 817 OnResetPageEncodingToDefault)
805 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) 818 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest)
819 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
806 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) 820 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest)
807 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 821 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
808 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) 822 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
809 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) 823 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
810 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) 824 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
811 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) 825 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved)
812 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, 826 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded,
813 OnDragSourceSystemDragEnded) 827 OnDragSourceSystemDragEnded)
814 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) 828 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
815 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) 829 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty)
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after
3518 } 3532 }
3519 3533
3520 void RenderViewImpl::dispatchIntent( 3534 void RenderViewImpl::dispatchIntent(
3521 WebFrame* frame, const WebIntentRequest& intentRequest) { 3535 WebFrame* frame, const WebIntentRequest& intentRequest) {
3522 webkit_glue::WebIntentData intent_data(intentRequest.intent()); 3536 webkit_glue::WebIntentData intent_data(intentRequest.intent());
3523 int id = intents_host_->RegisterWebIntent(intentRequest); 3537 int id = intents_host_->RegisterWebIntent(intentRequest);
3524 Send(new IntentsHostMsg_WebIntentDispatch( 3538 Send(new IntentsHostMsg_WebIntentDispatch(
3525 routing_id_, intent_data, id)); 3539 routing_id_, intent_data, id));
3526 } 3540 }
3527 3541
3542 bool RenderViewImpl::willCheckAndDispatchMessageEvent(
3543 WebKit::WebFrame* source,
3544 WebKit::WebSecurityOrigin target_origin,
3545 WebKit::WebDOMMessageEvent event) {
3546 if (!is_swapped_out_)
3547 return false;
3548
3549 ViewHostMsg_PostMessage_Params params;
3550 params.data = event.data().toString();
3551 params.source_origin = event.origin();
3552 if (!target_origin.isNull())
3553 params.target_origin = target_origin.toString();
3554
3555 // Include the routing ID for the source frame, which the browser process
3556 // will translate into the routing ID for the equivalent frame in the target
3557 // process.
3558 // TODO(creis): Support source subframes.
3559 params.source_routing_id = MSG_ROUTING_NONE;
3560 RenderViewImpl* source_view = FromWebView(source->view());
3561 if (source_view)
3562 params.source_routing_id = source_view->routing_id();
3563
3564 Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params));
3565 return true;
3566 }
3567
3528 void RenderViewImpl::willOpenSocketStream( 3568 void RenderViewImpl::willOpenSocketStream(
3529 WebSocketStreamHandle* handle) { 3569 WebSocketStreamHandle* handle) {
3530 SocketStreamHandleData::AddToHandle(handle, routing_id_); 3570 SocketStreamHandleData::AddToHandle(handle, routing_id_);
3531 } 3571 }
3532 3572
3533 // WebKit::WebPageSerializerClient implementation ------------------------------ 3573 // WebKit::WebPageSerializerClient implementation ------------------------------
3534 3574
3535 void RenderViewImpl::didSerializeDataForFrame( 3575 void RenderViewImpl::didSerializeDataForFrame(
3536 const WebURL& frame_url, 3576 const WebURL& frame_url,
3537 const WebCString& data, 3577 const WebCString& data,
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 return frame; 4230 return frame;
4191 } 4231 }
4192 4232
4193 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, 4233 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath,
4194 const string16& jscript, 4234 const string16& jscript,
4195 int id, 4235 int id,
4196 bool notify_result) { 4236 bool notify_result) {
4197 EvaluateScript(frame_xpath, jscript, id, notify_result); 4237 EvaluateScript(frame_xpath, jscript, id, notify_result);
4198 } 4238 }
4199 4239
4240 void RenderViewImpl::OnPostMessageEvent(
4241 const ViewHostMsg_PostMessage_Params& params) {
4242 // TODO(creis): Support sending to subframes.
4243 WebFrame *frame = webview()->mainFrame();
4244
4245 // Find the source frame if it exists.
4246 // TODO(creis): Support source subframes.
4247 WebFrame* source_frame = NULL;
4248 if (params.source_routing_id != MSG_ROUTING_NONE) {
4249 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id);
4250 if (source_view)
4251 source_frame = source_view->webview()->mainFrame();
4252 }
4253
4254 // Create an event with the message. The final parameter to initMessageEvent
4255 // is the last event ID, which is not used with postMessage.
4256 WebDOMEvent event = frame->document().createEvent("MessageEvent");
4257 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>();
4258 msg_event.initMessageEvent("message",
4259 // |canBubble| and |cancellable| are always false
4260 false, false,
4261 WebSerializedScriptValue::fromString(params.data),
4262 params.source_origin, source_frame, "");
4263
4264 // We must pass in the target_origin to do the security check on this side,
4265 // since it may have changed since the original postMessage call was made.
4266 WebSecurityOrigin target_origin;
4267 if (!params.target_origin.empty()) {
4268 target_origin =
4269 WebSecurityOrigin::createFromString(WebString(params.target_origin));
4270 }
4271 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event);
4272 }
4273
4200 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, 4274 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath,
4201 const std::string& css) { 4275 const std::string& css) {
4202 WebFrame* frame = GetChildFrame(frame_xpath); 4276 WebFrame* frame = GetChildFrame(frame_xpath);
4203 if (!frame) 4277 if (!frame)
4204 return; 4278 return;
4205 4279
4206 frame->document().insertUserStyleSheet( 4280 frame->document().insertUserStyleSheet(
4207 WebString::fromUTF8(css), 4281 WebString::fromUTF8(css),
4208 WebDocument::UserStyleAuthorLevel); 4282 WebDocument::UserStyleAuthorLevel);
4209 } 4283 }
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5311 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5385 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5312 return !!RenderThreadImpl::current()->compositor_thread(); 5386 return !!RenderThreadImpl::current()->compositor_thread();
5313 } 5387 }
5314 5388
5315 void RenderViewImpl::OnJavaBridgeInit() { 5389 void RenderViewImpl::OnJavaBridgeInit() {
5316 DCHECK(!java_bridge_dispatcher_.get()); 5390 DCHECK(!java_bridge_dispatcher_.get());
5317 #if defined(ENABLE_JAVA_BRIDGE) 5391 #if defined(ENABLE_JAVA_BRIDGE)
5318 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5392 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5319 #endif 5393 #endif
5320 } 5394 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698