| 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 20 matching lines...) Expand all Loading... |
| 31 #include "components/browser_sync/profile_sync_service.h" | 31 #include "components/browser_sync/profile_sync_service.h" |
| 32 #include "components/google/core/browser/google_util.h" | 32 #include "components/google/core/browser/google_util.h" |
| 33 #include "components/omnibox/browser/omnibox_edit_model.h" | 33 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 34 #include "components/omnibox/browser/omnibox_popup_model.h" | 34 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 35 #include "components/omnibox/browser/omnibox_view.h" | 35 #include "components/omnibox/browser/omnibox_view.h" |
| 36 #include "components/search/search.h" | 36 #include "components/search/search.h" |
| 37 #include "components/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" |
| 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/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 42 #include "content/public/browser/notification_source.h" | 43 #include "content/public/browser/notification_source.h" |
| 43 #include "content/public/browser/render_frame_host.h" | 44 #include "content/public/browser/render_frame_host.h" |
| 44 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
| 45 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
| 46 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
| 47 #include "content/public/common/referrer.h" | 48 #include "content/public/common/referrer.h" |
| 48 #include "google_apis/gaia/gaia_auth_util.h" | 49 #include "google_apis/gaia/gaia_auth_util.h" |
| 49 #include "net/base/net_errors.h" | 50 #include "net/base/net_errors.h" |
| 50 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // startup or from the user opening a new tab, and if we wait until later, | 209 // startup or from the user opening a new tab, and if we wait until later, |
| 209 // it won't correctly detect this case. | 210 // it won't correctly detect this case. |
| 210 NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_); | 211 NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_); |
| 211 } | 212 } |
| 212 } | 213 } |
| 213 | 214 |
| 214 void SearchTabHelper::OnTabDeactivated() { | 215 void SearchTabHelper::OnTabDeactivated() { |
| 215 ipc_router_.OnTabDeactivated(); | 216 ipc_router_.OnTabDeactivated(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 void SearchTabHelper::DidStartNavigationToPendingEntry( | 219 void SearchTabHelper::DidStartNavigation( |
| 219 const GURL& url, | 220 content::NavigationHandle* navigation_handle) { |
| 220 content::ReloadType /* reload_type */) { | 221 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) |
| 221 if (search::IsNTPURL(url, profile())) { | 222 return; |
| 223 |
| 224 if (search::IsNTPURL(navigation_handle->GetURL(), profile())) { |
| 222 // Set the title on any pending entry corresponding to the NTP. This | 225 // Set the title on any pending entry corresponding to the NTP. This |
| 223 // prevents any flickering of the tab title. | 226 // prevents any flickering of the tab title. |
| 224 content::NavigationEntry* entry = | 227 content::NavigationEntry* entry = |
| 225 web_contents_->GetController().GetPendingEntry(); | 228 web_contents_->GetController().GetPendingEntry(); |
| 226 if (entry) { | 229 if (entry) { |
| 227 web_contents_->UpdateTitleForEntry( | 230 web_contents_->UpdateTitleForEntry( |
| 228 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 231 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 229 } | 232 } |
| 230 } | 233 } |
| 231 } | 234 } |
| 232 | 235 |
| 233 void SearchTabHelper::DidNavigateMainFrame( | 236 void SearchTabHelper::DidFinishNavigation( |
| 234 const content::LoadCommittedDetails& details, | 237 content::NavigationHandle* navigation_handle) { |
| 235 const content::FrameNavigateParams& params) { | 238 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) |
| 239 return; |
| 240 |
| 236 if (IsCacheableNTP(web_contents_)) { | 241 if (IsCacheableNTP(web_contents_)) { |
| 237 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", | 242 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", |
| 238 search::CACHEABLE_NTP_LOAD_SUCCEEDED, | 243 search::CACHEABLE_NTP_LOAD_SUCCEEDED, |
| 239 search::CACHEABLE_NTP_LOAD_MAX); | 244 search::CACHEABLE_NTP_LOAD_MAX); |
| 240 } | 245 } |
| 241 | 246 |
| 242 // Always set the title on the new tab page to be the one from our UI | 247 // Always set the title on the new tab page to be the one from our UI |
| 243 // resources. Normally, we set the title when we begin a NTP load, but it can | 248 // resources. Normally, we set the title when we begin a NTP load, but it can |
| 244 // get reset in several places (like when you press Reload). This check | 249 // get reset in several places (like when you press Reload). This check |
| 245 // ensures that the title is properly set to the string defined by the Chrome | 250 // ensures that the title is properly set to the string defined by the Chrome |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 506 |
| 502 bool SearchTabHelper::IsInputInProgress() const { | 507 bool SearchTabHelper::IsInputInProgress() const { |
| 503 OmniboxView* omnibox = GetOmniboxView(); | 508 OmniboxView* omnibox = GetOmniboxView(); |
| 504 return !model_.mode().is_ntp() && omnibox && | 509 return !model_.mode().is_ntp() && omnibox && |
| 505 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 510 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 506 } | 511 } |
| 507 | 512 |
| 508 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 513 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 509 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 514 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 510 } | 515 } |
| OLD | NEW |