| 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/search/search.h" | 5 #include "chrome/browser/search/search.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/search/instant_service.h" | 19 #include "chrome/browser/search/instant_service.h" |
| 20 #include "chrome/browser/search/instant_service_factory.h" | 20 #include "chrome/browser/search/instant_service_factory.h" |
| 21 #include "chrome/browser/search_engines/template_url_service_factory.h" | 21 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 22 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 22 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_instant_controller.h" | 24 #include "chrome/browser/ui/browser_instant_controller.h" |
| 25 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 25 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 26 #include "chrome/common/chrome_features.h" |
| 26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/features.h" | 28 #include "chrome/common/features.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/search/search_urls.h" | 30 #include "chrome/common/search/search_urls.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 31 #include "components/google/core/browser/google_util.h" | 32 #include "components/google/core/browser/google_util.h" |
| 32 #include "components/pref_registry/pref_registry_syncable.h" | 33 #include "components/pref_registry/pref_registry_syncable.h" |
| 33 #include "components/prefs/pref_service.h" | 34 #include "components/prefs/pref_service.h" |
| 34 #include "components/search/search.h" | 35 #include "components/search/search.h" |
| 35 #include "components/search_engines/search_engine_type.h" | 36 #include "components/search_engines/search_engine_type.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // URL should not be used because Suggest is disabled. | 75 // URL should not be used because Suggest is disabled. |
| 75 // Not used anymore, see crbug.com/340424. | 76 // Not used anymore, see crbug.com/340424. |
| 76 // NEW_TAB_URL_SUGGEST_OFF = 5, | 77 // NEW_TAB_URL_SUGGEST_OFF = 5, |
| 77 | 78 |
| 78 // URL should not be used because it is blocked for a supervised user. | 79 // URL should not be used because it is blocked for a supervised user. |
| 79 NEW_TAB_URL_BLOCKED = 6, | 80 NEW_TAB_URL_BLOCKED = 6, |
| 80 | 81 |
| 81 NEW_TAB_URL_MAX | 82 NEW_TAB_URL_MAX |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 base::Feature kUseGoogleLocalNtp { | |
| 85 "UseGoogleLocalNtp", base::FEATURE_DISABLED_BY_DEFAULT | |
| 86 }; | |
| 87 | |
| 88 const TemplateURL* GetDefaultSearchProviderTemplateURL(Profile* profile) { | 85 const TemplateURL* GetDefaultSearchProviderTemplateURL(Profile* profile) { |
| 89 if (profile) { | 86 if (profile) { |
| 90 TemplateURLService* template_url_service = | 87 TemplateURLService* template_url_service = |
| 91 TemplateURLServiceFactory::GetForProfile(profile); | 88 TemplateURLServiceFactory::GetForProfile(profile); |
| 92 if (template_url_service) | 89 if (template_url_service) |
| 93 return template_url_service->GetDefaultSearchProvider(); | 90 return template_url_service->GetDefaultSearchProvider(); |
| 94 } | 91 } |
| 95 return NULL; | 92 return NULL; |
| 96 } | 93 } |
| 97 | 94 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // On Chrome OS, if the session hasn't merged yet, we need to avoid loading | 188 // On Chrome OS, if the session hasn't merged yet, we need to avoid loading |
| 192 // the remote NTP because that will trigger showing the merge session throttle | 189 // the remote NTP because that will trigger showing the merge session throttle |
| 193 // interstitial page, which can show for 5+ seconds. crbug.com/591530. | 190 // interstitial page, which can show for 5+ seconds. crbug.com/591530. |
| 194 if (merge_session_throttling_utils::ShouldDelayUrl(url) && | 191 if (merge_session_throttling_utils::ShouldDelayUrl(url) && |
| 195 merge_session_throttling_utils::IsSessionRestorePending(profile)) { | 192 merge_session_throttling_utils::IsSessionRestorePending(profile)) { |
| 196 return true; | 193 return true; |
| 197 } | 194 } |
| 198 #endif // defined(OS_CHROMEOS) | 195 #endif // defined(OS_CHROMEOS) |
| 199 | 196 |
| 200 if (!profile->IsOffTheRecord() && | 197 if (!profile->IsOffTheRecord() && |
| 201 base::FeatureList::IsEnabled(kUseGoogleLocalNtp) && | 198 base::FeatureList::IsEnabled(features::kUseGoogleLocalNtp) && |
| 202 DefaultSearchProviderIsGoogle(profile)) { | 199 DefaultSearchProviderIsGoogle(profile)) { |
| 203 return true; | 200 return true; |
| 204 } | 201 } |
| 205 | 202 |
| 206 return false; | 203 return false; |
| 207 } | 204 } |
| 208 | 205 |
| 209 // Used to look up the URL to use for the New Tab page. Also tracks how we | 206 // Used to look up the URL to use for the New Tab page. Also tracks how we |
| 210 // arrived at that URL so it can be logged with UMA. | 207 // arrived at that URL so it can be logged with UMA. |
| 211 struct NewTabURLDetails { | 208 struct NewTabURLDetails { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 460 |
| 464 if (IsInstantNTPURL(*url, profile)) { | 461 if (IsInstantNTPURL(*url, profile)) { |
| 465 *url = GURL(chrome::kChromeUINewTabURL); | 462 *url = GURL(chrome::kChromeUINewTabURL); |
| 466 return true; | 463 return true; |
| 467 } | 464 } |
| 468 | 465 |
| 469 return false; | 466 return false; |
| 470 } | 467 } |
| 471 | 468 |
| 472 } // namespace search | 469 } // namespace search |
| OLD | NEW |