OLD | NEW |
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/macros.h" | 10 #include "base/macros.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 | 285 |
286 void SearchTabHelper::DidStartNavigationToPendingEntry( | 286 void SearchTabHelper::DidStartNavigationToPendingEntry( |
287 const GURL& url, | 287 const GURL& url, |
288 content::NavigationController::ReloadType /* reload_type */) { | 288 content::NavigationController::ReloadType /* reload_type */) { |
289 if (search::IsNTPURL(url, profile())) { | 289 if (search::IsNTPURL(url, profile())) { |
290 // Set the title on any pending entry corresponding to the NTP. This | 290 // Set the title on any pending entry corresponding to the NTP. This |
291 // prevents any flickering of the tab title. | 291 // prevents any flickering of the tab title. |
292 content::NavigationEntry* entry = | 292 content::NavigationEntry* entry = |
293 web_contents_->GetController().GetPendingEntry(); | 293 web_contents_->GetController().GetPendingEntry(); |
294 if (entry) | 294 if (entry) { |
295 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 295 web_contents_->UpdateTitleForEntry( |
| 296 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 297 } |
296 } | 298 } |
297 } | 299 } |
298 | 300 |
299 void SearchTabHelper::DidNavigateMainFrame( | 301 void SearchTabHelper::DidNavigateMainFrame( |
300 const content::LoadCommittedDetails& details, | 302 const content::LoadCommittedDetails& details, |
301 const content::FrameNavigateParams& params) { | 303 const content::FrameNavigateParams& params) { |
302 if (IsCacheableNTP(web_contents_)) { | 304 if (IsCacheableNTP(web_contents_)) { |
303 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", | 305 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", |
304 search::CACHEABLE_NTP_LOAD_SUCCEEDED, | 306 search::CACHEABLE_NTP_LOAD_SUCCEEDED, |
305 search::CACHEABLE_NTP_LOAD_MAX); | 307 search::CACHEABLE_NTP_LOAD_MAX); |
306 } | 308 } |
307 | 309 |
308 // Always set the title on the new tab page to be the one from our UI | 310 // Always set the title on the new tab page to be the one from our UI |
309 // resources. Normally, we set the title when we begin a NTP load, but it can | 311 // resources. Normally, we set the title when we begin a NTP load, but it can |
310 // get reset in several places (like when you press Reload). This check | 312 // get reset in several places (like when you press Reload). This check |
311 // ensures that the title is properly set to the string defined by the Chrome | 313 // ensures that the title is properly set to the string defined by the Chrome |
312 // UI language (rather than the server language) in all cases. | 314 // UI language (rather than the server language) in all cases. |
313 // | 315 // |
314 // We only override the title when it's nonempty to allow the page to set the | 316 // We only override the title when it's nonempty to allow the page to set the |
315 // title if it really wants. An empty title means to use the default. There's | 317 // title if it really wants. An empty title means to use the default. There's |
316 // also a race condition between this code and the page's SetTitle call which | 318 // also a race condition between this code and the page's SetTitle call which |
317 // this rule avoids. | 319 // this rule avoids. |
318 content::NavigationEntry* entry = | 320 content::NavigationEntry* entry = |
319 web_contents_->GetController().GetLastCommittedEntry(); | 321 web_contents_->GetController().GetLastCommittedEntry(); |
320 if (entry && entry->GetTitle().empty() && | 322 if (entry && entry->GetTitle().empty() && |
321 (entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL) || | 323 (entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL) || |
322 search::NavEntryIsInstantNTP(web_contents_, entry))) { | 324 search::NavEntryIsInstantNTP(web_contents_, entry))) { |
323 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 325 web_contents_->UpdateTitleForEntry( |
| 326 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
324 } | 327 } |
325 } | 328 } |
326 | 329 |
327 void SearchTabHelper::DidFinishLoad(content::RenderFrameHost* render_frame_host, | 330 void SearchTabHelper::DidFinishLoad(content::RenderFrameHost* render_frame_host, |
328 const GURL& /* validated_url */) { | 331 const GURL& /* validated_url */) { |
329 if (!render_frame_host->GetParent()) { | 332 if (!render_frame_host->GetParent()) { |
330 if (search::IsInstantNTP(web_contents_)) | 333 if (search::IsInstantNTP(web_contents_)) |
331 RecordNewTabLoadTime(web_contents_); | 334 RecordNewTabLoadTime(web_contents_); |
332 | 335 |
333 DetermineIfPageSupportsInstant(); | 336 DetermineIfPageSupportsInstant(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 | 563 |
561 bool SearchTabHelper::IsInputInProgress() const { | 564 bool SearchTabHelper::IsInputInProgress() const { |
562 OmniboxView* omnibox = GetOmniboxView(); | 565 OmniboxView* omnibox = GetOmniboxView(); |
563 return !model_.mode().is_ntp() && omnibox && | 566 return !model_.mode().is_ntp() && omnibox && |
564 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 567 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
565 } | 568 } |
566 | 569 |
567 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 570 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
568 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 571 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
569 } | 572 } |
OLD | NEW |