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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "chrome/browser/ui/search/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 27 matching lines...) Expand all
38 #include "components/strings/grit/components_strings.h" 38 #include "components/strings/grit/components_strings.h"
39 #include "content/public/browser/navigation_details.h" 39 #include "content/public/browser/navigation_details.h"
40 #include "content/public/browser/navigation_entry.h" 40 #include "content/public/browser/navigation_entry.h"
41 #include "content/public/browser/navigation_handle.h" 41 #include "content/public/browser/navigation_handle.h"
42 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
43 #include "content/public/browser/notification_source.h" 43 #include "content/public/browser/notification_source.h"
44 #include "content/public/browser/render_frame_host.h" 44 #include "content/public/browser/render_frame_host.h"
45 #include "content/public/browser/render_process_host.h" 45 #include "content/public/browser/render_process_host.h"
46 #include "content/public/browser/user_metrics.h" 46 #include "content/public/browser/user_metrics.h"
47 #include "content/public/browser/web_contents.h" 47 #include "content/public/browser/web_contents.h"
48 #include "content/public/common/browser_side_navigation_policy.h"
48 #include "content/public/common/referrer.h" 49 #include "content/public/common/referrer.h"
49 #include "google_apis/gaia/gaia_auth_util.h" 50 #include "google_apis/gaia/gaia_auth_util.h"
50 #include "net/base/net_errors.h" 51 #include "net/base/net_errors.h"
51 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
52 #include "ui/base/page_transition_types.h" 53 #include "ui/base/page_transition_types.h"
53 #include "url/gurl.h" 54 #include "url/gurl.h"
54 55
55 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchTabHelper); 56 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchTabHelper);
56 57
57 namespace { 58 namespace {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // startup or from the user opening a new tab, and if we wait until later, 210 // startup or from the user opening a new tab, and if we wait until later,
210 // it won't correctly detect this case. 211 // it won't correctly detect this case.
211 NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_); 212 NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_);
212 } 213 }
213 } 214 }
214 215
215 void SearchTabHelper::OnTabDeactivated() { 216 void SearchTabHelper::OnTabDeactivated() {
216 ipc_router_.OnTabDeactivated(); 217 ipc_router_.OnTabDeactivated();
217 } 218 }
218 219
220 void SearchTabHelper::DidStartNavigationToPendingEntry(
221 const GURL& url,
222 content::ReloadType reload_type) {
223 // TODO(jam): delete this method once PlzNavigate is turned on by default.
224 // When PlzNavigate is enabled, DidStartNavigation is called early enough such
225 // that there's no flickering. However when PlzNavigate is disabled,
226 // DidStartNavigation is called too late and "Untitled" shows up momentarily.
227 // The fix is to override this deprecated callback for the non-PlzNavigate
228 // 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
229 if (content::IsBrowserSideNavigationEnabled())
230 return;
231
232 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
233 // Set the title on any pending entry corresponding to the NTP. This
234 // prevents any flickering of the tab title.
235 content::NavigationEntry* entry =
236 web_contents_->GetController().GetPendingEntry();
237 if (entry) {
238 web_contents_->UpdateTitleForEntry(
239 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
240 }
241 }
242 }
243
219 void SearchTabHelper::DidStartNavigation( 244 void SearchTabHelper::DidStartNavigation(
220 content::NavigationHandle* navigation_handle) { 245 content::NavigationHandle* navigation_handle) {
246 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)
247 return;
248
221 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) 249 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage())
222 return; 250 return;
223 251
224 if (search::IsNTPURL(navigation_handle->GetURL(), profile())) { 252 if (search::IsNTPURL(navigation_handle->GetURL(), profile())) {
225 // Set the title on any pending entry corresponding to the NTP. This 253 // Set the title on any pending entry corresponding to the NTP. This
226 // prevents any flickering of the tab title. 254 // prevents any flickering of the tab title.
227 content::NavigationEntry* entry = 255 content::NavigationEntry* entry =
228 web_contents_->GetController().GetPendingEntry(); 256 web_contents_->GetController().GetPendingEntry();
229 if (entry) { 257 if (entry) {
230 web_contents_->UpdateTitleForEntry( 258 web_contents_->UpdateTitleForEntry(
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 534
507 bool SearchTabHelper::IsInputInProgress() const { 535 bool SearchTabHelper::IsInputInProgress() const {
508 OmniboxView* omnibox = GetOmniboxView(); 536 OmniboxView* omnibox = GetOmniboxView();
509 return !model_.mode().is_ntp() && omnibox && 537 return !model_.mode().is_ntp() && omnibox &&
510 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; 538 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE;
511 } 539 }
512 540
513 OmniboxView* SearchTabHelper::GetOmniboxView() const { 541 OmniboxView* SearchTabHelper::GetOmniboxView() const {
514 return delegate_ ? delegate_->GetOmniboxView() : NULL; 542 return delegate_ ? delegate_->GetOmniboxView() : NULL;
515 } 543 }
OLDNEW
« 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