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

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

Issue 1794513003: Don't rely on the pending NavigationEntry for location.replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 low_water_mark_ = high_water_mark_ = t; 221 low_water_mark_ = high_water_mark_ = t;
222 return t; 222 return t;
223 } 223 }
224 224
225 NavigationControllerImpl::NavigationControllerImpl( 225 NavigationControllerImpl::NavigationControllerImpl(
226 NavigationControllerDelegate* delegate, 226 NavigationControllerDelegate* delegate,
227 BrowserContext* browser_context) 227 BrowserContext* browser_context)
228 : browser_context_(browser_context), 228 : browser_context_(browser_context),
229 pending_entry_(NULL), 229 pending_entry_(NULL),
230 failed_pending_entry_id_(0), 230 failed_pending_entry_id_(0),
231 failed_pending_entry_should_replace_(false),
232 last_committed_entry_index_(-1), 231 last_committed_entry_index_(-1),
233 pending_entry_index_(-1), 232 pending_entry_index_(-1),
234 transient_entry_index_(-1), 233 transient_entry_index_(-1),
235 delegate_(delegate), 234 delegate_(delegate),
236 max_restored_page_id_(-1), 235 max_restored_page_id_(-1),
237 ssl_manager_(this), 236 ssl_manager_(this),
238 needs_reload_(false), 237 needs_reload_(false),
239 is_initial_navigation_(true), 238 is_initial_navigation_(true),
240 in_navigate_to_pending_entry_(false), 239 in_navigate_to_pending_entry_(false),
241 pending_reload_(NO_RELOAD), 240 pending_reload_(NO_RELOAD),
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 852
854 // If there is a pending entry at this point, it should have a SiteInstance, 853 // If there is a pending entry at this point, it should have a SiteInstance,
855 // except for restored entries. 854 // except for restored entries.
856 DCHECK(pending_entry_index_ == -1 || 855 DCHECK(pending_entry_index_ == -1 ||
857 pending_entry_->site_instance() || 856 pending_entry_->site_instance() ||
858 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE); 857 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE);
859 if (pending_entry_ && 858 if (pending_entry_ &&
860 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) 859 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE)
861 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); 860 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE);
862 861
863 // If we are doing a cross-site reload, we need to replace the existing 862 // The renderer tells us whether the navigation replaces the current entry.
864 // navigation entry, not add another entry to the history. This has the side 863 details->did_replace_entry = params.should_replace_current_entry;
865 // effect of removing forward browsing history, if such existed. Or if we are
866 // doing a cross-site redirect navigation, we will do a similar thing.
867 //
868 // If this is an error load, we may have already removed the pending entry
869 // when we got the notice of the load failure. If so, look at the copy of the
870 // pending parameters that were saved.
871 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) {
872 details->did_replace_entry = failed_pending_entry_should_replace_;
873 } else {
874 details->did_replace_entry = pending_entry_ &&
875 pending_entry_->should_replace_entry();
876 }
877 864
878 // Do navigation-type specific actions. These will make and commit an entry. 865 // Do navigation-type specific actions. These will make and commit an entry.
879 details->type = ClassifyNavigation(rfh, params); 866 details->type = ClassifyNavigation(rfh, params);
880 867
881 // is_in_page must be computed before the entry gets committed. 868 // is_in_page must be computed before the entry gets committed.
882 details->is_in_page = IsURLInPageNavigation( 869 details->is_in_page = IsURLInPageNavigation(
883 params.url, params.was_within_same_page, rfh); 870 params.url, params.was_within_same_page, rfh);
884 871
885 switch (details->type) { 872 switch (details->type) {
886 case NAVIGATION_TYPE_NEW_PAGE: 873 case NAVIGATION_TYPE_NEW_PAGE:
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 // navigated on a popup navigated to about:blank (the iframe would be 998 // navigated on a popup navigated to about:blank (the iframe would be
1012 // written into the popup by script on the main page). For these cases, 999 // written into the popup by script on the main page). For these cases,
1013 // there isn't any navigation stuff we can do, so just ignore it. 1000 // there isn't any navigation stuff we can do, so just ignore it.
1014 if (!GetLastCommittedEntry()) 1001 if (!GetLastCommittedEntry())
1015 return NAVIGATION_TYPE_NAV_IGNORE; 1002 return NAVIGATION_TYPE_NAV_IGNORE;
1016 1003
1017 // Valid subframe navigation. 1004 // Valid subframe navigation.
1018 return NAVIGATION_TYPE_NEW_SUBFRAME; 1005 return NAVIGATION_TYPE_NEW_SUBFRAME;
1019 } 1006 }
1020 1007
1008 // Cross-process location.replace navigations should be classified as New with
1009 // replacement rather than ExistingPage, since it is not safe to reuse the
1010 // NavigationEntry.
1011 // TODO(creis): Have the renderer classify location.replace as
1012 // did_create_new_entry for all cases and eliminate this special case. This
1013 // requires updating several test expectations. See https://crbug.com/317872.
1014 if (!rfh->GetParent() && GetLastCommittedEntry() &&
1015 GetLastCommittedEntry()->site_instance() != rfh->GetSiteInstance() &&
1016 params.should_replace_current_entry) {
1017 return NAVIGATION_TYPE_NEW_PAGE;
1018 }
1019
1021 // We only clear the session history when navigating to a new page. 1020 // We only clear the session history when navigating to a new page.
1022 DCHECK(!params.history_list_was_cleared); 1021 DCHECK(!params.history_list_was_cleared);
1023 1022
1024 if (rfh->GetParent()) { 1023 if (rfh->GetParent()) {
1025 // All manual subframes would be did_create_new_entry and handled above, so 1024 // All manual subframes would be did_create_new_entry and handled above, so
1026 // we know this is auto. 1025 // we know this is auto.
1027 if (GetLastCommittedEntry()) { 1026 if (GetLastCommittedEntry()) {
1028 return NAVIGATION_TYPE_AUTO_SUBFRAME; 1027 return NAVIGATION_TYPE_AUTO_SUBFRAME;
1029 } else { 1028 } else {
1030 // We ignore subframes created in non-committed pages; we'd appreciate if 1029 // We ignore subframes created in non-committed pages; we'd appreciate if
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 1993
1995 void NavigationControllerImpl::DiscardPendingEntry(bool was_failure) { 1994 void NavigationControllerImpl::DiscardPendingEntry(bool was_failure) {
1996 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in 1995 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in
1997 // progress, since this will cause a use-after-free. (We only allow this 1996 // progress, since this will cause a use-after-free. (We only allow this
1998 // when the tab is being destroyed for shutdown, since it won't return to 1997 // when the tab is being destroyed for shutdown, since it won't return to
1999 // NavigateToEntry in that case.) http://crbug.com/347742. 1998 // NavigateToEntry in that case.) http://crbug.com/347742.
2000 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); 1999 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed());
2001 2000
2002 if (was_failure && pending_entry_) { 2001 if (was_failure && pending_entry_) {
2003 failed_pending_entry_id_ = pending_entry_->GetUniqueID(); 2002 failed_pending_entry_id_ = pending_entry_->GetUniqueID();
2004 failed_pending_entry_should_replace_ =
2005 pending_entry_->should_replace_entry();
2006 } else { 2003 } else {
2007 failed_pending_entry_id_ = 0; 2004 failed_pending_entry_id_ = 0;
2008 } 2005 }
2009 2006
2010 if (pending_entry_index_ == -1) 2007 if (pending_entry_index_ == -1)
2011 delete pending_entry_; 2008 delete pending_entry_;
2012 pending_entry_ = NULL; 2009 pending_entry_ = NULL;
2013 pending_entry_index_ = -1; 2010 pending_entry_index_ = -1;
2014 } 2011 }
2015 2012
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 } 2073 }
2077 } 2074 }
2078 } 2075 }
2079 2076
2080 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2077 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2081 const base::Callback<base::Time()>& get_timestamp_callback) { 2078 const base::Callback<base::Time()>& get_timestamp_callback) {
2082 get_timestamp_callback_ = get_timestamp_callback; 2079 get_timestamp_callback_ = get_timestamp_callback;
2083 } 2080 }
2084 2081
2085 } // namespace content 2082 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698