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