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

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

Issue 1303323003: Ignore in-page navigations on the initial blank page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up and add test Created 5 years, 4 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/frame_host/navigation_controller_impl_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 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 /* 5 /*
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 return true; 955 return true;
956 } 956 }
957 957
958 NavigationType NavigationControllerImpl::ClassifyNavigation( 958 NavigationType NavigationControllerImpl::ClassifyNavigation(
959 RenderFrameHostImpl* rfh, 959 RenderFrameHostImpl* rfh,
960 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { 960 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const {
961 if (params.did_create_new_entry) { 961 if (params.did_create_new_entry) {
962 // A new entry. We may or may not have a pending entry for the page, and 962 // A new entry. We may or may not have a pending entry for the page, and
963 // this may or may not be the main frame. 963 // this may or may not be the main frame.
964 if (!rfh->GetParent()) { 964 if (!rfh->GetParent()) {
965 // In-page navigations for the initial about:blank page should be ignored
966 // just like the initial about:blank page itself. We have no record of
967 // the subframes up to this point, so it's difficult to clone them into a
968 // new in-page entry.
969 if (params.was_within_same_page && !GetLastCommittedEntry())
970 return NAVIGATION_TYPE_NAV_IGNORE;
971
965 return NAVIGATION_TYPE_NEW_PAGE; 972 return NAVIGATION_TYPE_NEW_PAGE;
966 } 973 }
967 974
968 // When this is a new subframe navigation, we should have a committed page 975 // When this is a new subframe navigation, we should have a committed page
969 // in which it's a subframe. This may not be the case when an iframe is 976 // in which it's a subframe. This may not be the case when an iframe is
970 // navigated on a popup navigated to about:blank (the iframe would be 977 // navigated on a popup navigated to about:blank (the iframe would be
971 // written into the popup by script on the main page). For these cases, 978 // written into the popup by script on the main page). For these cases,
972 // there isn't any navigation stuff we can do, so just ignore it. 979 // there isn't any navigation stuff we can do, so just ignore it.
973 if (!GetLastCommittedEntry()) 980 if (!GetLastCommittedEntry())
974 return NAVIGATION_TYPE_NAV_IGNORE; 981 return NAVIGATION_TYPE_NAV_IGNORE;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // be in-page. 1346 // be in-page.
1340 bool NavigationControllerImpl::IsURLInPageNavigation( 1347 bool NavigationControllerImpl::IsURLInPageNavigation(
1341 const GURL& url, 1348 const GURL& url,
1342 bool renderer_says_in_page, 1349 bool renderer_says_in_page,
1343 RenderFrameHost* rfh) const { 1350 RenderFrameHost* rfh) const {
1344 GURL last_committed_url; 1351 GURL last_committed_url;
1345 if (rfh->GetParent()) { 1352 if (rfh->GetParent()) {
1346 last_committed_url = rfh->GetLastCommittedURL(); 1353 last_committed_url = rfh->GetLastCommittedURL();
1347 } else { 1354 } else {
1348 NavigationEntry* last_committed = GetLastCommittedEntry(); 1355 NavigationEntry* last_committed = GetLastCommittedEntry();
1349 // There must be a last-committed entry to compare URLs to. TODO(avi): When 1356
1350 // might Blink say that a navigation is in-page yet there be no last- 1357 // In most cases, there is a last committed entry to compare URLs to.
1351 // committed entry? 1358 // The last committed entry might be null when leaving the initial blank
1359 // page, even for in-page navigations (e.g., pushState or frament nav).
1360 // In these cases, we must trust what the renderer says.
1352 if (!last_committed) 1361 if (!last_committed)
1353 return false; 1362 return renderer_says_in_page;
1354 last_committed_url = last_committed->GetURL(); 1363 last_committed_url = last_committed->GetURL();
1355 } 1364 }
1356 1365
1357 WebPreferences prefs = rfh->GetRenderViewHost()->GetWebkitPreferences(); 1366 WebPreferences prefs = rfh->GetRenderViewHost()->GetWebkitPreferences();
1358 bool is_same_origin = last_committed_url.is_empty() || 1367 bool is_same_origin = last_committed_url.is_empty() ||
1359 // TODO(japhet): We should only permit navigations 1368 // TODO(japhet): We should only permit navigations
1360 // originating from about:blank to be in-page if the 1369 // originating from about:blank to be in-page if the
1361 // about:blank is the first document that frame loaded. 1370 // about:blank is the first document that frame loaded.
1362 // We don't have sufficient information to identify 1371 // We don't have sufficient information to identify
1363 // that case at the moment, so always allow about:blank 1372 // that case at the moment, so always allow about:blank
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 } 1993 }
1985 } 1994 }
1986 } 1995 }
1987 1996
1988 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1997 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1989 const base::Callback<base::Time()>& get_timestamp_callback) { 1998 const base::Callback<base::Time()>& get_timestamp_callback) {
1990 get_timestamp_callback_ = get_timestamp_callback; 1999 get_timestamp_callback_ = get_timestamp_callback;
1991 } 2000 }
1992 2001
1993 } // namespace content 2002 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_controller_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698