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

Unified Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 2644963004: Fix flickering in new tab title after r444582. (Closed)
Patch Set: Created 3 years, 11 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 | « chrome/browser/ui/search/search_tab_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/search_tab_helper.cc
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index 2b48edd3dfc691909cd76982da97e39224b44bfa..95f076d299e9f0d282becec36ebc254eb0bb1645 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -45,6 +45,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/referrer.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "net/base/net_errors.h"
@@ -216,8 +217,35 @@ void SearchTabHelper::OnTabDeactivated() {
ipc_router_.OnTabDeactivated();
}
+void SearchTabHelper::DidStartNavigationToPendingEntry(
+ const GURL& url,
+ content::ReloadType reload_type) {
+ // TODO(jam): delete this method once PlzNavigate is turned on by default.
+ // When PlzNavigate is enabled, DidStartNavigation is called early enough such
+ // that there's no flickering. However when PlzNavigate is disabled,
+ // DidStartNavigation is called too late and "Untitled" shows up momentarily.
+ // The fix is to override this deprecated callback for the non-PlzNavigate
+ // case.
Marc Treib 2017/01/20 09:26:47 Is there a bug you could reference here? (I'm seei
jam 2017/01/20 15:11:35 When PlzNavigate is turned on, we will delete this
+ if (content::IsBrowserSideNavigationEnabled())
+ return;
+
+ if (search::IsNTPURL(url, profile())) {
Marc Treib 2017/01/20 09:26:47 Put this block into a new helper, so it doesn't ha
jam 2017/01/20 15:11:35 given that this is only 3 lines of code, I thought
+ // Set the title on any pending entry corresponding to the NTP. This
+ // prevents any flickering of the tab title.
+ content::NavigationEntry* entry =
+ web_contents_->GetController().GetPendingEntry();
+ if (entry) {
+ web_contents_->UpdateTitleForEntry(
+ entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
+ }
+ }
+}
+
void SearchTabHelper::DidStartNavigation(
content::NavigationHandle* navigation_handle) {
+ if (!content::IsBrowserSideNavigationEnabled())
Marc Treib 2017/01/20 09:26:47 Once the non-PlzNavigate hack above is gone, this
jam 2017/01/20 15:11:35 (same as first comment)
+ return;
+
if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage())
return;
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698