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/browser/frame_host/render_frame_proxy_host.h" | 5 #include "content/browser/frame_host/render_frame_proxy_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "content/browser/bad_message.h" | 10 #include "content/browser/bad_message.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 128 |
129 bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) { | 129 bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) { |
130 if (cross_process_frame_connector_.get() && | 130 if (cross_process_frame_connector_.get() && |
131 cross_process_frame_connector_->OnMessageReceived(msg)) | 131 cross_process_frame_connector_->OnMessageReceived(msg)) |
132 return true; | 132 return true; |
133 | 133 |
134 bool handled = true; | 134 bool handled = true; |
135 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) | 135 IPC_BEGIN_MESSAGE_MAP(RenderFrameProxyHost, msg) |
136 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) | 136 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) |
137 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 137 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
138 IPC_MESSAGE_HANDLER(FrameHostMsg_ForwardContentSecurityPolicyViolation, | |
139 OnForwardContentSecurityPolicyViolation) | |
138 IPC_MESSAGE_HANDLER(FrameHostMsg_RouteMessageEvent, OnRouteMessageEvent) | 140 IPC_MESSAGE_HANDLER(FrameHostMsg_RouteMessageEvent, OnRouteMessageEvent) |
139 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) | 141 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) |
140 IPC_MESSAGE_HANDLER(FrameHostMsg_AdvanceFocus, OnAdvanceFocus) | 142 IPC_MESSAGE_HANDLER(FrameHostMsg_AdvanceFocus, OnAdvanceFocus) |
141 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) | 143 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) |
142 IPC_MESSAGE_UNHANDLED(handled = false) | 144 IPC_MESSAGE_UNHANDLED(handled = false) |
143 IPC_END_MESSAGE_MAP() | 145 IPC_END_MESSAGE_MAP() |
144 return handled; | 146 return handled; |
145 } | 147 } |
146 | 148 |
147 bool RenderFrameProxyHost::InitRenderFrameProxy() { | 149 bool RenderFrameProxyHost::InitRenderFrameProxy() { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 | 263 |
262 // TODO(alexmos, creis): Figure out whether |params.user_gesture| needs to be | 264 // TODO(alexmos, creis): Figure out whether |params.user_gesture| needs to be |
263 // passed in as well. | 265 // passed in as well. |
264 frame_tree_node_->navigator()->RequestTransferURL( | 266 frame_tree_node_->navigator()->RequestTransferURL( |
265 current_rfh, validated_url, site_instance_.get(), std::vector<GURL>(), | 267 current_rfh, validated_url, site_instance_.get(), std::vector<GURL>(), |
266 params.referrer, ui::PAGE_TRANSITION_LINK, GlobalRequestID(), | 268 params.referrer, ui::PAGE_TRANSITION_LINK, GlobalRequestID(), |
267 params.should_replace_current_entry, params.uses_post ? "POST" : "GET", | 269 params.should_replace_current_entry, params.uses_post ? "POST" : "GET", |
268 params.resource_request_body); | 270 params.resource_request_body); |
269 } | 271 } |
270 | 272 |
273 void RenderFrameProxyHost::OnForwardContentSecurityPolicyViolation( | |
274 const url::Origin& origin_declaring_violated_csp, | |
275 const ContentSecurityPolicyViolation& violation) { | |
276 RenderFrameHostImpl* current_rfh = frame_tree_node_->current_frame_host(); | |
277 | |
278 // Verify that the CSP violation will be reported in the same frame | |
Charlie Reis
2016/08/11 20:40:26
"same frame": Did you mean to say "same document?"
Łukasz Anforowicz
2016/08/12 18:55:04
Good point. Done.
| |
279 // as the one that declared the violated CSP (or at least in a frame | |
280 // with the same origin). This check protects against a race when | |
281 // ForwardContentSecurityPolicyViolation IPC races with navigation | |
282 // of the frame the IPC is sent to. | |
283 if (!origin_declaring_violated_csp.IsSameOriginWith( | |
284 current_rfh->GetLastCommittedOrigin())) | |
Charlie Reis
2016/08/11 20:40:26
I'm wondering if there's something better we can d
Łukasz Anforowicz
2016/08/12 18:55:04
Ack. Things are a bit improved by your suggestion
Charlie Reis
2016/08/12 20:47:30
I don't see any comments there, so I'll avoid digg
| |
285 return; | |
286 | |
287 // Forward CSP violation report to the frame that declared the CSP. | |
288 current_rfh->Send(new FrameMsg_ReportContentSecurityPolicyViolation( | |
289 current_rfh->GetRoutingID(), violation)); | |
290 } | |
291 | |
271 void RenderFrameProxyHost::OnRouteMessageEvent( | 292 void RenderFrameProxyHost::OnRouteMessageEvent( |
272 const FrameMsg_PostMessage_Params& params) { | 293 const FrameMsg_PostMessage_Params& params) { |
273 RenderFrameHostImpl* target_rfh = frame_tree_node()->current_frame_host(); | 294 RenderFrameHostImpl* target_rfh = frame_tree_node()->current_frame_host(); |
274 | 295 |
275 // Only deliver the message if the request came from a RenderFrameHost in the | 296 // Only deliver the message if the request came from a RenderFrameHost in the |
276 // same BrowsingInstance or if this WebContents is dedicated to a browser | 297 // same BrowsingInstance or if this WebContents is dedicated to a browser |
277 // plugin guest. | 298 // plugin guest. |
278 // | 299 // |
279 // TODO(alexmos, lazyboy): The check for browser plugin guest currently | 300 // TODO(alexmos, lazyboy): The check for browser plugin guest currently |
280 // requires going through the delegate. It should be refactored and | 301 // requires going through the delegate. It should be refactored and |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 target_rfh->Send(new FrameMsg_AdvanceFocus(target_rfh->GetRoutingID(), type, | 390 target_rfh->Send(new FrameMsg_AdvanceFocus(target_rfh->GetRoutingID(), type, |
370 source_proxy_routing_id)); | 391 source_proxy_routing_id)); |
371 } | 392 } |
372 | 393 |
373 void RenderFrameProxyHost::OnFrameFocused() { | 394 void RenderFrameProxyHost::OnFrameFocused() { |
374 frame_tree_node_->current_frame_host()->delegate()->SetFocusedFrame( | 395 frame_tree_node_->current_frame_host()->delegate()->SetFocusedFrame( |
375 frame_tree_node_, GetSiteInstance()); | 396 frame_tree_node_, GetSiteInstance()); |
376 } | 397 } |
377 | 398 |
378 } // namespace content | 399 } // namespace content |
OLD | NEW |