Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/search_engines/detect_desktop_search_win.h" | 5 #include "components/search_engines/desktop_search_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "components/pref_registry/pref_registry_syncable.h" | |
| 11 #include "components/search_engines/prepopulated_engines.h" | 13 #include "components/search_engines/prepopulated_engines.h" |
| 12 #include "components/search_engines/template_url.h" | 14 #include "components/search_engines/template_url.h" |
| 13 #include "components/search_engines/template_url_prepopulate_data.h" | 15 #include "components/search_engines/template_url_prepopulate_data.h" |
| 14 #include "net/base/url_util.h" | 16 #include "net/base/url_util.h" |
| 15 | 17 |
| 18 namespace { | |
| 19 // Name of the Windows desktop search redirection preference. | |
| 20 const char kWindowsDesktopSearchRedirectionPref[] = | |
| 21 "windows_desktop_search_redirection"; | |
|
Peter Kasting
2015/12/03 05:41:39
Multiple test files also want to use this pref nam
fdoray
2015/12/03 17:16:17
Done.
| |
| 22 } // namespace | |
| 23 | |
| 24 const base::Feature kWindowsDesktopSearchRedirectionFeature = { | |
| 25 "WindowsDesktopSearchRedirection", base::FEATURE_DISABLED_BY_DEFAULT}; | |
|
Peter Kasting
2015/12/03 05:41:39
Nit: I'd wrap the final "};" to the next line.
fdoray
2015/12/03 17:16:18
Done.
| |
| 26 | |
| 27 void RegisterWindowsDesktopSearchRedirectionPref( | |
| 28 user_prefs::PrefRegistrySyncable* registry) { | |
| 29 registry->RegisterBooleanPref(kWindowsDesktopSearchRedirectionPref, false); | |
| 30 } | |
| 31 | |
| 32 bool ShouldRedirectWindowsDesktopSearchToDefaultSearchEngine( | |
| 33 PrefService* pref_service) { | |
| 34 DCHECK(pref_service); | |
| 35 | |
| 36 if (!base::FeatureList::IsEnabled(kWindowsDesktopSearchRedirectionFeature)) | |
| 37 return false; | |
| 38 return pref_service->GetBoolean(kWindowsDesktopSearchRedirectionPref); | |
|
Peter Kasting
2015/12/03 05:41:39
Nit: Simpler:
return base::FeatureList::IsEnabl
fdoray
2015/12/03 17:16:17
Done.
| |
| 39 } | |
| 40 | |
| 16 bool DetectWindowsDesktopSearch(const GURL& url, | 41 bool DetectWindowsDesktopSearch(const GURL& url, |
| 17 const SearchTermsData& search_terms_data, | 42 const SearchTermsData& search_terms_data, |
| 18 base::string16* search_terms) { | 43 base::string16* search_terms) { |
| 19 DCHECK(search_terms); | 44 DCHECK(search_terms); |
| 20 | 45 |
| 21 scoped_ptr<TemplateURLData> template_url_data = | 46 scoped_ptr<TemplateURLData> template_url_data = |
| 22 TemplateURLPrepopulateData::MakeTemplateURLDataFromPrepopulatedEngine( | 47 TemplateURLPrepopulateData::MakeTemplateURLDataFromPrepopulatedEngine( |
| 23 TemplateURLPrepopulateData::bing); | 48 TemplateURLPrepopulateData::bing); |
| 24 TemplateURL template_url(*template_url_data); | 49 TemplateURL template_url(*template_url_data); |
| 25 | 50 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 39 if (base::EqualsCaseInsensitiveASCII(it.GetKey(), kBingSourceQueryKey)) { | 64 if (base::EqualsCaseInsensitiveASCII(it.GetKey(), kBingSourceQueryKey)) { |
| 40 std::string source = it.GetValue(); | 65 std::string source = it.GetValue(); |
| 41 if (source == kBingSourceDesktopText || source == kBingSourceDesktopVoice) | 66 if (source == kBingSourceDesktopText || source == kBingSourceDesktopVoice) |
| 42 return true; | 67 return true; |
| 43 } | 68 } |
| 44 } | 69 } |
| 45 | 70 |
| 46 search_terms->clear(); | 71 search_terms->clear(); |
| 47 return false; | 72 return false; |
| 48 } | 73 } |
| OLD | NEW |