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

Side by Side Diff: chrome/browser/tab_contents/navigation_controller.cc

Issue 3415026: Makes instant support other open dispositions. (Closed)
Patch Set: Merge and prune Created 10 years, 2 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 | « chrome/browser/tab_contents/navigation_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/tab_contents/navigation_controller.h" 5 #include "chrome/browser/tab_contents/navigation_controller.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 // point to the previous entry. 975 // point to the previous entry.
976 transient_entry_index_ = entry_count() - 1; 976 transient_entry_index_ = entry_count() - 1;
977 if (last_committed_entry_index_ != -1) 977 if (last_committed_entry_index_ != -1)
978 last_committed_entry_index_--; 978 last_committed_entry_index_--;
979 } 979 }
980 980
981 // Take over the session id from source. 981 // Take over the session id from source.
982 session_id_ = source.session_id_; 982 session_id_ = source.session_id_;
983 } 983 }
984 984
985 void NavigationController::PruneAllButActive() {
986 int prune_count = entry_count();
987 if (transient_entry_index_ != -1) {
988 // There is a transient entry. Prune up to it.
989 DCHECK_EQ(entry_count() - 1, transient_entry_index_);
990 prune_count = transient_entry_index_;
991 transient_entry_index_ = 0;
992 last_committed_entry_index_ = -1;
993 pending_entry_index_ = -1;
994 } else if (!pending_entry_) {
995 // There's no pending entry. Leave the last entry (if there is one).
996 if (!prune_count)
997 return;
998
999 prune_count--;
1000 last_committed_entry_index_ = 0;
1001 } else if (pending_entry_index_ != -1) {
1002 DCHECK_EQ(pending_entry_index_, prune_count - 1);
1003 pending_entry_index_ = 0;
1004 last_committed_entry_index_ = 0;
1005 prune_count--;
1006 } else {
1007 // There is a pending_entry, but it's not in entries_.
1008 pending_entry_index_ = -1;
1009 last_committed_entry_index_ = -1;
1010 }
1011
1012 if (tab_contents_->interstitial_page()) {
1013 // Normally the interstitial page hides itself if the user doesn't proceeed.
1014 // This would result in showing a NavigationEntry we just removed. Set this
1015 // so the interstitial triggers a reload if the user doesn't proceed.
1016 tab_contents_->interstitial_page()->set_reload_on_dont_proceed(true);
1017 }
1018
1019 entries_.erase(entries_.begin(), entries_.begin() + prune_count);
1020 }
1021
985 void NavigationController::DiscardNonCommittedEntries() { 1022 void NavigationController::DiscardNonCommittedEntries() {
986 bool transient = transient_entry_index_ != -1; 1023 bool transient = transient_entry_index_ != -1;
987 DiscardNonCommittedEntriesInternal(); 1024 DiscardNonCommittedEntriesInternal();
988 1025
989 // If there was a transient entry, invalidate everything so the new active 1026 // If there was a transient entry, invalidate everything so the new active
990 // entry state is shown. 1027 // entry state is shown.
991 if (transient) { 1028 if (transient) {
992 tab_contents_->NotifyNavigationStateChanged(kInvalidateAllButShelves); 1029 tab_contents_->NotifyNavigationStateChanged(kInvalidateAllButShelves);
993 } 1030 }
994 } 1031 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 } 1187 }
1151 return -1; 1188 return -1;
1152 } 1189 }
1153 1190
1154 NavigationEntry* NavigationController::GetTransientEntry() const { 1191 NavigationEntry* NavigationController::GetTransientEntry() const {
1155 if (transient_entry_index_ == -1) 1192 if (transient_entry_index_ == -1)
1156 return NULL; 1193 return NULL;
1157 return entries_[transient_entry_index_].get(); 1194 return entries_[transient_entry_index_].get();
1158 } 1195 }
1159 1196
1160 void NavigationController::PruneAllButActive() {
1161 int prune_count = entry_count();
1162 if (transient_entry_index_ != -1) {
1163 // There is a transient entry. Prune up to it.
1164 DCHECK_EQ(entry_count() - 1, transient_entry_index_);
1165 prune_count = transient_entry_index_;
1166 transient_entry_index_ = 0;
1167 last_committed_entry_index_ = -1;
1168 pending_entry_index_ = -1;
1169 } else if (!pending_entry_) {
1170 // There's no pending entry. Leave the last entry (if there is one).
1171 if (!prune_count)
1172 return;
1173
1174 prune_count--;
1175 last_committed_entry_index_ = 0;
1176 } else if (pending_entry_index_ != -1) {
1177 DCHECK_EQ(pending_entry_index_, prune_count - 1);
1178 pending_entry_index_ = 0;
1179 last_committed_entry_index_ = 0;
1180 prune_count--;
1181 } else {
1182 // There is a pending_entry, but it's not in entries_.
1183 pending_entry_index_ = -1;
1184 last_committed_entry_index_ = -1;
1185 }
1186
1187 if (tab_contents_->interstitial_page()) {
1188 // Normally the interstitial page hides itself if the user doesn't proceeed.
1189 // This would result in showing a NavigationEntry we just removed. Set this
1190 // so the interstitial triggers a reload if the user doesn't proceed.
1191 tab_contents_->interstitial_page()->set_reload_on_dont_proceed(true);
1192 }
1193
1194 entries_.erase(entries_.begin(), entries_.begin() + prune_count);
1195 }
1196
1197 void NavigationController::InsertEntriesFrom( 1197 void NavigationController::InsertEntriesFrom(
1198 const NavigationController& source, 1198 const NavigationController& source,
1199 int max_index) { 1199 int max_index) {
1200 DCHECK_LE(max_index, source.entry_count()); 1200 DCHECK_LE(max_index, source.entry_count());
1201 size_t insert_index = 0; 1201 size_t insert_index = 0;
1202 for (int i = 0; i < max_index; i++) { 1202 for (int i = 0; i < max_index; i++) {
1203 // When cloning a tab, copy all entries except interstitial pages 1203 // When cloning a tab, copy all entries except interstitial pages
1204 if (source.entries_[i].get()->page_type() != 1204 if (source.entries_[i].get()->page_type() !=
1205 NavigationEntry::INTERSTITIAL_PAGE) { 1205 NavigationEntry::INTERSTITIAL_PAGE) {
1206 entries_.insert(entries_.begin() + insert_index++, 1206 entries_.insert(entries_.begin() + insert_index++,
1207 linked_ptr<NavigationEntry>( 1207 linked_ptr<NavigationEntry>(
1208 new NavigationEntry(*source.entries_[i]))); 1208 new NavigationEntry(*source.entries_[i])));
1209 } 1209 }
1210 } 1210 }
1211 } 1211 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698