| OLD | NEW |
| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 tab_contents_->interstitial_page()->DontProceed(); | 345 tab_contents_->interstitial_page()->DontProceed(); |
| 346 return; | 346 return; |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Base the navigation on where we are now... | 349 // Base the navigation on where we are now... |
| 350 int current_index = GetCurrentEntryIndex(); | 350 int current_index = GetCurrentEntryIndex(); |
| 351 | 351 |
| 352 DiscardNonCommittedEntries(); | 352 DiscardNonCommittedEntries(); |
| 353 | 353 |
| 354 pending_entry_index_ = current_index - 1; | 354 pending_entry_index_ = current_index - 1; |
| 355 entries_[pending_entry_index_]->set_transition_type( | |
| 356 entries_[pending_entry_index_]->transition_type() | | |
| 357 PageTransition::FORWARD_BACK); | |
| 358 NavigateToPendingEntry(NO_RELOAD); | 355 NavigateToPendingEntry(NO_RELOAD); |
| 359 } | 356 } |
| 360 | 357 |
| 361 void NavigationController::GoForward() { | 358 void NavigationController::GoForward() { |
| 362 if (!CanGoForward()) { | 359 if (!CanGoForward()) { |
| 363 NOTREACHED(); | 360 NOTREACHED(); |
| 364 return; | 361 return; |
| 365 } | 362 } |
| 366 | 363 |
| 367 // If an interstitial page is showing, the previous renderer is blocked and | 364 // If an interstitial page is showing, the previous renderer is blocked and |
| (...skipping 10 matching lines...) Expand all Loading... |
| 378 int current_index = GetCurrentEntryIndex(); | 375 int current_index = GetCurrentEntryIndex(); |
| 379 | 376 |
| 380 DiscardNonCommittedEntries(); | 377 DiscardNonCommittedEntries(); |
| 381 | 378 |
| 382 pending_entry_index_ = current_index; | 379 pending_entry_index_ = current_index; |
| 383 // If there was a transient entry, we removed it making the current index | 380 // If there was a transient entry, we removed it making the current index |
| 384 // the next page. | 381 // the next page. |
| 385 if (!transient) | 382 if (!transient) |
| 386 pending_entry_index_++; | 383 pending_entry_index_++; |
| 387 | 384 |
| 388 entries_[pending_entry_index_]->set_transition_type( | |
| 389 entries_[pending_entry_index_]->transition_type() | | |
| 390 PageTransition::FORWARD_BACK); | |
| 391 NavigateToPendingEntry(NO_RELOAD); | 385 NavigateToPendingEntry(NO_RELOAD); |
| 392 } | 386 } |
| 393 | 387 |
| 394 void NavigationController::GoToIndex(int index) { | 388 void NavigationController::GoToIndex(int index) { |
| 395 if (index < 0 || index >= static_cast<int>(entries_.size())) { | 389 if (index < 0 || index >= static_cast<int>(entries_.size())) { |
| 396 NOTREACHED(); | 390 NOTREACHED(); |
| 397 return; | 391 return; |
| 398 } | 392 } |
| 399 | 393 |
| 400 if (transient_entry_index_ != -1) { | 394 if (transient_entry_index_ != -1) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 419 // Unblock the renderer (and disable the interstitial) to allow this | 413 // Unblock the renderer (and disable the interstitial) to allow this |
| 420 // navigation to succeed. The interstitial will stay visible until the | 414 // navigation to succeed. The interstitial will stay visible until the |
| 421 // resulting DidNavigate. | 415 // resulting DidNavigate. |
| 422 tab_contents_->interstitial_page()->CancelForNavigation(); | 416 tab_contents_->interstitial_page()->CancelForNavigation(); |
| 423 } | 417 } |
| 424 } | 418 } |
| 425 | 419 |
| 426 DiscardNonCommittedEntries(); | 420 DiscardNonCommittedEntries(); |
| 427 | 421 |
| 428 pending_entry_index_ = index; | 422 pending_entry_index_ = index; |
| 429 entries_[pending_entry_index_]->set_transition_type( | |
| 430 entries_[pending_entry_index_]->transition_type() | | |
| 431 PageTransition::FORWARD_BACK); | |
| 432 NavigateToPendingEntry(NO_RELOAD); | 423 NavigateToPendingEntry(NO_RELOAD); |
| 433 } | 424 } |
| 434 | 425 |
| 435 void NavigationController::GoToOffset(int offset) { | 426 void NavigationController::GoToOffset(int offset) { |
| 436 int index = (transient_entry_index_ != -1) ? | 427 int index = (transient_entry_index_ != -1) ? |
| 437 transient_entry_index_ + offset : | 428 transient_entry_index_ + offset : |
| 438 last_committed_entry_index_ + offset; | 429 last_committed_entry_index_ + offset; |
| 439 if (index < 0 || index >= entry_count()) | 430 if (index < 0 || index >= entry_count()) |
| 440 return; | 431 return; |
| 441 | 432 |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 for (int i = 0; i < max_index; i++) { | 1194 for (int i = 0; i < max_index; i++) { |
| 1204 // When cloning a tab, copy all entries except interstitial pages | 1195 // When cloning a tab, copy all entries except interstitial pages |
| 1205 if (source.entries_[i].get()->page_type() != | 1196 if (source.entries_[i].get()->page_type() != |
| 1206 NavigationEntry::INTERSTITIAL_PAGE) { | 1197 NavigationEntry::INTERSTITIAL_PAGE) { |
| 1207 entries_.insert(entries_.begin() + insert_index++, | 1198 entries_.insert(entries_.begin() + insert_index++, |
| 1208 linked_ptr<NavigationEntry>( | 1199 linked_ptr<NavigationEntry>( |
| 1209 new NavigationEntry(*source.entries_[i]))); | 1200 new NavigationEntry(*source.entries_[i]))); |
| 1210 } | 1201 } |
| 1211 } | 1202 } |
| 1212 } | 1203 } |
| OLD | NEW |