Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 2919593007: Always update the omnibox URL when cancelling via onbeforeunload (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into spoof Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
919 } 918 }
920 return false; 919 return false;
921 default: 920 default:
922 NOTREACHED(); 921 NOTREACHED();
923 } 922 }
924 923
925 // At this point, we know that the navigation has just completed, so 924 // At this point, we know that the navigation has just completed, so
926 // record the time. 925 // record the time.
927 // 926 //
928 // TODO(akalin): Use "sane time" as described in 927 // TODO(akalin): Use "sane time" as described in
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 DCHECK(index != last_committed_entry_index_); 1769 DCHECK(index != last_committed_entry_index_);
1771 1770
1772 DiscardNonCommittedEntries(); 1771 DiscardNonCommittedEntries();
1773 1772
1774 entries_.erase(entries_.begin() + index); 1773 entries_.erase(entries_.begin() + index);
1775 if (last_committed_entry_index_ > index) 1774 if (last_committed_entry_index_ > index)
1776 last_committed_entry_index_--; 1775 last_committed_entry_index_--;
1777 } 1776 }
1778 1777
1779 void NavigationControllerImpl::DiscardNonCommittedEntries() { 1778 void NavigationControllerImpl::DiscardNonCommittedEntries() {
1780 bool transient = transient_entry_index_ != -1; 1779 bool discarding_visible_entry = GetVisibleEntry() != GetLastCommittedEntry();
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.
1781 DiscardNonCommittedEntriesInternal(); 1787 DiscardNonCommittedEntriesInternal();
1782 1788
1783 // If there was a transient entry, invalidate everything so the new active 1789 DCHECK_EQ(GetVisibleEntry(), GetLastCommittedEntry());
1784 // entry state is shown. 1790 DCHECK(!GetTransientEntry());
1785 if (transient) { 1791 DCHECK(!GetPendingEntry());
1786 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); 1792
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);
1787 } 1799 }
1788 } 1800 }
1789 1801
1790 NavigationEntryImpl* NavigationControllerImpl::GetPendingEntry() const { 1802 NavigationEntryImpl* NavigationControllerImpl::GetPendingEntry() const {
1791 // If there is no pending_entry_, there should be no pending_entry_index_. 1803 // If there is no pending_entry_, there should be no pending_entry_index_.
1792 DCHECK(pending_entry_ || pending_entry_index_ == -1); 1804 DCHECK(pending_entry_ || pending_entry_index_ == -1);
1793 1805
1794 // If there is a pending_entry_index_, then pending_entry_ must be the entry 1806 // If there is a pending_entry_index_, then pending_entry_ must be the entry
1795 // at that index. 1807 // at that index.
1796 DCHECK(pending_entry_index_ == -1 || 1808 DCHECK(pending_entry_index_ == -1 ||
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 DCHECK(pending_entry_index_ == -1 || 2246 DCHECK(pending_entry_index_ == -1 ||
2235 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); 2247 pending_entry_ == GetEntryAtIndex(pending_entry_index_));
2236 } 2248 }
2237 2249
2238 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2250 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2239 const base::Callback<base::Time()>& get_timestamp_callback) { 2251 const base::Callback<base::Time()>& get_timestamp_callback) {
2240 get_timestamp_callback_ = get_timestamp_callback; 2252 get_timestamp_callback_ = get_timestamp_callback;
2241 } 2253 }
2242 2254
2243 } // namespace content 2255 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698