| 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 /* | 5 /* |
| 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * | 10 * |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 return false; | 908 return false; |
| 909 } | 909 } |
| 910 break; | 910 break; |
| 911 case NAVIGATION_TYPE_NAV_IGNORE: | 911 case NAVIGATION_TYPE_NAV_IGNORE: |
| 912 // If a pending navigation was in progress, this canceled it. We should | 912 // If a pending navigation was in progress, this canceled it. We should |
| 913 // discard it and make sure it is removed from the URL bar. After that, | 913 // discard it and make sure it is removed from the URL bar. After that, |
| 914 // there is nothing we can do with this navigation, so we just return to | 914 // there is nothing we can do with this navigation, so we just return to |
| 915 // the caller that nothing has happened. | 915 // the caller that nothing has happened. |
| 916 if (pending_entry_) { | 916 if (pending_entry_) { |
| 917 DiscardNonCommittedEntries(); | 917 DiscardNonCommittedEntries(); |
| 918 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 918 } | 919 } |
| 919 return false; | 920 return false; |
| 920 default: | 921 default: |
| 921 NOTREACHED(); | 922 NOTREACHED(); |
| 922 } | 923 } |
| 923 | 924 |
| 924 // At this point, we know that the navigation has just completed, so | 925 // At this point, we know that the navigation has just completed, so |
| 925 // record the time. | 926 // record the time. |
| 926 // | 927 // |
| 927 // TODO(akalin): Use "sane time" as described in | 928 // TODO(akalin): Use "sane time" as described in |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1769 DCHECK(index != last_committed_entry_index_); | 1770 DCHECK(index != last_committed_entry_index_); |
| 1770 | 1771 |
| 1771 DiscardNonCommittedEntries(); | 1772 DiscardNonCommittedEntries(); |
| 1772 | 1773 |
| 1773 entries_.erase(entries_.begin() + index); | 1774 entries_.erase(entries_.begin() + index); |
| 1774 if (last_committed_entry_index_ > index) | 1775 if (last_committed_entry_index_ > index) |
| 1775 last_committed_entry_index_--; | 1776 last_committed_entry_index_--; |
| 1776 } | 1777 } |
| 1777 | 1778 |
| 1778 void NavigationControllerImpl::DiscardNonCommittedEntries() { | 1779 void NavigationControllerImpl::DiscardNonCommittedEntries() { |
| 1779 bool discarding_visible_entry = GetVisibleEntry() != GetLastCommittedEntry(); | 1780 bool transient = transient_entry_index_ != -1; |
| 1780 bool had_transient_entry = GetTransientEntry() != nullptr; | |
| 1781 | |
| 1782 // Clearing the transient entry should always result in a change to the | |
| 1783 // visible entry. | |
| 1784 DCHECK(!had_transient_entry || discarding_visible_entry); | |
| 1785 | |
| 1786 // Actually discard pending entries. | |
| 1787 DiscardNonCommittedEntriesInternal(); | 1781 DiscardNonCommittedEntriesInternal(); |
| 1788 | 1782 |
| 1789 DCHECK_EQ(GetVisibleEntry(), GetLastCommittedEntry()); | 1783 // If there was a transient entry, invalidate everything so the new active |
| 1790 DCHECK(!GetTransientEntry()); | 1784 // entry state is shown. |
| 1791 DCHECK(!GetPendingEntry()); | 1785 if (transient) { |
| 1792 | 1786 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); |
| 1793 if (discarding_visible_entry) { | |
| 1794 // If we discarded a visible transient entry, invalidate all. | |
| 1795 // Otherwise we've discarded a pending entry, and we only | |
| 1796 // need to invalidate the URL. | |
| 1797 delegate_->NotifyNavigationStateChanged( | |
| 1798 had_transient_entry ? INVALIDATE_TYPE_ALL : INVALIDATE_TYPE_URL); | |
| 1799 } | 1787 } |
| 1800 } | 1788 } |
| 1801 | 1789 |
| 1802 NavigationEntryImpl* NavigationControllerImpl::GetPendingEntry() const { | 1790 NavigationEntryImpl* NavigationControllerImpl::GetPendingEntry() const { |
| 1803 // If there is no pending_entry_, there should be no pending_entry_index_. | 1791 // If there is no pending_entry_, there should be no pending_entry_index_. |
| 1804 DCHECK(pending_entry_ || pending_entry_index_ == -1); | 1792 DCHECK(pending_entry_ || pending_entry_index_ == -1); |
| 1805 | 1793 |
| 1806 // If there is a pending_entry_index_, then pending_entry_ must be the entry | 1794 // If there is a pending_entry_index_, then pending_entry_ must be the entry |
| 1807 // at that index. | 1795 // at that index. |
| 1808 DCHECK(pending_entry_index_ == -1 || | 1796 DCHECK(pending_entry_index_ == -1 || |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 DCHECK(pending_entry_index_ == -1 || | 2234 DCHECK(pending_entry_index_ == -1 || |
| 2247 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); | 2235 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); |
| 2248 } | 2236 } |
| 2249 | 2237 |
| 2250 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2238 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2251 const base::Callback<base::Time()>& get_timestamp_callback) { | 2239 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2252 get_timestamp_callback_ = get_timestamp_callback; | 2240 get_timestamp_callback_ = get_timestamp_callback; |
| 2253 } | 2241 } |
| 2254 | 2242 |
| 2255 } // namespace content | 2243 } // namespace content |
| OLD | NEW |