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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1307013004: Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content_unittests compile fix Created 5 years, 1 month 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
OLDNEW
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/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/process/kill.h" 12 #include "base/process/kill.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/browser/accessibility/accessibility_mode_helper.h" 14 #include "content/browser/accessibility/accessibility_mode_helper.h"
15 #include "content/browser/accessibility/ax_tree_id_registry.h" 15 #include "content/browser/accessibility/ax_tree_id_registry.h"
16 #include "content/browser/accessibility/browser_accessibility_manager.h" 16 #include "content/browser/accessibility/browser_accessibility_manager.h"
17 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 17 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
18 #include "content/browser/bad_message.h"
19 #include "content/browser/child_process_security_policy_impl.h" 18 #include "content/browser/child_process_security_policy_impl.h"
20 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 19 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
21 #include "content/browser/frame_host/cross_process_frame_connector.h" 20 #include "content/browser/frame_host/cross_process_frame_connector.h"
22 #include "content/browser/frame_host/cross_site_transferring_request.h" 21 #include "content/browser/frame_host/cross_site_transferring_request.h"
23 #include "content/browser/frame_host/frame_mojo_shell.h" 22 #include "content/browser/frame_host/frame_mojo_shell.h"
24 #include "content/browser/frame_host/frame_tree.h" 23 #include "content/browser/frame_host/frame_tree.h"
25 #include "content/browser/frame_host/frame_tree_node.h" 24 #include "content/browser/frame_host/frame_tree_node.h"
26 #include "content/browser/frame_host/navigation_handle_impl.h" 25 #include "content/browser/frame_host/navigation_handle_impl.h"
27 #include "content/browser/frame_host/navigation_request.h" 26 #include "content/browser/frame_host/navigation_request.h"
28 #include "content/browser/frame_host/navigator.h" 27 #include "content/browser/frame_host/navigator.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 OnRunJavaScriptMessage) 472 OnRunJavaScriptMessage)
474 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, 473 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm,
475 OnRunBeforeUnloadConfirm) 474 OnRunBeforeUnloadConfirm)
476 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, 475 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument,
477 OnDidAccessInitialDocument) 476 OnDidAccessInitialDocument)
478 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) 477 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener)
479 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName) 478 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName)
480 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) 479 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId)
481 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags, 480 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags,
482 OnDidChangeSandboxFlags) 481 OnDidChangeSandboxFlags)
482 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties,
483 OnDidChangeFrameOwnerProperties)
483 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) 484 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
484 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) 485 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
485 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, 486 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation,
486 OnBeginNavigation) 487 OnBeginNavigation)
487 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) 488 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad)
488 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, 489 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
489 OnTextSurroundingSelectionResponse) 490 OnTextSurroundingSelectionResponse)
490 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) 491 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
491 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, 492 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges,
492 OnAccessibilityLocationChanges) 493 OnAccessibilityLocationChanges)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 644
644 DCHECK(GetProcess()->HasConnection()); 645 DCHECK(GetProcess()->HasConnection());
645 646
646 FrameMsg_NewFrame_Params params; 647 FrameMsg_NewFrame_Params params;
647 params.routing_id = routing_id_; 648 params.routing_id = routing_id_;
648 params.proxy_routing_id = proxy_routing_id; 649 params.proxy_routing_id = proxy_routing_id;
649 params.opener_routing_id = opener_routing_id; 650 params.opener_routing_id = opener_routing_id;
650 params.parent_routing_id = parent_routing_id; 651 params.parent_routing_id = parent_routing_id;
651 params.previous_sibling_routing_id = previous_sibling_routing_id; 652 params.previous_sibling_routing_id = previous_sibling_routing_id;
652 params.replication_state = frame_tree_node()->current_replication_state(); 653 params.replication_state = frame_tree_node()->current_replication_state();
654 params.frame_owner_properties = frame_tree_node()->frame_owner_properties();
653 655
654 if (render_widget_host_) { 656 if (render_widget_host_) {
655 params.widget_params.routing_id = render_widget_host_->GetRoutingID(); 657 params.widget_params.routing_id = render_widget_host_->GetRoutingID();
656 params.widget_params.hidden = render_widget_host_->is_hidden(); 658 params.widget_params.hidden = render_widget_host_->is_hidden();
657 } else { 659 } else {
658 // MSG_ROUTING_NONE will prevent a new RenderWidget from being created in 660 // MSG_ROUTING_NONE will prevent a new RenderWidget from being created in
659 // the renderer process. 661 // the renderer process.
660 params.widget_params.routing_id = MSG_ROUTING_NONE; 662 params.widget_params.routing_id = MSG_ROUTING_NONE;
661 params.widget_params.hidden = true; 663 params.widget_params.hidden = true;
662 } 664 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() 737 logging::LogMessage("CONSOLE", line_no, resolved_level).stream()
736 << "\"" << message << "\", source: " << source_id << " (" << line_no 738 << "\"" << message << "\", source: " << source_id << " (" << line_no
737 << ")"; 739 << ")";
738 } 740 }
739 } 741 }
740 742
741 void RenderFrameHostImpl::OnCreateChildFrame( 743 void RenderFrameHostImpl::OnCreateChildFrame(
742 int new_routing_id, 744 int new_routing_id,
743 blink::WebTreeScopeType scope, 745 blink::WebTreeScopeType scope,
744 const std::string& frame_name, 746 const std::string& frame_name,
745 blink::WebSandboxFlags sandbox_flags) { 747 blink::WebSandboxFlags sandbox_flags,
748 const blink::WebFrameOwnerProperties& frame_owner_properties) {
746 // It is possible that while a new RenderFrameHost was committed, the 749 // It is possible that while a new RenderFrameHost was committed, the
747 // RenderFrame corresponding to this host sent an IPC message to create a 750 // RenderFrame corresponding to this host sent an IPC message to create a
748 // frame and it is delivered after this host is swapped out. 751 // frame and it is delivered after this host is swapped out.
749 // Ignore such messages, as we know this RenderFrameHost is going away. 752 // Ignore such messages, as we know this RenderFrameHost is going away.
750 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT) 753 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT)
751 return; 754 return;
752 755
753 RenderFrameHostImpl* new_frame = 756 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame(
754 frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), 757 frame_tree_node_, GetProcess()->GetID(), new_routing_id, scope,
755 new_routing_id, scope, frame_name, sandbox_flags); 758 frame_name, sandbox_flags, frame_owner_properties);
756 if (!new_frame) 759 if (!new_frame)
757 return; 760 return;
758 761
759 // We know that the RenderFrame has been created in this case, immediately 762 // We know that the RenderFrame has been created in this case, immediately
760 // after the CreateChildFrame IPC was sent. 763 // after the CreateChildFrame IPC was sent.
761 new_frame->SetRenderFrameCreated(true); 764 new_frame->SetRenderFrameCreated(true);
762 } 765 }
763 766
764 void RenderFrameHostImpl::OnDetach() { 767 void RenderFrameHostImpl::OnDetach() {
765 frame_tree_->RemoveFrame(frame_tree_node_); 768 frame_tree_->RemoveFrame(frame_tree_node_);
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame(); 1313 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame();
1311 delegate_->DidChangeName(this, name); 1314 delegate_->DidChangeName(this, name);
1312 } 1315 }
1313 1316
1314 void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) { 1317 void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) {
1315 // Update the RVH's current page ID so that future IPCs from the renderer 1318 // Update the RVH's current page ID so that future IPCs from the renderer
1316 // correspond to the new page. 1319 // correspond to the new page.
1317 render_view_host_->page_id_ = page_id; 1320 render_view_host_->page_id_ = page_id;
1318 } 1321 }
1319 1322
1323 FrameTreeNode* RenderFrameHostImpl::FindAndVerifyChild(
1324 int32 child_frame_routing_id,
1325 bad_message::BadMessageReason reason) {
1326 FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID(
1327 GetProcess()->GetID(), child_frame_routing_id);
1328 // A race can result in |child| to be nullptr. Avoid killing the renderer in
1329 // that case.
1330 if (child && child->parent() != frame_tree_node()) {
1331 bad_message::ReceivedBadMessage(GetProcess(), reason);
1332 return nullptr;
1333 }
1334 return child;
1335 }
1336
1320 void RenderFrameHostImpl::OnDidChangeSandboxFlags( 1337 void RenderFrameHostImpl::OnDidChangeSandboxFlags(
1321 int32 frame_routing_id, 1338 int32 frame_routing_id,
1322 blink::WebSandboxFlags flags) { 1339 blink::WebSandboxFlags flags) {
1323 FrameTree* frame_tree = frame_tree_node()->frame_tree(); 1340 // Ensure that a frame can only update sandbox flags for its immediate
1324 FrameTreeNode* child = 1341 // children. If this is not the case, the renderer is considered malicious
1325 frame_tree->FindByRoutingID(GetProcess()->GetID(), frame_routing_id); 1342 // and is killed.
1343 FrameTreeNode* child = FindAndVerifyChild(
1344 frame_routing_id, bad_message::RFH_SANDBOX_FLAGS);
1326 if (!child) 1345 if (!child)
1327 return; 1346 return;
1328 1347
1329 // Ensure that a frame can only update sandbox flags for its immediate
1330 // children. If this is not the case, the renderer is considered malicious
1331 // and is killed.
1332 if (child->parent() != frame_tree_node()) {
1333 bad_message::ReceivedBadMessage(GetProcess(),
1334 bad_message::RFH_SANDBOX_FLAGS);
1335 return;
1336 }
1337
1338 child->set_sandbox_flags(flags); 1348 child->set_sandbox_flags(flags);
1339 1349
1340 // Notify the RenderFrame if it lives in a different process from its 1350 // Notify the RenderFrame if it lives in a different process from its
1341 // parent. The frame's proxies in other processes also need to learn about 1351 // parent. The frame's proxies in other processes also need to learn about
1342 // the updated sandbox flags, but these notifications are sent later in 1352 // the updated sandbox flags, but these notifications are sent later in
1343 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame 1353 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame
1344 // navigates and the new sandbox flags take effect. 1354 // navigates and the new sandbox flags take effect.
1345 RenderFrameHost* child_rfh = child->current_frame_host(); 1355 RenderFrameHost* child_rfh = child->current_frame_host();
1346 if (child_rfh->GetSiteInstance() != GetSiteInstance()) { 1356 if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
1347 child_rfh->Send( 1357 child_rfh->Send(
1348 new FrameMsg_DidUpdateSandboxFlags(child_rfh->GetRoutingID(), flags)); 1358 new FrameMsg_DidUpdateSandboxFlags(child_rfh->GetRoutingID(), flags));
1349 } 1359 }
1350 } 1360 }
1351 1361
1362 void RenderFrameHostImpl::OnDidChangeFrameOwnerProperties(
1363 int32 frame_routing_id,
1364 const blink::WebFrameOwnerProperties& frame_owner_properties) {
1365 FrameTreeNode* child = FindAndVerifyChild(
1366 frame_routing_id, bad_message::RFH_OWNER_PROPERTY);
1367 if (!child)
1368 return;
1369
1370 child->set_frame_owner_properties(frame_owner_properties);
1371
1372 // Notify the RenderFrame if it lives in a different process from its parent.
1373 // These properties only affect the RenderFrame and live in its parent
1374 // (HTMLFrameOwnerElement). Therefore, we do not need to notify this frame's
1375 // proxies.
1376 RenderFrameHost* child_rfh = child->current_frame_host();
1377 if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
1378 child_rfh->Send(new FrameMsg_SetFrameOwnerProperties(
1379 child_rfh->GetRoutingID(), frame_owner_properties));
1380 }
1381 }
1382
1352 void RenderFrameHostImpl::OnUpdateTitle( 1383 void RenderFrameHostImpl::OnUpdateTitle(
1353 const base::string16& title, 1384 const base::string16& title,
1354 blink::WebTextDirection title_direction) { 1385 blink::WebTextDirection title_direction) {
1355 // This message is only sent for top-level frames. TODO(avi): when frame tree 1386 // This message is only sent for top-level frames. TODO(avi): when frame tree
1356 // mirroring works correctly, add a check here to enforce it. 1387 // mirroring works correctly, add a check here to enforce it.
1357 if (title.length() > kMaxTitleChars) { 1388 if (title.length() > kMaxTitleChars) {
1358 NOTREACHED() << "Renderer sent too many characters in title."; 1389 NOTREACHED() << "Renderer sent too many characters in title.";
1359 return; 1390 return;
1360 } 1391 }
1361 1392
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 *dst = src; 2337 *dst = src;
2307 2338
2308 if (src.routing_id != -1) 2339 if (src.routing_id != -1)
2309 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); 2340 dst->tree_id = RoutingIDToAXTreeID(src.routing_id);
2310 2341
2311 if (src.parent_routing_id != -1) 2342 if (src.parent_routing_id != -1)
2312 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); 2343 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id);
2313 } 2344 }
2314 2345
2315 } // namespace content 2346 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698