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

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

Issue 1902433002: Do not create pending NavigationEntry when a transient one is present. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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 | « chrome/test/data/window_open_and_navigate.html ('k') | no next file » | 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 #include "content/browser/frame_host/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 SiteInstanceImpl* site_instance, 1017 SiteInstanceImpl* site_instance,
1018 NavigationHandleImpl* navigation_handle) { 1018 NavigationHandleImpl* navigation_handle) {
1019 // If there is no browser-initiated pending entry for this navigation and it 1019 // If there is no browser-initiated pending entry for this navigation and it
1020 // is not for the error URL, create a pending entry using the current 1020 // is not for the error URL, create a pending entry using the current
1021 // SiteInstance, and ensure the address bar updates accordingly. We don't 1021 // SiteInstance, and ensure the address bar updates accordingly. We don't
1022 // know the referrer or extra headers at this point, but the referrer will 1022 // know the referrer or extra headers at this point, but the referrer will
1023 // be set properly upon commit. 1023 // be set properly upon commit.
1024 NavigationEntryImpl* pending_entry = controller_->GetPendingEntry(); 1024 NavigationEntryImpl* pending_entry = controller_->GetPendingEntry();
1025 bool has_browser_initiated_pending_entry = 1025 bool has_browser_initiated_pending_entry =
1026 pending_entry && !pending_entry->is_renderer_initiated(); 1026 pending_entry && !pending_entry->is_renderer_initiated();
1027 if (!has_browser_initiated_pending_entry) { 1027
1028 // If there is a transient entry, creating a new pending entry will result
1029 // in deleting it, which leads to inconsistent state.
1030 bool has_transient_entry = !!controller_->GetTransientEntry();
1031
1032 if (!has_browser_initiated_pending_entry && !has_transient_entry) {
1028 scoped_ptr<NavigationEntryImpl> entry = 1033 scoped_ptr<NavigationEntryImpl> entry =
1029 NavigationEntryImpl::FromNavigationEntry( 1034 NavigationEntryImpl::FromNavigationEntry(
1030 controller_->CreateNavigationEntry( 1035 controller_->CreateNavigationEntry(
1031 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, 1036 url, content::Referrer(), ui::PAGE_TRANSITION_LINK,
1032 true /* is_renderer_initiated */, std::string(), 1037 true /* is_renderer_initiated */, std::string(),
1033 controller_->GetBrowserContext())); 1038 controller_->GetBrowserContext()));
1034 entry->set_site_instance(site_instance); 1039 entry->set_site_instance(site_instance);
1035 // TODO(creis): If there's a pending entry already, find a safe way to 1040 // TODO(creis): If there's a pending entry already, find a safe way to
1036 // update it instead of replacing it and copying over things like this. 1041 // update it instead of replacing it and copying over things like this.
1037 // That will allow us to skip the NavigationHandle update below as well. 1042 // That will allow us to skip the NavigationHandle update below as well.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 if (pending_entry != controller_->GetVisibleEntry() || 1094 if (pending_entry != controller_->GetVisibleEntry() ||
1090 !should_preserve_entry) { 1095 !should_preserve_entry) {
1091 controller_->DiscardPendingEntry(true); 1096 controller_->DiscardPendingEntry(true);
1092 1097
1093 // Also force the UI to refresh. 1098 // Also force the UI to refresh.
1094 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); 1099 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
1095 } 1100 }
1096 } 1101 }
1097 1102
1098 } // namespace content 1103 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/data/window_open_and_navigate.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698