OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 // water marks. | 219 // water marks. |
220 low_water_mark_ = high_water_mark_ = t; | 220 low_water_mark_ = high_water_mark_ = t; |
221 return t; | 221 return t; |
222 } | 222 } |
223 | 223 |
224 NavigationControllerImpl::NavigationControllerImpl( | 224 NavigationControllerImpl::NavigationControllerImpl( |
225 NavigationControllerDelegate* delegate, | 225 NavigationControllerDelegate* delegate, |
226 BrowserContext* browser_context) | 226 BrowserContext* browser_context) |
227 : browser_context_(browser_context), | 227 : browser_context_(browser_context), |
228 pending_entry_(NULL), | 228 pending_entry_(NULL), |
229 failed_pending_entry_id_(0), | |
230 failed_pending_entry_should_replace_(false), | |
229 last_committed_entry_index_(-1), | 231 last_committed_entry_index_(-1), |
230 pending_entry_index_(-1), | 232 pending_entry_index_(-1), |
231 transient_entry_index_(-1), | 233 transient_entry_index_(-1), |
232 delegate_(delegate), | 234 delegate_(delegate), |
233 max_restored_page_id_(-1), | 235 max_restored_page_id_(-1), |
234 ssl_manager_(this), | 236 ssl_manager_(this), |
235 needs_reload_(false), | 237 needs_reload_(false), |
236 is_initial_navigation_(true), | 238 is_initial_navigation_(true), |
237 in_navigate_to_pending_entry_(false), | 239 in_navigate_to_pending_entry_(false), |
238 pending_reload_(NO_RELOAD), | 240 pending_reload_(NO_RELOAD), |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
789 details->previous_entry_index = -1; | 791 details->previous_entry_index = -1; |
790 } | 792 } |
791 | 793 |
792 // If we have a pending entry at this point, it should have a SiteInstance. | 794 // If we have a pending entry at this point, it should have a SiteInstance. |
793 // Restored entries start out with a null SiteInstance, but we should have | 795 // Restored entries start out with a null SiteInstance, but we should have |
794 // assigned one in NavigateToPendingEntry. | 796 // assigned one in NavigateToPendingEntry. |
795 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); | 797 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); |
796 | 798 |
797 // If we are doing a cross-site reload, we need to replace the existing | 799 // If we are doing a cross-site reload, we need to replace the existing |
798 // navigation entry, not add another entry to the history. This has the side | 800 // navigation entry, not add another entry to the history. This has the side |
799 // effect of removing forward browsing history, if such existed. | 801 // effect of removing forward browsing history, if such existed. Or if we are |
800 // Or if we are doing a cross-site redirect navigation, | 802 // doing a cross-site redirect navigation, we will do a similar thing. |
Charlie Reis
2015/04/07 18:00:47
Might also be worth mentioning the error page case
Avi (use Gerrit)
2015/04/07 18:22:58
Done.
| |
801 // we will do a similar thing. | 803 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { |
802 details->did_replace_entry = | 804 details->did_replace_entry = failed_pending_entry_should_replace_; |
803 pending_entry_ && pending_entry_->should_replace_entry(); | 805 } else { |
806 details->did_replace_entry = pending_entry_ && | |
807 pending_entry_->should_replace_entry(); | |
808 } | |
804 | 809 |
805 // Do navigation-type specific actions. These will make and commit an entry. | 810 // Do navigation-type specific actions. These will make and commit an entry. |
806 details->type = ClassifyNavigation(rfh, params); | 811 details->type = ClassifyNavigation(rfh, params); |
807 | 812 |
808 // is_in_page must be computed before the entry gets committed. | 813 // is_in_page must be computed before the entry gets committed. |
809 details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(), | 814 details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(), |
810 params.url, params.was_within_same_page, rfh); | 815 params.url, params.was_within_same_page, rfh); |
811 | 816 |
812 switch (details->type) { | 817 switch (details->type) { |
813 case NAVIGATION_TYPE_NEW_PAGE: | 818 case NAVIGATION_TYPE_NEW_PAGE: |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1751 RestoreType type) { | 1756 RestoreType type) { |
1752 DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); | 1757 DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); |
1753 ConfigureEntriesForRestore(&entries_, type); | 1758 ConfigureEntriesForRestore(&entries_, type); |
1754 | 1759 |
1755 SetMaxRestoredPageID(static_cast<int32>(GetEntryCount())); | 1760 SetMaxRestoredPageID(static_cast<int32>(GetEntryCount())); |
1756 | 1761 |
1757 last_committed_entry_index_ = selected_index; | 1762 last_committed_entry_index_ = selected_index; |
1758 } | 1763 } |
1759 | 1764 |
1760 void NavigationControllerImpl::DiscardNonCommittedEntriesInternal() { | 1765 void NavigationControllerImpl::DiscardNonCommittedEntriesInternal() { |
1761 DiscardPendingEntry(); | 1766 DiscardPendingEntry(false); |
1762 DiscardTransientEntry(); | 1767 DiscardTransientEntry(); |
1763 } | 1768 } |
1764 | 1769 |
1765 void NavigationControllerImpl::DiscardPendingEntry() { | 1770 void NavigationControllerImpl::DiscardPendingEntry(bool was_failure) { |
1766 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in | 1771 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in |
1767 // progress, since this will cause a use-after-free. (We only allow this | 1772 // progress, since this will cause a use-after-free. (We only allow this |
1768 // when the tab is being destroyed for shutdown, since it won't return to | 1773 // when the tab is being destroyed for shutdown, since it won't return to |
1769 // NavigateToEntry in that case.) http://crbug.com/347742. | 1774 // NavigateToEntry in that case.) http://crbug.com/347742. |
1770 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); | 1775 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); |
1771 | 1776 |
1777 if (was_failure && pending_entry_) { | |
1778 failed_pending_entry_id_ = pending_entry_->GetUniqueID(); | |
1779 failed_pending_entry_should_replace_ = | |
1780 pending_entry_->should_replace_entry(); | |
1781 } else { | |
1782 failed_pending_entry_id_ = 0; | |
1783 } | |
1784 | |
1772 if (pending_entry_index_ == -1) | 1785 if (pending_entry_index_ == -1) |
1773 delete pending_entry_; | 1786 delete pending_entry_; |
1774 pending_entry_ = NULL; | 1787 pending_entry_ = NULL; |
1775 pending_entry_index_ = -1; | 1788 pending_entry_index_ = -1; |
1776 } | 1789 } |
1777 | 1790 |
1778 void NavigationControllerImpl::DiscardTransientEntry() { | 1791 void NavigationControllerImpl::DiscardTransientEntry() { |
1779 if (transient_entry_index_ == -1) | 1792 if (transient_entry_index_ == -1) |
1780 return; | 1793 return; |
1781 entries_.erase(entries_.begin() + transient_entry_index_); | 1794 entries_.erase(entries_.begin() + transient_entry_index_); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1830 } | 1843 } |
1831 } | 1844 } |
1832 } | 1845 } |
1833 | 1846 |
1834 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1847 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1835 const base::Callback<base::Time()>& get_timestamp_callback) { | 1848 const base::Callback<base::Time()>& get_timestamp_callback) { |
1836 get_timestamp_callback_ = get_timestamp_callback; | 1849 get_timestamp_callback_ = get_timestamp_callback; |
1837 } | 1850 } |
1838 | 1851 |
1839 } // namespace content | 1852 } // namespace content |
OLD | NEW |