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

Side by Side Diff: content/renderer/render_frame_proxy.cc

Issue 2797813002: Replicate feature policy container policies. (Closed)
Patch Set: Addressing review comments Created 3 years, 8 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
« no previous file with comments | « content/renderer/render_frame_proxy.h ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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),
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
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) {
254 web_frame_->SetReplicatedSandboxFlags(flags); 258 web_frame_->SetReplicatedSandboxFlags(flags);
255 web_frame_->SetFrameOwnerSandboxFlags(flags); 259 web_frame_->SetFrameOwnerPolicy(flags,
260 FeaturePolicyHeaderToWeb(container_policy));
256 } 261 }
257 262
258 bool RenderFrameProxy::OnMessageReceived(const IPC::Message& msg) { 263 bool RenderFrameProxy::OnMessageReceived(const IPC::Message& msg) {
259 // Forward Page IPCs to the RenderView. 264 // Forward Page IPCs to the RenderView.
260 if ((IPC_MESSAGE_CLASS(msg) == PageMsgStart)) { 265 if ((IPC_MESSAGE_CLASS(msg) == PageMsgStart)) {
261 if (render_view()) 266 if (render_view())
262 return render_view()->OnMessageReceived(msg); 267 return render_view()->OnMessageReceived(msg);
263 268
264 return false; 269 return false;
265 } 270 }
266 271
267 bool handled = true; 272 bool handled = true;
268 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxy, msg) 273 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxy, msg)
269 IPC_MESSAGE_HANDLER(FrameMsg_DeleteProxy, OnDeleteProxy) 274 IPC_MESSAGE_HANDLER(FrameMsg_DeleteProxy, OnDeleteProxy)
270 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone) 275 IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone)
271 IPC_MESSAGE_HANDLER(FrameMsg_SetChildFrameSurface, OnSetChildFrameSurface) 276 IPC_MESSAGE_HANDLER(FrameMsg_SetChildFrameSurface, OnSetChildFrameSurface)
272 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener) 277 IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener)
273 IPC_MESSAGE_HANDLER(FrameMsg_DidStartLoading, OnDidStartLoading) 278 IPC_MESSAGE_HANDLER(FrameMsg_DidStartLoading, OnDidStartLoading)
274 IPC_MESSAGE_HANDLER(FrameMsg_DidStopLoading, OnDidStopLoading) 279 IPC_MESSAGE_HANDLER(FrameMsg_DidStopLoading, OnDidStopLoading)
275 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateSandboxFlags, OnDidUpdateSandboxFlags) 280 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateFramePolicy, OnDidUpdateFramePolicy)
276 IPC_MESSAGE_HANDLER(FrameMsg_DispatchLoad, OnDispatchLoad) 281 IPC_MESSAGE_HANDLER(FrameMsg_DispatchLoad, OnDispatchLoad)
277 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateName, OnDidUpdateName) 282 IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateName, OnDidUpdateName)
278 IPC_MESSAGE_HANDLER(FrameMsg_AddContentSecurityPolicies, 283 IPC_MESSAGE_HANDLER(FrameMsg_AddContentSecurityPolicies,
279 OnAddContentSecurityPolicies) 284 OnAddContentSecurityPolicies)
280 IPC_MESSAGE_HANDLER(FrameMsg_ResetContentSecurityPolicy, 285 IPC_MESSAGE_HANDLER(FrameMsg_ResetContentSecurityPolicy,
281 OnResetContentSecurityPolicy) 286 OnResetContentSecurityPolicy)
282 IPC_MESSAGE_HANDLER(FrameMsg_EnforceInsecureRequestPolicy, 287 IPC_MESSAGE_HANDLER(FrameMsg_EnforceInsecureRequestPolicy,
283 OnEnforceInsecureRequestPolicy) 288 OnEnforceInsecureRequestPolicy)
284 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties, 289 IPC_MESSAGE_HANDLER(FrameMsg_SetFrameOwnerProperties,
285 OnSetFrameOwnerProperties) 290 OnSetFrameOwnerProperties)
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 blink::WebLocalFrame* source) { 528 blink::WebLocalFrame* source) {
524 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); 529 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID();
525 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); 530 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id));
526 } 531 }
527 532
528 void RenderFrameProxy::FrameFocused() { 533 void RenderFrameProxy::FrameFocused() {
529 Send(new FrameHostMsg_FrameFocused(routing_id_)); 534 Send(new FrameHostMsg_FrameFocused(routing_id_));
530 } 535 }
531 536
532 } // namespace 537 } // namespace
OLDNEW
« no previous file with comments | « content/renderer/render_frame_proxy.h ('k') | content/test/test_render_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698