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 11 matching lines...) Expand all Loading... |
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::WebVector<blink::WebFeaturePolicy::ParsedWhitelist> |
| 52 ToWebFeaturePolicyParsedWhitelist( |
| 53 const std::vector<FeaturePolicyParsedWhitelist>& parsed_whitelists) { |
| 54 std::vector<blink::WebFeaturePolicy::ParsedWhitelist> result; |
| 55 for (const FeaturePolicyParsedWhitelist& whitelist : parsed_whitelists) { |
| 56 blink::WebFeaturePolicy::ParsedWhitelist web_whitelist; |
| 57 web_whitelist.featureName = |
| 58 blink::WebString::fromUTF8(whitelist.feature_name); |
| 59 web_whitelist.matchesAllOrigins = whitelist.matches_all_origins; |
| 60 std::vector<blink::WebString> web_origins; |
| 61 for (const std::string& origin : whitelist.origins) |
| 62 web_origins.push_back(blink::WebString::fromUTF8(origin)); |
| 63 result.push_back(web_whitelist); |
| 64 } |
| 65 return result; |
| 66 } |
| 67 |
50 } // namespace | 68 } // namespace |
51 | 69 |
52 // static | 70 // static |
53 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( | 71 RenderFrameProxy* RenderFrameProxy::CreateProxyToReplaceFrame( |
54 RenderFrameImpl* frame_to_replace, | 72 RenderFrameImpl* frame_to_replace, |
55 int routing_id, | 73 int routing_id, |
56 blink::WebTreeScopeType scope) { | 74 blink::WebTreeScopeType scope) { |
57 CHECK_NE(routing_id, MSG_ROUTING_NONE); | 75 CHECK_NE(routing_id, MSG_ROUTING_NONE); |
58 | 76 |
59 std::unique_ptr<RenderFrameProxy> proxy( | 77 std::unique_ptr<RenderFrameProxy> proxy( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) { | 235 void RenderFrameProxy::SetReplicatedState(const FrameReplicationState& state) { |
218 DCHECK(web_frame_); | 236 DCHECK(web_frame_); |
219 web_frame_->setReplicatedOrigin(state.origin); | 237 web_frame_->setReplicatedOrigin(state.origin); |
220 web_frame_->setReplicatedSandboxFlags(state.sandbox_flags); | 238 web_frame_->setReplicatedSandboxFlags(state.sandbox_flags); |
221 web_frame_->setReplicatedName(blink::WebString::fromUTF8(state.name), | 239 web_frame_->setReplicatedName(blink::WebString::fromUTF8(state.name), |
222 blink::WebString::fromUTF8(state.unique_name)); | 240 blink::WebString::fromUTF8(state.unique_name)); |
223 web_frame_->setReplicatedInsecureRequestPolicy(state.insecure_request_policy); | 241 web_frame_->setReplicatedInsecureRequestPolicy(state.insecure_request_policy); |
224 web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin( | 242 web_frame_->setReplicatedPotentiallyTrustworthyUniqueOrigin( |
225 state.has_potentially_trustworthy_unique_origin); | 243 state.has_potentially_trustworthy_unique_origin); |
226 web_frame_->setReplicatedFeaturePolicyHeader( | 244 web_frame_->setReplicatedFeaturePolicyHeader( |
227 blink::WebString::fromUTF8(state.feature_policy_header)); | 245 ToWebFeaturePolicyParsedWhitelist(state.feature_policy_header)); |
228 | 246 |
229 web_frame_->resetReplicatedContentSecurityPolicy(); | 247 web_frame_->resetReplicatedContentSecurityPolicy(); |
230 for (const auto& header : state.accumulated_csp_headers) | 248 for (const auto& header : state.accumulated_csp_headers) |
231 OnAddContentSecurityPolicy(header); | 249 OnAddContentSecurityPolicy(header); |
232 } | 250 } |
233 | 251 |
234 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags | 252 // Update the proxy's SecurityContext and FrameOwner with new sandbox flags |
235 // that were set by its parent in another process. | 253 // that were set by its parent in another process. |
236 // | 254 // |
237 // Normally, when a frame's sandbox attribute is changed dynamically, the | 255 // Normally, when a frame's sandbox attribute is changed dynamically, the |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 blink::WebLocalFrame* source) { | 523 blink::WebLocalFrame* source) { |
506 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); | 524 int source_routing_id = RenderFrameImpl::FromWebFrame(source)->GetRoutingID(); |
507 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); | 525 Send(new FrameHostMsg_AdvanceFocus(routing_id_, type, source_routing_id)); |
508 } | 526 } |
509 | 527 |
510 void RenderFrameProxy::frameFocused() { | 528 void RenderFrameProxy::frameFocused() { |
511 Send(new FrameHostMsg_FrameFocused(routing_id_)); | 529 Send(new FrameHostMsg_FrameFocused(routing_id_)); |
512 } | 530 } |
513 | 531 |
514 } // namespace | 532 } // namespace |
OLD | NEW |