Chromium Code Reviews

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

Issue 265123003: DRAFT CL: Check that we already know the renderer's page ID (outside commit). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_impl.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
(...skipping 366 matching lines...)
377 GetProcess()->FilterURL(false, &validated_url); 377 GetProcess()->FilterURL(false, &validated_url);
378 378
379 frame_tree_node_->navigator()->DidFailLoadWithError( 379 frame_tree_node_->navigator()->DidFailLoadWithError(
380 this, validated_url, error_code, error_description); 380 this, validated_url, error_code, error_description);
381 } 381 }
382 382
383 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( 383 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad(
384 int32 page_id, 384 int32 page_id,
385 const GURL& source_url, 385 const GURL& source_url,
386 const GURL& target_url) { 386 const GURL& target_url) {
387 CHECK_EQ(render_view_host_->page_id_, page_id);
387 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( 388 frame_tree_node_->navigator()->DidRedirectProvisionalLoad(
388 this, page_id, source_url, target_url); 389 this, render_view_host_->page_id_, source_url, target_url);
389 } 390 }
390 391
391 // Called when the renderer navigates. For every frame loaded, we'll get this 392 // Called when the renderer navigates. For every frame loaded, we'll get this
392 // notification containing parameters identifying the navigation. 393 // notification containing parameters identifying the navigation.
393 // 394 //
394 // Subframes are identified by the page transition type. For subframes loaded 395 // Subframes are identified by the page transition type. For subframes loaded
395 // as part of a wider page load, the page_id will be the same as for the top 396 // as part of a wider page load, the page_id will be the same as for the top
396 // level frame. If the user explicitly requests a subframe navigation, we will 397 // level frame. If the user explicitly requests a subframe navigation, we will
397 // get a new page_id because we need to create a new navigation entry for that 398 // get a new page_id because we need to create a new navigation entry for that
398 // action. 399 // action.
(...skipping 34 matching lines...)
433 // than our FilterURL checks below. If a renderer violates this policy, it 434 // than our FilterURL checks below. If a renderer violates this policy, it
434 // should be killed. 435 // should be killed.
435 if (!CanCommitURL(validated_params.url)) { 436 if (!CanCommitURL(validated_params.url)) {
436 VLOG(1) << "Blocked URL " << validated_params.url.spec(); 437 VLOG(1) << "Blocked URL " << validated_params.url.spec();
437 validated_params.url = GURL(kAboutBlankURL); 438 validated_params.url = GURL(kAboutBlankURL);
438 RecordAction(base::UserMetricsAction("CanCommitURL_BlockedAndKilled")); 439 RecordAction(base::UserMetricsAction("CanCommitURL_BlockedAndKilled"));
439 // Kills the process. 440 // Kills the process.
440 process->ReceivedBadMessage(); 441 process->ReceivedBadMessage();
441 } 442 }
442 443
444 // Update the RVH's current page ID so that other IPCs make sense.
445 // TODO(creis): Should this be above the second return statement above?
446 render_view_host_->page_id_ = validated_params.page_id;
447
443 // Without this check, an evil renderer can trick the browser into creating 448 // Without this check, an evil renderer can trick the browser into creating
444 // a navigation entry for a banned URL. If the user clicks the back button 449 // a navigation entry for a banned URL. If the user clicks the back button
445 // followed by the forward button (or clicks reload, or round-trips through 450 // followed by the forward button (or clicks reload, or round-trips through
446 // session restore, etc), we'll think that the browser commanded the 451 // session restore, etc), we'll think that the browser commanded the
447 // renderer to load the URL and grant the renderer the privileges to request 452 // renderer to load the URL and grant the renderer the privileges to request
448 // the URL. To prevent this attack, we block the renderer from inserting 453 // the URL. To prevent this attack, we block the renderer from inserting
449 // banned URLs into the navigation controller in the first place. 454 // banned URLs into the navigation controller in the first place.
450 process->FilterURL(false, &validated_params.url); 455 process->FilterURL(false, &validated_params.url);
451 process->FilterURL(true, &validated_params.referrer.url); 456 process->FilterURL(true, &validated_params.referrer.url);
452 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); 457 for (std::vector<GURL>::iterator it(validated_params.redirects.begin());
(...skipping 397 matching lines...)
850 cancel_notification_callbacks_.erase(notification_id); 855 cancel_notification_callbacks_.erase(notification_id);
851 } 856 }
852 857
853 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone( 858 void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone(
854 int callback_context) { 859 int callback_context) {
855 Send(new DesktopNotificationMsg_PermissionRequestDone( 860 Send(new DesktopNotificationMsg_PermissionRequestDone(
856 routing_id_, callback_context)); 861 routing_id_, callback_context));
857 } 862 }
858 863
859 } // namespace content 864 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine