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

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

Issue 2654873004: Move content-side Feature Policy code into content/{common,child}/feature_policy (Closed)
Patch Set: Fix missed nit Created 3 years, 11 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_impl.cc ('k') | no next file » | 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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "content/child/feature_policy/feature_policy_platform.h"
13 #include "content/child/web_url_request_util.h" 14 #include "content/child/web_url_request_util.h"
14 #include "content/child/webmessageportchannel_impl.h" 15 #include "content/child/webmessageportchannel_impl.h"
15 #include "content/common/content_security_policy_header.h" 16 #include "content/common/content_security_policy_header.h"
16 #include "content/common/content_switches_internal.h" 17 #include "content/common/content_switches_internal.h"
17 #include "content/common/frame_messages.h" 18 #include "content/common/frame_messages.h"
18 #include "content/common/frame_owner_properties.h" 19 #include "content/common/frame_owner_properties.h"
19 #include "content/common/frame_replication_state.h" 20 #include "content/common/frame_replication_state.h"
20 #include "content/common/input_messages.h" 21 #include "content/common/input_messages.h"
21 #include "content/common/page_messages.h" 22 #include "content/common/page_messages.h"
22 #include "content/common/site_isolation_policy.h" 23 #include "content/common/site_isolation_policy.h"
(...skipping 19 matching lines...) Expand all
42 43
43 // Facilitates lookup of RenderFrameProxy by routing_id. 44 // Facilitates lookup of RenderFrameProxy by routing_id.
44 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; 45 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap;
45 static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map = 46 static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map =
46 LAZY_INSTANCE_INITIALIZER; 47 LAZY_INSTANCE_INITIALIZER;
47 48
48 // Facilitates lookup of RenderFrameProxy by WebFrame. 49 // Facilitates lookup of RenderFrameProxy by WebFrame.
49 typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap; 50 typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap;
50 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; 51 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER;
51 52
52 blink::WebParsedFeaturePolicyHeader ToWebParsedFeaturePolicyHeader(
53 const ParsedFeaturePolicyHeader& parsed_header) {
54 std::vector<blink::WebParsedFeaturePolicyDeclaration> result;
55 for (const ParsedFeaturePolicyDeclaration& declaration : parsed_header) {
56 blink::WebParsedFeaturePolicyDeclaration web_declaration;
57 web_declaration.featureName =
58 blink::WebString::fromUTF8(declaration.feature_name);
59 web_declaration.matchesAllOrigins = declaration.matches_all_origins;
60 std::vector<blink::WebSecurityOrigin> web_origins;
61 for (const url::Origin& origin : declaration.origins)
62 web_origins.push_back(origin);
63 web_declaration.origins = web_origins;
64 result.push_back(web_declaration);
65 }
66 return result;
67 }
68
69 } // namespace 53 } // namespace
70 54
71 // static 55 // static
72 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( 56 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame(
73 RenderFrameImpl* frame_to_replace, 57 RenderFrameImpl* frame_to_replace,
74 int routing_id, 58 int routing_id,
75 blink::WebTreeScopeType scope) { 59 blink::WebTreeScopeType scope) {
76 CHECK_NE(routing_id, MSG_ROUTING_NONE); 60 CHECK_NE(routing_id, MSG_ROUTING_NONE);
77 61
78 std::unique_ptr<RenderFrameProxy> proxy(new RenderFrameProxy(routing_id)); 62 std::unique_ptr<RenderFrameProxy> proxy(new RenderFrameProxy(routing_id));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) { 218 void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) {
235 DCHECK(web_frame_); 219 DCHECK(web_frame_);
236 web_frame_->setReplicatedOrigin(state.origin); 220 web_frame_->setReplicatedOrigin(state.origin);
237 web_frame_->setReplicatedSandboxFlags(state.sandbox_flags); 221 web_frame_->setReplicatedSandboxFlags(state.sandbox_flags);
238 web_frame_->setReplicatedName(blink::WebString::fromUTF8(state.name), 222 web_frame_->setReplicatedName(blink::WebString::fromUTF8(state.name),
239 blink::WebString::fromUTF8(state.unique_name)); 223 blink::WebString::fromUTF8(state.unique_name));
240 web_frame_->setReplicatedInsecureRequestPolicy(state.insecure_request_policy); 224 web_frame_->setReplicatedInsecureRequestPolicy(state.insecure_request_policy);
241 web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin( 225 web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin(
242 state.has_potentially_trustworthy_unique_origin); 226 state.has_potentially_trustworthy_unique_origin);
243 web_frame_->setReplicatedFeaturePolicyHeader( 227 web_frame_->setReplicatedFeaturePolicyHeader(
244 ToWebParsedFeaturePolicyHeader(state.feature_policy_header)); 228 FeaturePolicyHeaderToWeb(state.feature_policy_header));
245 if (state.has_received_user_gesture) 229 if (state.has_received_user_gesture)
246 web_frame_->setHasReceivedUserGesture(); 230 web_frame_->setHasReceivedUserGesture();
247 231
248 web_frame_->resetReplicatedContentSecurityPolicy(); 232 web_frame_->resetReplicatedContentSecurityPolicy();
249 for (const auto& header : state.accumulated_csp_headers) 233 for (const auto& header : state.accumulated_csp_headers)
250 OnAddContentSecurityPolicy(header); 234 OnAddContentSecurityPolicy(header);
251 } 235 }
252 236
253 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags 237 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags
254 // that were set by its parent in another process. 238 // that were set by its parent in another process.
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 blink::WebLocalFrame* source) { 525 blink::WebLocalFrame* source) {
542 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); 526 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID();
543 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); 527 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id));
544 } 528 }
545 529
546 void RenderFrameProxy::frameFocused() { 530 void RenderFrameProxy::frameFocused() {
547 Send(new FrameHostMsg_FrameFocused(routing_id_)); 531 Send(new FrameHostMsg_FrameFocused(routing_id_));
548 } 532 }
549 533
550 } // namespace 534 } // namespace
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698