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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 239 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 void SearchTabHelper::DidStartNavigation( | 244 void SearchTabHelper::DidStartNavigation( |
245 content::NavigationHandle* navigation_handle) { | 245 content::NavigationHandle* navigation_handle) { |
246 if (!content::IsBrowserSideNavigationEnabled()) | 246 if (!content::IsBrowserSideNavigationEnabled()) |
247 return; | 247 return; |
248 | 248 |
249 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) | 249 if (!navigation_handle->IsInMainFrame() || |
| 250 navigation_handle->IsSameDocument()) { |
250 return; | 251 return; |
| 252 } |
251 | 253 |
252 if (search::IsNTPURL(navigation_handle->GetURL(), profile())) { | 254 if (search::IsNTPURL(navigation_handle->GetURL(), profile())) { |
253 // Set the title on any pending entry corresponding to the NTP. This | 255 // Set the title on any pending entry corresponding to the NTP. This |
254 // prevents any flickering of the tab title. | 256 // prevents any flickering of the tab title. |
255 content::NavigationEntry* entry = | 257 content::NavigationEntry* entry = |
256 web_contents_->GetController().GetPendingEntry(); | 258 web_contents_->GetController().GetPendingEntry(); |
257 if (entry) { | 259 if (entry) { |
258 web_contents_->UpdateTitleForEntry( | 260 web_contents_->UpdateTitleForEntry( |
259 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 261 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
260 } | 262 } |
261 } | 263 } |
262 } | 264 } |
263 | 265 |
264 void SearchTabHelper::DidFinishNavigation( | 266 void SearchTabHelper::DidFinishNavigation( |
265 content::NavigationHandle* navigation_handle) { | 267 content::NavigationHandle* navigation_handle) { |
266 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) | 268 if (!navigation_handle->IsInMainFrame() || |
| 269 navigation_handle->IsSameDocument()) |
267 return; | 270 return; |
268 | 271 |
269 if (IsCacheableNTP(web_contents_)) { | 272 if (IsCacheableNTP(web_contents_)) { |
270 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", | 273 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", |
271 search::CACHEABLE_NTP_LOAD_SUCCEEDED, | 274 search::CACHEABLE_NTP_LOAD_SUCCEEDED, |
272 search::CACHEABLE_NTP_LOAD_MAX); | 275 search::CACHEABLE_NTP_LOAD_MAX); |
273 } | 276 } |
274 | 277 |
275 // Always set the title on the new tab page to be the one from our UI | 278 // Always set the title on the new tab page to be the one from our UI |
276 // resources. Normally, we set the title when we begin a NTP load, but it can | 279 // resources. Normally, we set the title when we begin a NTP load, but it can |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 537 |
535 bool SearchTabHelper::IsInputInProgress() const { | 538 bool SearchTabHelper::IsInputInProgress() const { |
536 OmniboxView* omnibox = GetOmniboxView(); | 539 OmniboxView* omnibox = GetOmniboxView(); |
537 return !model_.mode().is_ntp() && omnibox && | 540 return !model_.mode().is_ntp() && omnibox && |
538 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 541 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
539 } | 542 } |
540 | 543 |
541 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 544 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
542 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 545 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
543 } | 546 } |
OLD | NEW |