OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 | 654 |
655 // The entry we found in the list might be pending if the user hit | 655 // The entry we found in the list might be pending if the user hit |
656 // back/forward/reload. This load should commit it (since it's already in the | 656 // back/forward/reload. This load should commit it (since it's already in the |
657 // list, we can just discard the pending pointer). | 657 // list, we can just discard the pending pointer). |
658 // | 658 // |
659 // Note that we need to use the "internal" version since we don't want to | 659 // Note that we need to use the "internal" version since we don't want to |
660 // actually change any other state, just kill the pointer. | 660 // actually change any other state, just kill the pointer. |
661 if (entry == pending_entry_) | 661 if (entry == pending_entry_) |
662 DiscardNonCommittedEntriesInternal(); | 662 DiscardNonCommittedEntriesInternal(); |
663 | 663 |
664 // If a transient entry was removed, the indeces might have changed, get | |
brettw
2009/10/14 20:47:09
indeces -> indices
| |
665 // entry_index again. | |
666 entry_index = GetEntryIndexWithPageID(tab_contents_->GetSiteInstance(), | |
brettw
2009/10/14 20:47:09
How about skipping entry_index and just setting la
| |
667 params.page_id); | |
664 last_committed_entry_index_ = entry_index; | 668 last_committed_entry_index_ = entry_index; |
665 } | 669 } |
666 | 670 |
667 void NavigationController::RendererDidNavigateToSamePage( | 671 void NavigationController::RendererDidNavigateToSamePage( |
668 const ViewHostMsg_FrameNavigate_Params& params) { | 672 const ViewHostMsg_FrameNavigate_Params& params) { |
669 // This mode implies we have a pending entry that's the same as an existing | 673 // This mode implies we have a pending entry that's the same as an existing |
670 // entry for this page ID. This entry is guaranteed to exist by | 674 // entry for this page ID. This entry is guaranteed to exist by |
671 // ClassifyNavigation. All we need to do is update the existing entry. | 675 // ClassifyNavigation. All we need to do is update the existing entry. |
672 NavigationEntry* existing_entry = GetEntryWithPageID( | 676 NavigationEntry* existing_entry = GetEntryWithPageID( |
673 tab_contents_->GetSiteInstance(), | 677 tab_contents_->GetSiteInstance(), |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 pending_entry_ = NULL; | 974 pending_entry_ = NULL; |
971 pending_entry_index_ = -1; | 975 pending_entry_index_ = -1; |
972 | 976 |
973 DiscardTransientEntry(); | 977 DiscardTransientEntry(); |
974 } | 978 } |
975 | 979 |
976 void NavigationController::DiscardTransientEntry() { | 980 void NavigationController::DiscardTransientEntry() { |
977 if (transient_entry_index_ == -1) | 981 if (transient_entry_index_ == -1) |
978 return; | 982 return; |
979 entries_.erase(entries_.begin() + transient_entry_index_); | 983 entries_.erase(entries_.begin() + transient_entry_index_); |
984 if (last_committed_entry_index_ > transient_entry_index_) | |
985 last_committed_entry_index_--; | |
980 transient_entry_index_ = -1; | 986 transient_entry_index_ = -1; |
981 } | 987 } |
982 | 988 |
983 int NavigationController::GetEntryIndexWithPageID( | 989 int NavigationController::GetEntryIndexWithPageID( |
984 SiteInstance* instance, int32 page_id) const { | 990 SiteInstance* instance, int32 page_id) const { |
985 for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) { | 991 for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) { |
986 if ((entries_[i]->site_instance() == instance) && | 992 if ((entries_[i]->site_instance() == instance) && |
987 (entries_[i]->page_id() == page_id)) | 993 (entries_[i]->page_id() == page_id)) |
988 return i; | 994 return i; |
989 } | 995 } |
990 return -1; | 996 return -1; |
991 } | 997 } |
992 | 998 |
993 NavigationEntry* NavigationController::GetTransientEntry() const { | 999 NavigationEntry* NavigationController::GetTransientEntry() const { |
994 if (transient_entry_index_ == -1) | 1000 if (transient_entry_index_ == -1) |
995 return NULL; | 1001 return NULL; |
996 return entries_[transient_entry_index_].get(); | 1002 return entries_[transient_entry_index_].get(); |
997 } | 1003 } |
OLD | NEW |