Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_proxy.h" | 5 #include "content/renderer/render_frame_proxy.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 if (!render_view->is_swapped_out()) | 120 if (!render_view->is_swapped_out()) |
| 121 render_view->SetSwappedOut(true); | 121 render_view->SetSwappedOut(true); |
| 122 } else { | 122 } else { |
| 123 // Create a frame under an existing parent. The parent is always expected | 123 // Create a frame under an existing parent. The parent is always expected |
| 124 // to be a RenderFrameProxy, because navigations initiated by local frames | 124 // to be a RenderFrameProxy, because navigations initiated by local frames |
| 125 // should not wind up here. | 125 // should not wind up here. |
| 126 | 126 |
| 127 web_frame = parent->web_frame()->createRemoteChild( | 127 web_frame = parent->web_frame()->createRemoteChild( |
| 128 replicated_state.scope, | 128 replicated_state.scope, |
| 129 blink::WebString::fromUTF8(replicated_state.name), | 129 blink::WebString::fromUTF8(replicated_state.name), |
| 130 replicated_state.sandbox_flags, proxy.get(), opener); | 130 replicated_state.sandbox_flags, |
| 131 FeaturePolicyHeaderToWeb(replicated_state.container_policy), | |
|
lunalu1
2017/04/05 22:30:03
same here
iclelland
2017/04/09 03:25:54
Sorry, not sure what this refers to
| |
| 132 proxy.get(), opener); | |
| 131 proxy->unique_name_ = replicated_state.unique_name; | 133 proxy->unique_name_ = replicated_state.unique_name; |
| 132 render_view = parent->render_view(); | 134 render_view = parent->render_view(); |
| 133 render_widget = parent->render_widget(); | 135 render_widget = parent->render_widget(); |
| 134 } | 136 } |
| 135 | 137 |
| 136 proxy->Init(web_frame, render_view, render_widget); | 138 proxy->Init(web_frame, render_view, render_widget); |
| 137 | 139 |
| 138 // Initialize proxy's WebRemoteFrame with the security origin and other | 140 // Initialize proxy's WebRemoteFrame with the security origin and other |
| 139 // replicated information. | 141 // replicated information. |
| 140 // TODO(dcheng): Calling this when parent_routing_id != MSG_ROUTING_NONE is | 142 // TODO(dcheng): Calling this when parent_routing_id != MSG_ROUTING_NONE is |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 web_frame_->setReplicatedFeaturePolicyHeader( | 230 web_frame_->setReplicatedFeaturePolicyHeader( |
| 229 FeaturePolicyHeaderToWeb(state.feature_policy_header)); | 231 FeaturePolicyHeaderToWeb(state.feature_policy_header)); |
| 230 if (state.has_received_user_gesture) | 232 if (state.has_received_user_gesture) |
| 231 web_frame_->setHasReceivedUserGesture(); | 233 web_frame_->setHasReceivedUserGesture(); |
| 232 | 234 |
| 233 web_frame_->resetReplicatedContentSecurityPolicy(); | 235 web_frame_->resetReplicatedContentSecurityPolicy(); |
| 234 OnAddContentSecurityPolicies(state.accumulated_csp_headers); | 236 OnAddContentSecurityPolicies(state.accumulated_csp_headers); |
| 235 } | 237 } |
| 236 | 238 |
| 237 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags | 239 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags |
| 238 // that were set by its parent in another process. | 240 // and container policy that were set by its parent in another process. |
| 239 // | 241 // |
| 240 // Normally, when a frame's sandbox attribute is changed dynamically, the | 242 // Normally, when a frame's sandbox attribute is changed dynamically, the |
| 241 // frame's FrameOwner is updated with the new sandbox flags right away, while | 243 // frame's FrameOwner is updated with the new sandbox flags right away, while |
| 242 // the frame's SecurityContext is updated when the frame is navigated and the | 244 // the frame's SecurityContext is updated when the frame is navigated and the |
| 243 // new sandbox flags take effect. | 245 // new sandbox flags take effect. |
| 244 // | 246 // |
| 245 // Currently, there is no use case for a proxy's pending FrameOwner sandbox | 247 // Currently, there is no use case for a proxy's pending FrameOwner sandbox |
| 246 // flags, so there's no message sent to proxies when the sandbox attribute is | 248 // flags, so there's no message sent to proxies when the sandbox attribute is |
| 247 // first updated. Instead, the update message is sent and this function is | 249 // first updated. Instead, the update message is sent and this function is |
| 248 // called when the new flags take effect, so that the proxy updates its | 250 // called when the new flags take effect, so that the proxy updates its |
| 249 // SecurityContext. This is needed to ensure that sandbox flags are inherited | 251 // SecurityContext. This is needed to ensure that sandbox flags are inherited |
| 250 // properly if this proxy ever parents a local frame. The proxy's FrameOwner | 252 // properly if this proxy ever parents a local frame. The proxy's FrameOwner |
| 251 // flags are also updated here with the caveat that the FrameOwner won't learn | 253 // flags are also updated here with the caveat that the FrameOwner won't learn |
| 252 // about updates to its flags until they take effect. | 254 // about updates to its flags until they take effect. |
| 253 void RenderFrameProxy::OnDidUpdateSandboxFlags(blink::WebSandboxFlags flags) { | 255 void RenderFrameProxy::OnDidUpdateFramePolicy( |
| 256 blink::WebSandboxFlags flags, | |
| 257 const ParsedFeaturePolicyHeader& container_policy) { | |
|
lunalu1
2017/04/05 22:30:03
Can we rename ParsedFeaturePolicyHeader to ParsedF
iclelland
2017/04/09 03:25:54
I'll file another CL to rename that, to avoid maki
| |
| 254 web_frame_->setReplicatedSandboxFlags(flags); | 258 web_frame_->setReplicatedSandboxFlags(flags); |
| 255 web_frame_->setFrameOwnerSandboxFlags(flags); | 259 web_frame_->setFrameOwnerSandboxFlags(flags); |
| 260 web_frame_->setFrameOwnerContainerPolicy( | |
| 261 FeaturePolicyHeaderToWeb(container_policy)); | |
| 256 } | 262 } |
| 257 | 263 |
| 258 bool RenderFrameProxy::OnMessageReceived(const IPC::Message& msg) { | 264 bool RenderFrameProxy::OnMessageReceived(const IPC::Message& msg) { |
| 259 // Forward Page IPCs to the RenderView. | 265 // Forward Page IPCs to the RenderView. |
| 260 if ((IPC_MESSAGE_CLASS(msg) == PageMsgStart)) { | 266 if ((IPC_MESSAGE_CLASS(msg) == PageMsgStart)) { |
| 261 if (render_view()) | 267 if (render_view()) |
| 262 return render_view()->OnMessageReceived(msg); | 268 return render_view()->OnMessageReceived(msg); |
| 263 | 269 |
| 264 return false; | 270 return false; |
| 265 } | 271 } |
| 266 | 272 |
| 267 bool handled = true; | 273 bool handled = true; |
| 268 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxy, msg) | 274 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxy, msg) |
| 269 IPC_MESSAGE_HANDLER(FrameMsg_DeleteProxy, OnDeleteProxy) | 275 IPC_MESSAGE_HANDLER(FrameMsg_DeleteProxy, OnDeleteProxy) |
| 270 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) | 276 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) |
| 271 IPC_MESSAGE_HANDLER(FrameMsg_SetChildFrameSurface, OnSetChildFrameSurface) | 277 IPC_MESSAGE_HANDLER(FrameMsg_SetChildFrameSurface, OnSetChildFrameSurface) |
| 272 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) | 278 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) |
| 273 IPC_MESSAGE_HANDLER(FrameMsg_DidStartLoading, OnDidStartLoading) | 279 IPC_MESSAGE_HANDLER(FrameMsg_DidStartLoading, OnDidStartLoading) |
| 274 IPC_MESSAGE_HANDLER(FrameMsg_DidStopLoading, OnDidStopLoading) | 280 IPC_MESSAGE_HANDLER(FrameMsg_DidStopLoading, OnDidStopLoading) |
| 275 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) | 281 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateFramePolicy, OnDidUpdateFramePolicy) |
| 276 IPC_MESSAGE_HANDLER(FrameMsg_DispatchLoad, OnDispatchLoad) | 282 IPC_MESSAGE_HANDLER(FrameMsg_DispatchLoad, OnDispatchLoad) |
| 277 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateName, OnDidUpdateName) | 283 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateName, OnDidUpdateName) |
| 278 IPC_MESSAGE_HANDLER(FrameMsg_AddContentSecurityPolicies, | 284 IPC_MESSAGE_HANDLER(FrameMsg_AddContentSecurityPolicies, |
| 279 OnAddContentSecurityPolicies) | 285 OnAddContentSecurityPolicies) |
| 280 IPC_MESSAGE_HANDLER(FrameMsg_ResetContentSecurityPolicy, | 286 IPC_MESSAGE_HANDLER(FrameMsg_ResetContentSecurityPolicy, |
| 281 OnResetContentSecurityPolicy) | 287 OnResetContentSecurityPolicy) |
| 282 IPC_MESSAGE_HANDLER(FrameMsg_EnforceInsecureRequestPolicy, | 288 IPC_MESSAGE_HANDLER(FrameMsg_EnforceInsecureRequestPolicy, |
| 283 OnEnforceInsecureRequestPolicy) | 289 OnEnforceInsecureRequestPolicy) |
| 284 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties, | 290 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties, |
| 285 OnSetFrameOwnerProperties) | 291 OnSetFrameOwnerProperties) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 blink::WebLocalFrame* source) { | 530 blink::WebLocalFrame* source) { |
| 525 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); | 531 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); |
| 526 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); | 532 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); |
| 527 } | 533 } |
| 528 | 534 |
| 529 void RenderFrameProxy::frameFocused() { | 535 void RenderFrameProxy::frameFocused() { |
| 530 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 536 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
| 531 } | 537 } |
| 532 | 538 |
| 533 } // namespace | 539 } // namespace |
| OLD | NEW |