OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/navigation_controller_impl.h" | 5 #include "content/browser/web_contents/navigation_controller_impl.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_number_conversions.h" // Temporary | 9 #include "base/string_number_conversions.h" // Temporary |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 | 976 |
977 // The entry we found in the list might be pending if the user hit | 977 // The entry we found in the list might be pending if the user hit |
978 // back/forward/reload. This load should commit it (since it's already in the | 978 // back/forward/reload. This load should commit it (since it's already in the |
979 // list, we can just discard the pending pointer). We should also discard the | 979 // list, we can just discard the pending pointer). We should also discard the |
980 // pending entry if it corresponds to a different navigation, since that one | 980 // pending entry if it corresponds to a different navigation, since that one |
981 // is now likely canceled. If it is not canceled, we will treat it as a new | 981 // is now likely canceled. If it is not canceled, we will treat it as a new |
982 // navigation when it arrives, which is also ok. | 982 // navigation when it arrives, which is also ok. |
983 // | 983 // |
984 // Note that we need to use the "internal" version since we don't want to | 984 // Note that we need to use the "internal" version since we don't want to |
985 // actually change any other state, just kill the pointer. | 985 // actually change any other state, just kill the pointer. |
986 if (pending_entry_) | 986 DiscardNonCommittedEntriesInternal(); |
987 DiscardNonCommittedEntriesInternal(); | |
988 | 987 |
989 // If a transient entry was removed, the indices might have changed, so we | 988 // If a transient entry was removed, the indices might have changed, so we |
990 // have to query the entry index again. | 989 // have to query the entry index again. |
991 last_committed_entry_index_ = | 990 last_committed_entry_index_ = |
992 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); | 991 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); |
993 } | 992 } |
994 | 993 |
995 void NavigationControllerImpl::RendererDidNavigateToSamePage( | 994 void NavigationControllerImpl::RendererDidNavigateToSamePage( |
996 const ViewHostMsg_FrameNavigate_Params& params) { | 995 const ViewHostMsg_FrameNavigate_Params& params) { |
997 // This mode implies we have a pending entry that's the same as an existing | 996 // This mode implies we have a pending entry that's the same as an existing |
(...skipping 27 matching lines...) Expand all Loading... |
1025 // entry and it will be the same page as the new navigation (minus the | 1024 // entry and it will be the same page as the new navigation (minus the |
1026 // reference fragments, of course). We'll update the URL of the existing | 1025 // reference fragments, of course). We'll update the URL of the existing |
1027 // entry without pruning the forward history. | 1026 // entry without pruning the forward history. |
1028 existing_entry->SetURL(params.url); | 1027 existing_entry->SetURL(params.url); |
1029 if (existing_entry->update_virtual_url_with_url()) | 1028 if (existing_entry->update_virtual_url_with_url()) |
1030 UpdateVirtualURLToURL(existing_entry, params.url); | 1029 UpdateVirtualURLToURL(existing_entry, params.url); |
1031 | 1030 |
1032 // This replaces the existing entry since the page ID didn't change. | 1031 // This replaces the existing entry since the page ID didn't change. |
1033 *did_replace_entry = true; | 1032 *did_replace_entry = true; |
1034 | 1033 |
1035 if (pending_entry_) | 1034 DiscardNonCommittedEntriesInternal(); |
1036 DiscardNonCommittedEntriesInternal(); | |
1037 | 1035 |
1038 // If a transient entry was removed, the indices might have changed, so we | 1036 // If a transient entry was removed, the indices might have changed, so we |
1039 // have to query the entry index again. | 1037 // have to query the entry index again. |
1040 last_committed_entry_index_ = | 1038 last_committed_entry_index_ = |
1041 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); | 1039 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); |
1042 } | 1040 } |
1043 | 1041 |
1044 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 1042 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
1045 const ViewHostMsg_FrameNavigate_Params& params) { | 1043 const ViewHostMsg_FrameNavigate_Params& params) { |
1046 if (content::PageTransitionStripQualifier(params.transition) == | 1044 if (content::PageTransitionStripQualifier(params.transition) == |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 for (int i = 0; i < max_index; i++) { | 1562 for (int i = 0; i < max_index; i++) { |
1565 // When cloning a tab, copy all entries except interstitial pages | 1563 // When cloning a tab, copy all entries except interstitial pages |
1566 if (source.entries_[i].get()->GetPageType() != | 1564 if (source.entries_[i].get()->GetPageType() != |
1567 content::PAGE_TYPE_INTERSTITIAL) { | 1565 content::PAGE_TYPE_INTERSTITIAL) { |
1568 entries_.insert(entries_.begin() + insert_index++, | 1566 entries_.insert(entries_.begin() + insert_index++, |
1569 linked_ptr<NavigationEntryImpl>( | 1567 linked_ptr<NavigationEntryImpl>( |
1570 new NavigationEntryImpl(*source.entries_[i]))); | 1568 new NavigationEntryImpl(*source.entries_[i]))); |
1571 } | 1569 } |
1572 } | 1570 } |
1573 } | 1571 } |
OLD | NEW |