Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_impl.cc |
| diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
| index 488fad6ac2f16a5c604f863a188a6f637b7552a6..fbb1c4639a2533451f29abef3291dd769f601672 100644 |
| --- a/content/browser/frame_host/render_frame_host_impl.cc |
| +++ b/content/browser/frame_host/render_frame_host_impl.cc |
| @@ -15,7 +15,6 @@ |
| #include "content/browser/accessibility/ax_tree_id_registry.h" |
| #include "content/browser/accessibility/browser_accessibility_manager.h" |
| #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| -#include "content/browser/bad_message.h" |
| #include "content/browser/child_process_security_policy_impl.h" |
| #include "content/browser/frame_host/cross_process_frame_connector.h" |
| #include "content/browser/frame_host/cross_site_transferring_request.h" |
| @@ -464,6 +463,8 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) |
| IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags, |
| OnDidChangeSandboxFlags) |
| + IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, |
| + OnDidChangeFrameOwnerProperties) |
| IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) |
| IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) |
| IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, |
| @@ -629,6 +630,7 @@ bool RenderFrameHostImpl::CreateRenderFrame(int proxy_routing_id, |
| params.parent_routing_id = parent_routing_id; |
| params.previous_sibling_routing_id = previous_sibling_routing_id; |
| params.replication_state = frame_tree_node()->current_replication_state(); |
| + params.frame_owner_properties = frame_tree_node()->frame_owner_properties(); |
| if (render_widget_host_) { |
| params.widget_params.routing_id = render_widget_host_->GetRoutingID(); |
| @@ -718,7 +720,8 @@ void RenderFrameHostImpl::OnCreateChildFrame( |
| int new_routing_id, |
| blink::WebTreeScopeType scope, |
| const std::string& frame_name, |
| - blink::WebSandboxFlags sandbox_flags) { |
| + blink::WebSandboxFlags sandbox_flags, |
| + const blink::WebFrameOwnerProperties& frame_owner_properties) { |
| // It is possible that while a new RenderFrameHost was committed, the |
| // RenderFrame corresponding to this host sent an IPC message to create a |
| // frame and it is delivered after this host is swapped out. |
| @@ -726,9 +729,9 @@ void RenderFrameHostImpl::OnCreateChildFrame( |
| if (rfh_state_ != RenderFrameHostImpl::STATE_DEFAULT) |
| return; |
| - RenderFrameHostImpl* new_frame = |
| - frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), |
| - new_routing_id, scope, frame_name, sandbox_flags); |
| + RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( |
| + frame_tree_node_, GetProcess()->GetID(), new_routing_id, scope, |
| + frame_name, sandbox_flags, frame_owner_properties); |
| if (!new_frame) |
| return; |
| @@ -1305,20 +1308,13 @@ void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) { |
| void RenderFrameHostImpl::OnDidChangeSandboxFlags( |
| int32 frame_routing_id, |
| blink::WebSandboxFlags flags) { |
| - FrameTree* frame_tree = frame_tree_node()->frame_tree(); |
| - FrameTreeNode* child = |
| - frame_tree->FindByRoutingID(GetProcess()->GetID(), frame_routing_id); |
| - if (!child) |
| - return; |
| - |
| // Ensure that a frame can only update sandbox flags for its immediate |
| // children. If this is not the case, the renderer is considered malicious |
| // and is killed. |
| - if (child->parent() != frame_tree_node()) { |
| - bad_message::ReceivedBadMessage(GetProcess(), |
| - bad_message::RFH_SANDBOX_FLAGS); |
| + FrameTreeNode* child = CheckAndGetIfImmediateChild( |
| + frame_routing_id, bad_message::RFH_SANDBOX_FLAGS); |
| + if (!child) |
| return; |
| - } |
| child->set_sandbox_flags(flags); |
| @@ -1334,6 +1330,36 @@ void RenderFrameHostImpl::OnDidChangeSandboxFlags( |
| } |
| } |
| +FrameTreeNode* RenderFrameHostImpl::CheckAndGetIfImmediateChild( |
| + int32 child_frame_routing_id, bad_message::BadMessageReason reason) { |
|
alexmos
2015/10/02 21:24:20
nit: second parameter on separate line?
lazyboy
2015/10/05 22:16:08
Done.
|
| + FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID( |
| + GetProcess()->GetID(), child_frame_routing_id); |
| + if (child && child->parent() != frame_tree_node()) { |
| + bad_message::ReceivedBadMessage(GetProcess(), reason); |
| + return nullptr; |
| + } |
| + return child; |
| +} |
| + |
| +void RenderFrameHostImpl::OnDidChangeFrameOwnerProperties( |
| + int32 frame_routing_id, |
| + const blink::WebFrameOwnerProperties& frame_owner_properties) { |
| + FrameTreeNode* child = CheckAndGetIfImmediateChild( |
| + frame_routing_id, bad_message::RFH_OWNER_PROPERTY); |
| + if (!child) |
| + return; |
| + |
| + child->set_frame_owner_properties(frame_owner_properties); |
| + |
| + // Notify the RenderFrame if it lives in a different process from its |
| + // parent. |
| + RenderFrameHost* child_rfh = child->current_frame_host(); |
| + if (child_rfh->GetSiteInstance() != GetSiteInstance()) { |
| + child_rfh->Send(new FrameMsg_SetFrameOwnerProperties( |
| + child_rfh->GetRoutingID(), child->frame_owner_properties())); |
|
alexmos
2015/10/02 21:24:19
nit: why not just pass |frame_owner_properties|?
lazyboy
2015/10/05 22:16:08
Done.
|
| + } |
| +} |
| + |
| void RenderFrameHostImpl::OnUpdateTitle( |
| const base::string16& title, |
| blink::WebTextDirection title_direction) { |