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

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

Issue 2520223002: Replicate a parsed feature policy representation so it doesn't need to be parsed in the browser pro… (Closed)
Patch Set: Replicate a parsed feature policy representation so it doesn't need to be parsed in the browser pro… Created 4 years 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 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 11 matching lines...) Expand all
22 #include "content/common/site_isolation_policy.h" 22 #include "content/common/site_isolation_policy.h"
23 #include "content/common/swapped_out_messages.h" 23 #include "content/common/swapped_out_messages.h"
24 #include "content/common/view_messages.h" 24 #include "content/common/view_messages.h"
25 #include "content/renderer/child_frame_compositing_helper.h" 25 #include "content/renderer/child_frame_compositing_helper.h"
26 #include "content/renderer/render_frame_impl.h" 26 #include "content/renderer/render_frame_impl.h"
27 #include "content/renderer/render_thread_impl.h" 27 #include "content/renderer/render_thread_impl.h"
28 #include "content/renderer/render_view_impl.h" 28 #include "content/renderer/render_view_impl.h"
29 #include "content/renderer/render_widget.h" 29 #include "content/renderer/render_widget.h"
30 #include "ipc/ipc_message_macros.h" 30 #include "ipc/ipc_message_macros.h"
31 #include "third_party/WebKit/public/platform/URLConversion.h" 31 #include "third_party/WebKit/public/platform/URLConversion.h"
32 #include "third_party/WebKit/public/platform/WebFeaturePolicy.h"
32 #include "third_party/WebKit/public/platform/WebString.h" 33 #include "third_party/WebKit/public/platform/WebString.h"
33 #include "third_party/WebKit/public/web/WebLocalFrame.h" 34 #include "third_party/WebKit/public/web/WebLocalFrame.h"
34 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 35 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
35 #include "third_party/WebKit/public/web/WebView.h" 36 #include "third_party/WebKit/public/web/WebView.h"
36 37
37 namespace content { 38 namespace content {
38 39
39 namespace { 40 namespace {
40 41
41 // Facilitates lookup of RenderFrameProxy by routing_id. 42 // Facilitates lookup of RenderFrameProxy by routing_id.
42 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap; 43 typedef std::map<int, RenderFrameProxy*> RoutingIDProxyMap;
43 static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map = 44 static base::LazyInstance<RoutingIDProxyMap> g_routing_id_proxy_map =
44 LAZY_INSTANCE_INITIALIZER; 45 LAZY_INSTANCE_INITIALIZER;
45 46
46 // Facilitates lookup of RenderFrameProxy by WebFrame. 47 // Facilitates lookup of RenderFrameProxy by WebFrame.
47 typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap; 48 typedef std::map<blink::WebFrame*, RenderFrameProxy*> FrameMap;
48 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER; 49 base::LazyInstance<FrameMap> g_frame_map = LAZY_INSTANCE_INITIALIZER;
49 50
51 blink::WebParsedFeaturePolicy ToWebParsedFeaturePolicy(
52 const ParsedFeaturePolicy& parsed_whitelists) {
53 std::vector<blink::WebFeaturePolicy::ParsedWhitelist> result;
54 for (const FeaturePolicyParsedWhitelist& whitelist : parsed_whitelists) {
55 blink::WebFeaturePolicy::ParsedWhitelist web_whitelist;
56 web_whitelist.featureName =
57 blink::WebString::fromUTF8(whitelist.feature_name);
58 web_whitelist.matchesAllOrigins = whitelist.matches_all_origins;
59 std::vector<blink::WebSecurityOrigin> web_origins;
60 for (const url::Origin& origin : whitelist.origins)
61 web_origins.push_back(origin);
62 result.push_back(web_whitelist);
63 }
64 return result;
65 }
66
50 } // namespace 67 } // namespace
51 68
52 // static 69 // static
53 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( 70 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame(
54 RenderFrameImpl* frame_to_replace, 71 RenderFrameImpl* frame_to_replace,
55 int routing_id, 72 int routing_id,
56 blink::WebTreeScopeType scope) { 73 blink::WebTreeScopeType scope) {
57 CHECK_NE(routing_id, MSG_ROUTING_NONE); 74 CHECK_NE(routing_id, MSG_ROUTING_NONE);
58 75
59 std::unique_ptr<RenderFrameProxy> proxy( 76 std::unique_ptr<RenderFrameProxy> proxy(
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) { 234 void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) {
218 DCHECK(web_frame_); 235 DCHECK(web_frame_);
219 web_frame_->setReplicatedOrigin(state.origin); 236 web_frame_->setReplicatedOrigin(state.origin);
220 web_frame_->setReplicatedSandboxFlags(state.sandbox_flags); 237 web_frame_->setReplicatedSandboxFlags(state.sandbox_flags);
221 web_frame_->setReplicatedName(blink::WebString::fromUTF8(state.name), 238 web_frame_->setReplicatedName(blink::WebString::fromUTF8(state.name),
222 blink::WebString::fromUTF8(state.unique_name)); 239 blink::WebString::fromUTF8(state.unique_name));
223 web_frame_->setReplicatedInsecureRequestPolicy(state.insecure_request_policy); 240 web_frame_->setReplicatedInsecureRequestPolicy(state.insecure_request_policy);
224 web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin( 241 web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin(
225 state.has_potentially_trustworthy_unique_origin); 242 state.has_potentially_trustworthy_unique_origin);
226 web_frame_->setReplicatedFeaturePolicyHeader( 243 web_frame_->setReplicatedFeaturePolicyHeader(
227 blink::WebString::fromUTF8(state.feature_policy_header)); 244 ToWebParsedFeaturePolicy(state.feature_policy_header));
228 245
229 web_frame_->resetReplicatedContentSecurityPolicy(); 246 web_frame_->resetReplicatedContentSecurityPolicy();
230 for (const auto& header : state.accumulated_csp_headers) 247 for (const auto& header : state.accumulated_csp_headers)
231 OnAddContentSecurityPolicy(header); 248 OnAddContentSecurityPolicy(header);
232 } 249 }
233 250
234 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags 251 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags
235 // that were set by its parent in another process. 252 // that were set by its parent in another process.
236 // 253 //
237 // Normally, when a frame's sandbox attribute is changed dynamically, the 254 // Normally, when a frame's sandbox attribute is changed dynamically, the
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 blink::WebLocalFrame* source) { 522 blink::WebLocalFrame* source) {
506 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); 523 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID();
507 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); 524 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id));
508 } 525 }
509 526
510 void RenderFrameProxy::frameFocused() { 527 void RenderFrameProxy::frameFocused() {
511 Send(new FrameHostMsg_FrameFocused(routing_id_)); 528 Send(new FrameHostMsg_FrameFocused(routing_id_));
512 } 529 }
513 530
514 } // namespace 531 } // namespace
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | third_party/WebKit/Source/core/dom/SecurityContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698