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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/navigation_controller_impl.cc
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index 1f07ec664e0b2f0f212e746e2fb5d89d9d80db42..572f3c5f2fb27d56730361bf351a9d278a1e2fb8 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -915,7 +915,6 @@ bool NavigationControllerImpl::RendererDidNavigate(
// the caller that nothing has happened.
if (pending_entry_) {
DiscardNonCommittedEntries();
- delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
}
return false;
default:
@@ -1777,13 +1776,26 @@ void NavigationControllerImpl::RemoveEntryAtIndexInternal(int index) {
}
void NavigationControllerImpl::DiscardNonCommittedEntries() {
- bool transient = transient_entry_index_ != -1;
+ bool discarding_visible_entry = GetVisibleEntry() != GetLastCommittedEntry();
+ bool had_transient_entry = GetTransientEntry() != nullptr;
+
+ // Clearing the transient entry should always result in a change to the
+ // visible entry.
+ DCHECK(!had_transient_entry || discarding_visible_entry);
+
+ // Actually discard pending entries.
DiscardNonCommittedEntriesInternal();
- // If there was a transient entry, invalidate everything so the new active
- // entry state is shown.
- if (transient) {
- delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL);
+ DCHECK_EQ(GetVisibleEntry(), GetLastCommittedEntry());
+ DCHECK(!GetTransientEntry());
+ DCHECK(!GetPendingEntry());
+
+ if (discarding_visible_entry) {
+ // If we discarded a visible transient entry, invalidate all.
+ // Otherwise we've discarded a pending entry, and we only
+ // need to invalidate the URL.
+ delegate_->NotifyNavigationStateChanged(
+ had_transient_entry ? INVALIDATE_TYPE_ALL : INVALIDATE_TYPE_URL);
}
}
« 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