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

Side by Side Diff: content/browser/frame_host/render_frame_proxy_host.cc

Issue 1812723002: Add URL validation to navigations initiated via RenderFrameProxyHosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Charlie's nit Created 4 years, 9 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 | « no previous file | content/browser/site_per_process_browsertest.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/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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // by navigating its parent. 241 // by navigating its parent.
242 if (frame_tree_node_->IsMainFrame()) { 242 if (frame_tree_node_->IsMainFrame()) {
243 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); 243 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH);
244 return; 244 return;
245 } 245 }
246 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_); 246 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_);
247 } 247 }
248 248
249 void RenderFrameProxyHost::OnOpenURL( 249 void RenderFrameProxyHost::OnOpenURL(
250 const FrameHostMsg_OpenURL_Params& params) { 250 const FrameHostMsg_OpenURL_Params& params) {
251 GURL validated_url(params.url);
252 GetProcess()->FilterURL(false, &validated_url);
253
251 // Verify that we are in the same BrowsingInstance as the current 254 // Verify that we are in the same BrowsingInstance as the current
252 // RenderFrameHost. 255 // RenderFrameHost.
253 RenderFrameHostImpl* current_rfh = frame_tree_node_->current_frame_host(); 256 RenderFrameHostImpl* current_rfh = frame_tree_node_->current_frame_host();
254 if (!site_instance_->IsRelatedSiteInstance(current_rfh->GetSiteInstance())) 257 if (!site_instance_->IsRelatedSiteInstance(current_rfh->GetSiteInstance()))
255 return; 258 return;
256 259
257 // Since this navigation targeted a specific RenderFrameProxy, it should stay 260 // Since this navigation targeted a specific RenderFrameProxy, it should stay
258 // in the current tab. 261 // in the current tab.
259 DCHECK_EQ(CURRENT_TAB, params.disposition); 262 DCHECK_EQ(CURRENT_TAB, params.disposition);
260 263
261 // 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
262 // passed in as well. 265 // passed in as well.
263 frame_tree_node_->navigator()->RequestTransferURL( 266 frame_tree_node_->navigator()->RequestTransferURL(
264 current_rfh, params.url, site_instance_.get(), std::vector<GURL>(), 267 current_rfh, validated_url, site_instance_.get(), std::vector<GURL>(),
265 params.referrer, ui::PAGE_TRANSITION_LINK, GlobalRequestID(), 268 params.referrer, ui::PAGE_TRANSITION_LINK, GlobalRequestID(),
266 params.should_replace_current_entry); 269 params.should_replace_current_entry);
267 } 270 }
268 271
269 void RenderFrameProxyHost::OnRouteMessageEvent( 272 void RenderFrameProxyHost::OnRouteMessageEvent(
270 const FrameMsg_PostMessage_Params& params) { 273 const FrameMsg_PostMessage_Params& params) {
271 RenderFrameHostImpl* target_rfh = frame_tree_node()->current_frame_host(); 274 RenderFrameHostImpl* target_rfh = frame_tree_node()->current_frame_host();
272 275
273 // Only deliver the message if the request came from a RenderFrameHost in the 276 // Only deliver the message if the request came from a RenderFrameHost in the
274 // same BrowsingInstance or if this WebContents is dedicated to a browser 277 // same BrowsingInstance or if this WebContents is dedicated to a browser
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 target_rfh->Send(new FrameMsg_AdvanceFocus(target_rfh->GetRoutingID(), type, 370 target_rfh->Send(new FrameMsg_AdvanceFocus(target_rfh->GetRoutingID(), type,
368 source_proxy_routing_id)); 371 source_proxy_routing_id));
369 } 372 }
370 373
371 void RenderFrameProxyHost::OnFrameFocused() { 374 void RenderFrameProxyHost::OnFrameFocused() {
372 frame_tree_node_->frame_tree()->SetFocusedFrame(frame_tree_node_, 375 frame_tree_node_->frame_tree()->SetFocusedFrame(frame_tree_node_,
373 GetSiteInstance()); 376 GetSiteInstance());
374 } 377 }
375 378
376 } // namespace content 379 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698