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

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: Invert check. 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"
(...skipping 21 matching lines...) Expand all
136 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 138 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
137 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h" 139 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h"
138 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 140 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
139 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" 141 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h"
140 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00Handler.h" 142 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00Handler.h"
141 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00HandlerClient.h" 143 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00HandlerClient.h"
142 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandler.h" 144 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandler.h"
143 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandlerClient.h" 145 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandlerClient.h"
144 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" 146 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
145 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 147 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
148 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
146 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" 149 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
147 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSocketStr eamHandle.h" 150 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSocketStr eamHandle.h"
148 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 151 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
149 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 152 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
150 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" 153 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h"
151 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 154 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
152 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" 155 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h"
153 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 156 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
154 #include "third_party/skia/include/core/SkBitmap.h" 157 #include "third_party/skia/include/core/SkBitmap.h"
155 #include "ui/base/javascript_message_type.h" 158 #include "ui/base/javascript_message_type.h"
(...skipping 41 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 313
308 static const size_t kExtraCharsBeforeAndAfterSelection = 100; 314 static const size_t kExtraCharsBeforeAndAfterSelection = 100;
309 315
310 // The maximum number of popups that can be spawned from one page. 316 // The maximum number of popups that can be spawned from one page.
311 static const int kMaximumNumberOfUnacknowledgedPopups = 25; 317 static const int kMaximumNumberOfUnacknowledgedPopups = 25;
312 318
313 static const float kScalingIncrement = 0.1f; 319 static const float kScalingIncrement = 0.1f;
314 320
315 static const float kScalingIncrementForGesture = 0.01f; 321 static const float kScalingIncrementForGesture = 0.01f;
316 322
323 static RenderViewImpl* FromRoutingID(int32 routing_id) {
324 return static_cast<RenderViewImpl*>(
325 ChildThread::current()->ResolveRoute(routing_id));
326 }
327
317 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { 328 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
318 WebVector<WebURL> urls; 329 WebVector<WebURL> urls;
319 ds->redirectChain(urls); 330 ds->redirectChain(urls);
320 result->reserve(urls.size()); 331 result->reserve(urls.size());
321 for (size_t i = 0; i < urls.size(); ++i) 332 for (size_t i = 0; i < urls.size(); ++i)
322 result->push_back(urls[i]); 333 result->push_back(urls[i]);
323 } 334 }
324 335
325 // If |data_source| is non-null and has a DocumentState associated with it, 336 // If |data_source| is non-null and has a DocumentState associated with it,
326 // the AltErrorPageResourceFetcher is reset. 337 // the AltErrorPageResourceFetcher is reset.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; 577 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION;
567 578
568 ProcessViewLayoutFlags(command_line); 579 ProcessViewLayoutFlags(command_line);
569 580
570 content::GetContentClient()->renderer()->RenderViewCreated(this); 581 content::GetContentClient()->renderer()->RenderViewCreated(this);
571 582
572 // If we have an opener_id but we weren't created by a renderer, then 583 // 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. 584 // 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. 585 // TODO(creis): This doesn't yet handle openers that are subframes.
575 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { 586 if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) {
576 RenderViewImpl* opener_view = static_cast<RenderViewImpl*>( 587 RenderViewImpl* opener_view = FromRoutingID(opener_id);
577 ChildThread::current()->ResolveRoute(opener_id)); 588 if (opener_view)
578 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); 589 webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame());
579 } 590 }
580 591
581 // If we are initially swapped out, navigate to kSwappedOutURL. 592 // If we are initially swapped out, navigate to kSwappedOutURL.
582 // This ensures we are in a unique origin that others cannot script. 593 // This ensures we are in a unique origin that others cannot script.
583 if (is_swapped_out_) 594 if (is_swapped_out_)
584 NavigateToSwappedOutURL(); 595 NavigateToSwappedOutURL();
585 } 596 }
586 597
587 RenderViewImpl::~RenderViewImpl() { 598 RenderViewImpl::~RenderViewImpl() {
588 history_page_ids_.clear(); 599 history_page_ids_.clear();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) 807 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck)
797 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 808 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
798 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) 809 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel)
799 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) 810 IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor)
800 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, 811 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
801 OnSetZoomLevelForLoadingURL) 812 OnSetZoomLevelForLoadingURL)
802 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 813 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
803 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 814 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
804 OnResetPageEncodingToDefault) 815 OnResetPageEncodingToDefault)
805 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) 816 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest)
817 IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent)
806 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) 818 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest)
807 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) 819 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
808 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) 820 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
809 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) 821 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
810 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) 822 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
811 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) 823 IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved)
812 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, 824 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded,
813 OnDragSourceSystemDragEnded) 825 OnDragSourceSystemDragEnded)
814 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) 826 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
815 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) 827 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty)
(...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 } 3531 }
3520 3532
3521 void RenderViewImpl::dispatchIntent( 3533 void RenderViewImpl::dispatchIntent(
3522 WebFrame* frame, const WebIntentRequest& intentRequest) { 3534 WebFrame* frame, const WebIntentRequest& intentRequest) {
3523 webkit_glue::WebIntentData intent_data(intentRequest.intent()); 3535 webkit_glue::WebIntentData intent_data(intentRequest.intent());
3524 int id = intents_host_->RegisterWebIntent(intentRequest); 3536 int id = intents_host_->RegisterWebIntent(intentRequest);
3525 Send(new IntentsHostMsg_WebIntentDispatch( 3537 Send(new IntentsHostMsg_WebIntentDispatch(
3526 routing_id_, intent_data, id)); 3538 routing_id_, intent_data, id));
3527 } 3539 }
3528 3540
3541 bool RenderViewImpl::willCheckAndDispatchMessageEvent(
3542 WebKit::WebFrame* source,
3543 WebKit::WebSecurityOrigin target_origin,
3544 WebKit::WebDOMMessageEvent event) {
3545 if (!is_swapped_out_)
3546 return false;
3547
3548 ViewMsg_PostMessage_Params params;
3549 params.data = event.data().toString();
3550 params.source_origin = event.origin();
3551 if (!target_origin.isNull())
3552 params.target_origin = target_origin.toString();
3553
3554 // Include the routing ID for the source frame, which the browser process
3555 // will translate into the routing ID for the equivalent frame in the target
3556 // process.
3557 // TODO(creis): Support source subframes.
3558 params.source_routing_id = MSG_ROUTING_NONE;
3559 RenderViewImpl* source_view = FromWebView(source->view());
3560 if (source_view)
3561 params.source_routing_id = source_view->routing_id();
3562
3563 Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params));
3564 return true;
3565 }
3566
3529 void RenderViewImpl::willOpenSocketStream( 3567 void RenderViewImpl::willOpenSocketStream(
3530 WebSocketStreamHandle* handle) { 3568 WebSocketStreamHandle* handle) {
3531 SocketStreamHandleData::AddToHandle(handle, routing_id_); 3569 SocketStreamHandleData::AddToHandle(handle, routing_id_);
3532 } 3570 }
3533 3571
3534 // WebKit::WebPageSerializerClient implementation ------------------------------ 3572 // WebKit::WebPageSerializerClient implementation ------------------------------
3535 3573
3536 void RenderViewImpl::didSerializeDataForFrame( 3574 void RenderViewImpl::didSerializeDataForFrame(
3537 const WebURL& frame_url, 3575 const WebURL& frame_url,
3538 const WebCString& data, 3576 const WebCString& data,
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4191 return frame; 4229 return frame;
4192 } 4230 }
4193 4231
4194 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, 4232 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath,
4195 const string16& jscript, 4233 const string16& jscript,
4196 int id, 4234 int id,
4197 bool notify_result) { 4235 bool notify_result) {
4198 EvaluateScript(frame_xpath, jscript, id, notify_result); 4236 EvaluateScript(frame_xpath, jscript, id, notify_result);
4199 } 4237 }
4200 4238
4239 void RenderViewImpl::OnPostMessageEvent(
4240 const ViewMsg_PostMessage_Params& params) {
4241 // TODO(creis): Support sending to subframes.
4242 WebFrame *frame = webview()->mainFrame();
4243
4244 // Find the source frame if it exists.
4245 // TODO(creis): Support source subframes.
4246 WebFrame* source_frame = NULL;
4247 if (params.source_routing_id != MSG_ROUTING_NONE) {
4248 RenderViewImpl* source_view = FromRoutingID(params.source_routing_id);
4249 if (source_view)
4250 source_frame = source_view->webview()->mainFrame();
4251 }
4252
4253 // Create an event with the message. The final parameter to initMessageEvent
4254 // is the last event ID, which is not used with postMessage.
4255 WebDOMEvent event = frame->document().createEvent("MessageEvent");
4256 WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>();
4257 msg_event.initMessageEvent("message",
4258 // |canBubble| and |cancellable| are always false
4259 false, false,
4260 WebSerializedScriptValue::fromString(params.data),
4261 params.source_origin, source_frame, "");
4262
4263 // We must pass in the target_origin to do the security check on this side,
4264 // since it may have changed since the original postMessage call was made.
4265 WebSecurityOrigin target_origin;
4266 if (!params.target_origin.empty()) {
4267 target_origin =
4268 WebSecurityOrigin::createFromString(WebString(params.target_origin));
4269 }
4270 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event);
4271 }
4272
4201 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, 4273 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath,
4202 const std::string& css) { 4274 const std::string& css) {
4203 WebFrame* frame = GetChildFrame(frame_xpath); 4275 WebFrame* frame = GetChildFrame(frame_xpath);
4204 if (!frame) 4276 if (!frame)
4205 return; 4277 return;
4206 4278
4207 frame->document().insertUserStyleSheet( 4279 frame->document().insertUserStyleSheet(
4208 WebString::fromUTF8(css), 4280 WebString::fromUTF8(css),
4209 WebDocument::UserStyleAuthorLevel); 4281 WebDocument::UserStyleAuthorLevel);
4210 } 4282 }
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
5310 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5382 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5311 return !!RenderThreadImpl::current()->compositor_thread(); 5383 return !!RenderThreadImpl::current()->compositor_thread();
5312 } 5384 }
5313 5385
5314 void RenderViewImpl::OnJavaBridgeInit() { 5386 void RenderViewImpl::OnJavaBridgeInit() {
5315 DCHECK(!java_bridge_dispatcher_.get()); 5387 DCHECK(!java_bridge_dispatcher_.get());
5316 #if defined(ENABLE_JAVA_BRIDGE) 5388 #if defined(ENABLE_JAVA_BRIDGE)
5317 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5389 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5318 #endif 5390 #endif
5319 } 5391 }
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