OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 using blink::WebUserGestureIndicator; | 244 using blink::WebUserGestureIndicator; |
245 using blink::WebVector; | 245 using blink::WebVector; |
246 using blink::WebView; | 246 using blink::WebView; |
247 using base::Time; | 247 using base::Time; |
248 using base::TimeDelta; | 248 using base::TimeDelta; |
249 | 249 |
250 namespace content { | 250 namespace content { |
251 | 251 |
252 namespace { | 252 namespace { |
253 | 253 |
254 int GetRoutingIDForFrame(blink::WebFrame* frame) { | |
alexmos
2015/10/09 21:55:49
Heads up: you don't need this anymore, as Nick has
lazyboy
2015/10/13 21:59:08
Done.
| |
255 if (frame->isWebRemoteFrame()) | |
256 return RenderFrameProxy::FromWebFrame(frame)->routing_id(); | |
257 | |
258 return RenderFrameImpl::FromWebFrame(frame)->GetRoutingID(); | |
259 } | |
260 | |
254 const char kDefaultAcceptHeader[] = | 261 const char kDefaultAcceptHeader[] = |
255 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" | 262 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" |
256 "*;q=0.8"; | 263 "*;q=0.8"; |
257 const char kAcceptHeader[] = "Accept"; | 264 const char kAcceptHeader[] = "Accept"; |
258 | 265 |
259 const size_t kExtraCharsBeforeAndAfterSelection = 100; | 266 const size_t kExtraCharsBeforeAndAfterSelection = 100; |
260 | 267 |
261 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; | 268 typedef std::map<int, RenderFrameImpl*> RoutingIDFrameMap; |
262 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = | 269 static base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = |
263 LAZY_INSTANCE_INITIALIZER; | 270 LAZY_INSTANCE_INITIALIZER; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 | 567 |
561 // static | 568 // static |
562 void RenderFrameImpl::CreateFrame( | 569 void RenderFrameImpl::CreateFrame( |
563 int routing_id, | 570 int routing_id, |
564 int proxy_routing_id, | 571 int proxy_routing_id, |
565 int opener_routing_id, | 572 int opener_routing_id, |
566 int parent_routing_id, | 573 int parent_routing_id, |
567 int previous_sibling_routing_id, | 574 int previous_sibling_routing_id, |
568 const FrameReplicationState& replicated_state, | 575 const FrameReplicationState& replicated_state, |
569 CompositorDependencies* compositor_deps, | 576 CompositorDependencies* compositor_deps, |
570 const FrameMsg_NewFrame_WidgetParams& widget_params) { | 577 const FrameMsg_NewFrame_WidgetParams& widget_params, |
578 const blink::WebFrameOwnerProperties& frame_owner_properties) { | |
571 blink::WebLocalFrame* web_frame; | 579 blink::WebLocalFrame* web_frame; |
572 RenderFrameImpl* render_frame; | 580 RenderFrameImpl* render_frame; |
573 if (proxy_routing_id == MSG_ROUTING_NONE) { | 581 if (proxy_routing_id == MSG_ROUTING_NONE) { |
574 RenderFrameProxy* parent_proxy = | 582 RenderFrameProxy* parent_proxy = |
575 RenderFrameProxy::FromRoutingID(parent_routing_id); | 583 RenderFrameProxy::FromRoutingID(parent_routing_id); |
576 // If the browser is sending a valid parent routing id, it should already | 584 // If the browser is sending a valid parent routing id, it should already |
577 // be created and registered. | 585 // be created and registered. |
578 CHECK(parent_proxy); | 586 CHECK(parent_proxy); |
579 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); | 587 blink::WebRemoteFrame* parent_web_frame = parent_proxy->web_frame(); |
580 | 588 |
581 blink::WebFrame* previous_sibling_web_frame = nullptr; | 589 blink::WebFrame* previous_sibling_web_frame = nullptr; |
582 RenderFrameProxy* previous_sibling_proxy = | 590 RenderFrameProxy* previous_sibling_proxy = |
583 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); | 591 RenderFrameProxy::FromRoutingID(previous_sibling_routing_id); |
584 if (previous_sibling_proxy) | 592 if (previous_sibling_proxy) |
585 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); | 593 previous_sibling_web_frame = previous_sibling_proxy->web_frame(); |
586 | 594 |
587 // Create the RenderFrame and WebLocalFrame, linking the two. | 595 // Create the RenderFrame and WebLocalFrame, linking the two. |
588 render_frame = | 596 render_frame = |
589 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); | 597 RenderFrameImpl::Create(parent_proxy->render_view(), routing_id); |
590 web_frame = parent_web_frame->createLocalChild( | 598 web_frame = parent_web_frame->createLocalChild( |
591 replicated_state.scope, WebString::fromUTF8(replicated_state.name), | 599 replicated_state.scope, WebString::fromUTF8(replicated_state.name), |
592 replicated_state.sandbox_flags, render_frame, | 600 replicated_state.sandbox_flags, render_frame, |
593 previous_sibling_web_frame); | 601 previous_sibling_web_frame, frame_owner_properties); |
594 } else { | 602 } else { |
595 RenderFrameProxy* proxy = | 603 RenderFrameProxy* proxy = |
596 RenderFrameProxy::FromRoutingID(proxy_routing_id); | 604 RenderFrameProxy::FromRoutingID(proxy_routing_id); |
597 CHECK(proxy); | 605 CHECK(proxy); |
598 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); | 606 render_frame = RenderFrameImpl::Create(proxy->render_view(), routing_id); |
599 web_frame = | 607 web_frame = |
600 blink::WebLocalFrame::create(replicated_state.scope, render_frame); | 608 blink::WebLocalFrame::create(replicated_state.scope, render_frame); |
601 render_frame->proxy_routing_id_ = proxy_routing_id; | 609 render_frame->proxy_routing_id_ = proxy_routing_id; |
602 web_frame->initializeToReplaceRemoteFrame( | 610 web_frame->initializeToReplaceRemoteFrame( |
603 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), | 611 proxy->web_frame(), WebString::fromUTF8(replicated_state.name), |
604 replicated_state.sandbox_flags); | 612 replicated_state.sandbox_flags, frame_owner_properties); |
605 } | 613 } |
606 render_frame->SetWebFrame(web_frame); | 614 render_frame->SetWebFrame(web_frame); |
607 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); | 615 CHECK_IMPLIES(parent_routing_id == MSG_ROUTING_NONE, !web_frame->parent()); |
608 | 616 |
609 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); | 617 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); |
610 web_frame->setOpener(opener); | 618 web_frame->setOpener(opener); |
611 | 619 |
612 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 620 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
613 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 621 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
614 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 622 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1119 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) | 1127 IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload) |
1120 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, | 1128 IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest, |
1121 OnTextSurroundingSelectionRequest) | 1129 OnTextSurroundingSelectionRequest) |
1122 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, | 1130 IPC_MESSAGE_HANDLER(FrameMsg_SetAccessibilityMode, |
1123 OnSetAccessibilityMode) | 1131 OnSetAccessibilityMode) |
1124 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree, | 1132 IPC_MESSAGE_HANDLER(AccessibilityMsg_SnapshotTree, |
1125 OnSnapshotAccessibilityTree) | 1133 OnSnapshotAccessibilityTree) |
1126 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) | 1134 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) |
1127 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) | 1135 IPC_MESSAGE_HANDLER(FrameMsg_CommitNavigation, OnCommitNavigation) |
1128 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) | 1136 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) |
1137 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties, | |
1138 OnSetFrameOwnerProperties) | |
1129 IPC_MESSAGE_HANDLER(FrameMsg_ClearFocus, OnClearFocus) | 1139 IPC_MESSAGE_HANDLER(FrameMsg_ClearFocus, OnClearFocus) |
1130 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, | 1140 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, |
1131 OnTextTrackSettingsChanged) | 1141 OnTextTrackSettingsChanged) |
1132 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) | 1142 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) |
1133 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) | 1143 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) |
1134 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, | 1144 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, |
1135 OnGetSavableResourceLinks) | 1145 OnGetSavableResourceLinks) |
1136 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, | 1146 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, |
1137 OnGetSerializedHtmlWithLocalLinks) | 1147 OnGetSerializedHtmlWithLocalLinks) |
1138 #if defined(OS_ANDROID) | 1148 #if defined(OS_ANDROID) |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1676 | 1686 |
1677 void RenderFrameImpl::OnUpdateOpener(int opener_routing_id) { | 1687 void RenderFrameImpl::OnUpdateOpener(int opener_routing_id) { |
1678 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); | 1688 WebFrame* opener = ResolveOpener(opener_routing_id, nullptr); |
1679 frame_->setOpener(opener); | 1689 frame_->setOpener(opener); |
1680 } | 1690 } |
1681 | 1691 |
1682 void RenderFrameImpl::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) { | 1692 void RenderFrameImpl::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) { |
1683 frame_->setFrameOwnerSandboxFlags(flags); | 1693 frame_->setFrameOwnerSandboxFlags(flags); |
1684 } | 1694 } |
1685 | 1695 |
1696 void RenderFrameImpl::OnSetFrameOwnerProperties( | |
1697 const blink::WebFrameOwnerProperties& frame_owner_properties) { | |
1698 DCHECK(frame_); | |
1699 frame_->setFrameOwnerProperties(frame_owner_properties); | |
1700 } | |
1701 | |
1686 void RenderFrameImpl::OnClearFocus() { | 1702 void RenderFrameImpl::OnClearFocus() { |
1687 frame_->clearFocus(); | 1703 frame_->clearFocus(); |
1688 } | 1704 } |
1689 | 1705 |
1690 void RenderFrameImpl::OnTextTrackSettingsChanged( | 1706 void RenderFrameImpl::OnTextTrackSettingsChanged( |
1691 const FrameMsg_TextTrackSettings_Params& params) { | 1707 const FrameMsg_TextTrackSettings_Params& params) { |
1692 DCHECK(!frame_->parent()); | 1708 DCHECK(!frame_->parent()); |
1693 if (!render_view_->webview()) | 1709 if (!render_view_->webview()) |
1694 return; | 1710 return; |
1695 | 1711 |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2208 if (!navigation_state->request_committed()) { | 2224 if (!navigation_state->request_committed()) { |
2209 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); | 2225 Send(new FrameHostMsg_DidAccessInitialDocument(routing_id_)); |
2210 } | 2226 } |
2211 } | 2227 } |
2212 } | 2228 } |
2213 | 2229 |
2214 blink::WebFrame* RenderFrameImpl::createChildFrame( | 2230 blink::WebFrame* RenderFrameImpl::createChildFrame( |
2215 blink::WebLocalFrame* parent, | 2231 blink::WebLocalFrame* parent, |
2216 blink::WebTreeScopeType scope, | 2232 blink::WebTreeScopeType scope, |
2217 const blink::WebString& name, | 2233 const blink::WebString& name, |
2218 blink::WebSandboxFlags sandbox_flags) { | 2234 blink::WebSandboxFlags sandbox_flags, |
2235 const blink::WebFrameOwnerProperties& frameOwnerProperties) { | |
2219 // Synchronously notify the browser of a child frame creation to get the | 2236 // Synchronously notify the browser of a child frame creation to get the |
2220 // routing_id for the RenderFrame. | 2237 // routing_id for the RenderFrame. |
2221 int child_routing_id = MSG_ROUTING_NONE; | 2238 int child_routing_id = MSG_ROUTING_NONE; |
2222 Send(new FrameHostMsg_CreateChildFrame( | 2239 Send(new FrameHostMsg_CreateChildFrame( |
2223 routing_id_, scope, | 2240 routing_id_, scope, base::UTF16ToUTF8(base::StringPiece16(name)), |
2224 base::UTF16ToUTF8(base::StringPiece16(name)), sandbox_flags, | 2241 sandbox_flags, frameOwnerProperties, &child_routing_id)); |
2225 &child_routing_id)); | |
2226 | 2242 |
2227 // Allocation of routing id failed, so we can't create a child frame. This can | 2243 // Allocation of routing id failed, so we can't create a child frame. This can |
2228 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped | 2244 // happen if this RenderFrameImpl's IPCs are being filtered when in swapped |
2229 // out state or synchronous IPC message above has failed. | 2245 // out state or synchronous IPC message above has failed. |
2230 if (child_routing_id == MSG_ROUTING_NONE) { | 2246 if (child_routing_id == MSG_ROUTING_NONE) { |
2231 NOTREACHED() << "Failed to allocate routing id for child frame."; | 2247 NOTREACHED() << "Failed to allocate routing id for child frame."; |
2232 return nullptr; | 2248 return nullptr; |
2233 } | 2249 } |
2234 | 2250 |
2235 // This method is always called by local frames, never remote frames. | 2251 // This method is always called by local frames, never remote frames. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2346 // updates are happening too frequently. | 2362 // updates are happening too frequently. |
2347 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || | 2363 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || |
2348 render_view_->renderer_preferences_.report_frame_name_changes) { | 2364 render_view_->renderer_preferences_.report_frame_name_changes) { |
2349 Send(new FrameHostMsg_DidChangeName( | 2365 Send(new FrameHostMsg_DidChangeName( |
2350 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)))); | 2366 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)))); |
2351 } | 2367 } |
2352 } | 2368 } |
2353 | 2369 |
2354 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, | 2370 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, |
2355 blink::WebSandboxFlags flags) { | 2371 blink::WebSandboxFlags flags) { |
2356 int frame_routing_id = MSG_ROUTING_NONE; | 2372 int frame_routing_id = GetRoutingIDForFrame(child_frame); |
2357 if (child_frame->isWebRemoteFrame()) { | |
2358 frame_routing_id = | |
2359 RenderFrameProxy::FromWebFrame(child_frame)->routing_id(); | |
2360 } else { | |
2361 frame_routing_id = | |
2362 RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID(); | |
2363 } | |
2364 | |
2365 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id, | 2373 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id, |
2366 flags)); | 2374 flags)); |
2367 } | 2375 } |
2368 | 2376 |
2377 void RenderFrameImpl::didChangeFrameOwnerProperties( | |
2378 blink::WebFrame* child_frame, | |
2379 const blink::WebFrameOwnerProperties& frame_owner_properties) { | |
2380 int frame_routing_id = GetRoutingIDForFrame(child_frame); | |
2381 Send(new FrameHostMsg_DidChangeFrameOwnerProperties( | |
2382 routing_id_, frame_routing_id, frame_owner_properties)); | |
2383 } | |
2384 | |
2369 void RenderFrameImpl::didMatchCSS( | 2385 void RenderFrameImpl::didMatchCSS( |
2370 blink::WebLocalFrame* frame, | 2386 blink::WebLocalFrame* frame, |
2371 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 2387 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
2372 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 2388 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { |
2373 DCHECK(!frame_ || frame_ == frame); | 2389 DCHECK(!frame_ || frame_ == frame); |
2374 | 2390 |
2375 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2391 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
2376 DidMatchCSS(newly_matching_selectors, | 2392 DidMatchCSS(newly_matching_selectors, |
2377 stopped_matching_selectors)); | 2393 stopped_matching_selectors)); |
2378 } | 2394 } |
(...skipping 2835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5214 mojo::ServiceProviderPtr service_provider(21); | 5230 mojo::ServiceProviderPtr service_provider(21); |
5215 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5231 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5216 request->url = mojo::String::From(url); | 5232 request->url = mojo::String::From(url); |
5217 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5233 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5218 nullptr, nullptr, | 5234 nullptr, nullptr, |
5219 base::Bind(&OnGotContentHandlerID)); | 5235 base::Bind(&OnGotContentHandlerID)); |
5220 return service_provider.Pass(); | 5236 return service_provider.Pass(); |
5221 } | 5237 } |
5222 | 5238 |
5223 } // namespace content | 5239 } // namespace content |
OLD | NEW |