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

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: move setSandboxFlags call Created 5 years, 2 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
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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 OnRunJavaScriptMessage) 459 OnRunJavaScriptMessage)
461 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, 460 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm,
462 OnRunBeforeUnloadConfirm) 461 OnRunBeforeUnloadConfirm)
463 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, 462 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument,
464 OnDidAccessInitialDocument) 463 OnDidAccessInitialDocument)
465 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) 464 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener)
466 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName) 465 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName)
467 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) 466 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId)
468 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags, 467 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags,
469 OnDidChangeSandboxFlags) 468 OnDidChangeSandboxFlags)
469 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties,
470 OnDidChangeFrameOwnerProperties)
470 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) 471 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
471 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) 472 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
472 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, 473 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation,
473 OnBeginNavigation) 474 OnBeginNavigation)
474 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) 475 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad)
475 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, 476 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
476 OnTextSurroundingSelectionResponse) 477 OnTextSurroundingSelectionResponse)
477 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) 478 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
478 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, 479 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges,
479 OnAccessibilityLocationChanges) 480 OnAccessibilityLocationChanges)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 631
631 DCHECK(GetProcess()->HasConnection()); 632 DCHECK(GetProcess()->HasConnection());
632 633
633 FrameMsg_NewFrame_Params params; 634 FrameMsg_NewFrame_Params params;
634 params.routing_id = routing_id_; 635 params.routing_id = routing_id_;
635 params.proxy_routing_id = proxy_routing_id; 636 params.proxy_routing_id = proxy_routing_id;
636 params.opener_routing_id = opener_routing_id; 637 params.opener_routing_id = opener_routing_id;
637 params.parent_routing_id = parent_routing_id; 638 params.parent_routing_id = parent_routing_id;
638 params.previous_sibling_routing_id = previous_sibling_routing_id; 639 params.previous_sibling_routing_id = previous_sibling_routing_id;
639 params.replication_state = frame_tree_node()->current_replication_state(); 640 params.replication_state = frame_tree_node()->current_replication_state();
641 params.frame_owner_properties = frame_tree_node()->frame_owner_properties();
640 642
641 if (render_widget_host_) { 643 if (render_widget_host_) {
642 params.widget_params.routing_id = render_widget_host_->GetRoutingID(); 644 params.widget_params.routing_id = render_widget_host_->GetRoutingID();
643 params.widget_params.hidden = render_widget_host_->is_hidden(); 645 params.widget_params.hidden = render_widget_host_->is_hidden();
644 } else { 646 } else {
645 // MSG_ROUTING_NONE will prevent a new RenderWidget from being created in 647 // MSG_ROUTING_NONE will prevent a new RenderWidget from being created in
646 // the renderer process. 648 // the renderer process.
647 params.widget_params.routing_id = MSG_ROUTING_NONE; 649 params.widget_params.routing_id = MSG_ROUTING_NONE;
648 params.widget_params.hidden = true; 650 params.widget_params.hidden = true;
649 } 651 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() 721 logging::LogMessage("CONSOLE", line_no, resolved_level).stream()
720 << "\"" << message << "\", source: " << source_id << " (" << line_no 722 << "\"" << message << "\", source: " << source_id << " (" << line_no
721 << ")"; 723 << ")";
722 } 724 }
723 } 725 }
724 726
725 void RenderFrameHostImpl::OnCreateChildFrame( 727 void RenderFrameHostImpl::OnCreateChildFrame(
726 int new_routing_id, 728 int new_routing_id,
727 blink::WebTreeScopeType scope, 729 blink::WebTreeScopeType scope,
728 const std::string& frame_name, 730 const std::string& frame_name,
729 blink::WebSandboxFlags sandbox_flags) { 731 blink::WebSandboxFlags sandbox_flags,
732 const blink::WebFrameOwnerProperties& frame_owner_properties) {
730 // It is possible that while a new RenderFrameHost was committed, the 733 // It is possible that while a new RenderFrameHost was committed, the
731 // RenderFrame corresponding to this host sent an IPC message to create a 734 // RenderFrame corresponding to this host sent an IPC message to create a
732 // frame and it is delivered after this host is swapped out. 735 // frame and it is delivered after this host is swapped out.
733 // Ignore such messages, as we know this RenderFrameHost is going away. 736 // Ignore such messages, as we know this RenderFrameHost is going away.
734 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT) 737 if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT)
735 return; 738 return;
736 739
737 RenderFrameHostImpl* new_frame = 740 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame(
738 frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), 741 frame_tree_node_, GetProcess()->GetID(), new_routing_id, scope,
739 new_routing_id, scope, frame_name, sandbox_flags); 742 frame_name, sandbox_flags, frame_owner_properties);
740 if (!new_frame) 743 if (!new_frame)
741 return; 744 return;
742 745
743 // We know that the RenderFrame has been created in this case, immediately 746 // We know that the RenderFrame has been created in this case, immediately
744 // after the CreateChildFrame IPC was sent. 747 // after the CreateChildFrame IPC was sent.
745 new_frame->SetRenderFrameCreated(true); 748 new_frame->SetRenderFrameCreated(true);
746 } 749 }
747 750
748 void RenderFrameHostImpl::OnDetach() { 751 void RenderFrameHostImpl::OnDetach() {
749 frame_tree_->RemoveFrame(frame_tree_node_); 752 frame_tree_->RemoveFrame(frame_tree_node_);
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame(); 1304 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame();
1302 delegate_->DidChangeName(this, name); 1305 delegate_->DidChangeName(this, name);
1303 } 1306 }
1304 1307
1305 void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) { 1308 void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) {
1306 // Update the RVH's current page ID so that future IPCs from the renderer 1309 // Update the RVH's current page ID so that future IPCs from the renderer
1307 // correspond to the new page. 1310 // correspond to the new page.
1308 render_view_host_->page_id_ = page_id; 1311 render_view_host_->page_id_ = page_id;
1309 } 1312 }
1310 1313
1314 FrameTreeNode* RenderFrameHostImpl::FindAndVerifyChild(
1315 int32 child_frame_routing_id,
1316 bad_message::BadMessageReason reason) {
1317 FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID(
1318 GetProcess()->GetID(), child_frame_routing_id);
1319 if (child && child->parent() != frame_tree_node()) {
1320 bad_message::ReceivedBadMessage(GetProcess(), reason);
1321 return nullptr;
1322 }
1323 return child;
dcheng 2015/10/21 21:04:01 I assume we explicitly allow not finding a child,
lazyboy 2015/10/23 21:19:35 Yes, I believe so (this pattern already existed in
1324 }
1325
1311 void RenderFrameHostImpl::OnDidChangeSandboxFlags( 1326 void RenderFrameHostImpl::OnDidChangeSandboxFlags(
1312 int32 frame_routing_id, 1327 int32 frame_routing_id,
1313 blink::WebSandboxFlags flags) { 1328 blink::WebSandboxFlags flags) {
1314 FrameTree* frame_tree = frame_tree_node()->frame_tree(); 1329 // Ensure that a frame can only update sandbox flags for its immediate
1315 FrameTreeNode* child = 1330 // children. If this is not the case, the renderer is considered malicious
1316 frame_tree->FindByRoutingID(GetProcess()->GetID(), frame_routing_id); 1331 // and is killed.
1332 FrameTreeNode* child = FindAndVerifyChild(
1333 frame_routing_id, bad_message::RFH_SANDBOX_FLAGS);
1317 if (!child) 1334 if (!child)
1318 return; 1335 return;
1319 1336
1320 // Ensure that a frame can only update sandbox flags for its immediate
1321 // children. If this is not the case, the renderer is considered malicious
1322 // and is killed.
1323 if (child->parent() != frame_tree_node()) {
1324 bad_message::ReceivedBadMessage(GetProcess(),
1325 bad_message::RFH_SANDBOX_FLAGS);
1326 return;
1327 }
1328
1329 child->set_sandbox_flags(flags); 1337 child->set_sandbox_flags(flags);
1330 1338
1331 // Notify the RenderFrame if it lives in a different process from its 1339 // Notify the RenderFrame if it lives in a different process from its
1332 // parent. The frame's proxies in other processes also need to learn about 1340 // parent. The frame's proxies in other processes also need to learn about
1333 // the updated sandbox flags, but these notifications are sent later in 1341 // the updated sandbox flags, but these notifications are sent later in
1334 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame 1342 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame
1335 // navigates and the new sandbox flags take effect. 1343 // navigates and the new sandbox flags take effect.
1336 RenderFrameHost* child_rfh = child->current_frame_host(); 1344 RenderFrameHost* child_rfh = child->current_frame_host();
1337 if (child_rfh->GetSiteInstance() != GetSiteInstance()) { 1345 if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
1338 child_rfh->Send( 1346 child_rfh->Send(
1339 new FrameMsg_DidUpdateSandboxFlags(child_rfh->GetRoutingID(), flags)); 1347 new FrameMsg_DidUpdateSandboxFlags(child_rfh->GetRoutingID(), flags));
1340 } 1348 }
1341 } 1349 }
1342 1350
1351 void RenderFrameHostImpl::OnDidChangeFrameOwnerProperties(
1352 int32 frame_routing_id,
1353 const blink::WebFrameOwnerProperties& frame_owner_properties) {
1354 FrameTreeNode* child = FindAndVerifyChild(
1355 frame_routing_id, bad_message::RFH_OWNER_PROPERTY);
1356 if (!child)
1357 return;
1358
1359 child->set_frame_owner_properties(frame_owner_properties);
1360
1361 // Notify the RenderFrame if it lives in a different process from its parent.
1362 // These properties only affect the RenderFrame and live in its parent
1363 // (HTMLFrameOwnerElement). Therefore, we do not need to notify this frame's
1364 // proxies.
1365 RenderFrameHost* child_rfh = child->current_frame_host();
1366 if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
1367 child_rfh->Send(new FrameMsg_SetFrameOwnerProperties(
1368 child_rfh->GetRoutingID(), frame_owner_properties));
1369 }
1370 }
1371
1343 void RenderFrameHostImpl::OnUpdateTitle( 1372 void RenderFrameHostImpl::OnUpdateTitle(
1344 const base::string16& title, 1373 const base::string16& title,
1345 blink::WebTextDirection title_direction) { 1374 blink::WebTextDirection title_direction) {
1346 // This message is only sent for top-level frames. TODO(avi): when frame tree 1375 // This message is only sent for top-level frames. TODO(avi): when frame tree
1347 // mirroring works correctly, add a check here to enforce it. 1376 // mirroring works correctly, add a check here to enforce it.
1348 if (title.length() > kMaxTitleChars) { 1377 if (title.length() > kMaxTitleChars) {
1349 NOTREACHED() << "Renderer sent too many characters in title."; 1378 NOTREACHED() << "Renderer sent too many characters in title.";
1350 return; 1379 return;
1351 } 1380 }
1352 1381
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 BrowserPluginInstanceIDToAXTreeID(value))); 2299 BrowserPluginInstanceIDToAXTreeID(value)));
2271 break; 2300 break;
2272 case AX_CONTENT_INT_ATTRIBUTE_LAST: 2301 case AX_CONTENT_INT_ATTRIBUTE_LAST:
2273 NOTREACHED(); 2302 NOTREACHED();
2274 break; 2303 break;
2275 } 2304 }
2276 } 2305 }
2277 } 2306 }
2278 2307
2279 } // namespace content 2308 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698