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

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

Issue 1245433002: Don't clear the forward history when replacing entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 5 years, 5 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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // need to keep continuity with the pending entry, so copy the pending entry's 1644 // need to keep continuity with the pending entry, so copy the pending entry's
1645 // unique ID to the committed entry. If the pending_entry_index_ isn't -1, 1645 // unique ID to the committed entry. If the pending_entry_index_ isn't -1,
1646 // then the renderer navigated on its own, independent of the pending entry, 1646 // then the renderer navigated on its own, independent of the pending entry,
1647 // so don't copy anything. 1647 // so don't copy anything.
1648 if (pending_entry_ && pending_entry_index_ == -1) 1648 if (pending_entry_ && pending_entry_index_ == -1)
1649 entry->set_unique_id(pending_entry_->GetUniqueID()); 1649 entry->set_unique_id(pending_entry_->GetUniqueID());
1650 1650
1651 DiscardNonCommittedEntriesInternal(); 1651 DiscardNonCommittedEntriesInternal();
1652 1652
1653 int current_size = static_cast<int>(entries_.size()); 1653 int current_size = static_cast<int>(entries_.size());
1654 DCHECK_IMPLIES(replace, current_size > 0); 1654
1655 // When replacing, don't prune the forward history.
1656 if (replace) {
1657 DCHECK_GT(current_size, 0);
1658 int32 page_id = entry->GetPageID();
1659 entries_[last_committed_entry_index_] = entry.release();
1660
1661 // This is a new page ID, so we need everybody to know about it.
1662 delegate_->UpdateMaxPageID(page_id);
1663 return;
1664 }
1655 1665
1656 if (current_size > 0) { 1666 if (current_size > 0) {
1657 // Prune any entries which are in front of the current entry. 1667 // Prune any entries which are in front of the current entry.
1658 // Also prune the current entry if we are to replace the current entry.
1659 // last_committed_entry_index_ must be updated here since calls to 1668 // last_committed_entry_index_ must be updated here since calls to
1660 // NotifyPrunedEntries() below may re-enter and we must make sure 1669 // NotifyPrunedEntries() below may re-enter and we must make sure
1661 // last_committed_entry_index_ is not left in an invalid state. 1670 // last_committed_entry_index_ is not left in an invalid state.
1662 if (replace)
1663 --last_committed_entry_index_;
1664
1665 int num_pruned = 0; 1671 int num_pruned = 0;
1666 while (last_committed_entry_index_ < (current_size - 1)) { 1672 while (last_committed_entry_index_ < (current_size - 1)) {
1667 num_pruned++; 1673 num_pruned++;
1668 entries_.pop_back(); 1674 entries_.pop_back();
1669 current_size--; 1675 current_size--;
1670 } 1676 }
1671 if (num_pruned > 0) // Only notify if we did prune something. 1677 if (num_pruned > 0) // Only notify if we did prune something.
1672 NotifyPrunedEntries(this, false, num_pruned); 1678 NotifyPrunedEntries(this, false, num_pruned);
1673 } 1679 }
1674 1680
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 } 2003 }
1998 } 2004 }
1999 } 2005 }
2000 2006
2001 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2007 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2002 const base::Callback<base::Time()>& get_timestamp_callback) { 2008 const base::Callback<base::Time()>& get_timestamp_callback) {
2003 get_timestamp_callback_ = get_timestamp_callback; 2009 get_timestamp_callback_ = get_timestamp_callback;
2004 } 2010 }
2005 2011
2006 } // namespace content 2012 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698