Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: components/search_engines/desktop_search_win.cc

Issue 1477783004: Add a preference to control Windows desktop search redirection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Declare feature in header file. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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";
22 } // namespace
23
24 const base::Feature kWindowsDesktopSearchRedirectionFeature = {
Peter Kasting 2015/12/01 02:23:05 Nit: If you remove the .h declaration, you can dec
fdoray 2015/12/02 17:28:27 See other comment. It needs to be declared in the
25 "WindowsDesktopSearchRedirection", base::FEATURE_DISABLED_BY_DEFAULT
26 };
27
28 void RegisterWindowsDesktopSearchRedirectionPref(
29 user_prefs::PrefRegistrySyncable* registry) {
30 registry->RegisterBooleanPref(kWindowsDesktopSearchRedirectionPref, false);
31 }
32
33 WindowsDesktopSearchRedirectionPref GetWindowsDesktopSearchRedirectionPref(
34 PrefService* pref_service) {
35 const PrefService::Preference* preference =
36 pref_service->FindPreference(kWindowsDesktopSearchRedirectionPref);
37 DCHECK(preference);
38 if (preference->IsDefaultValue())
39 return WindowsDesktopSearchRedirectionPref::UNSET;
40
41 bool pref_value = false;
42 const bool has_boolean_value =
43 preference->GetValue()->GetAsBoolean(&pref_value);
44 DCHECK(has_boolean_value);
45
46 if (pref_value)
47 return WindowsDesktopSearchRedirectionPref::ENABLED;
48 return WindowsDesktopSearchRedirectionPref::DISABLED;
Peter Kasting 2015/12/01 02:23:05 Nit: Simpler: return pref_value ? WindowsDeskto
fdoray 2015/12/02 17:28:27 This code is gone now.
49 }
50
51 bool WindowsDesktopSearchRedirectionFeatureIsEnabled() {
52 return base::FeatureList::IsEnabled(kWindowsDesktopSearchRedirectionFeature);
53 }
54
16 bool DetectWindowsDesktopSearch(const GURL& url, 55 bool DetectWindowsDesktopSearch(const GURL& url,
17 const SearchTermsData& search_terms_data, 56 const SearchTermsData& search_terms_data,
18 base::string16* search_terms) { 57 base::string16* search_terms) {
19 DCHECK(search_terms); 58 DCHECK(search_terms);
20 59
21 scoped_ptr<TemplateURLData> template_url_data = 60 scoped_ptr<TemplateURLData> template_url_data =
22 TemplateURLPrepopulateData::MakeTemplateURLDataFromPrepopulatedEngine( 61 TemplateURLPrepopulateData::MakeTemplateURLDataFromPrepopulatedEngine(
23 TemplateURLPrepopulateData::bing); 62 TemplateURLPrepopulateData::bing);
24 TemplateURL template_url(*template_url_data); 63 TemplateURL template_url(*template_url_data);
25 64
(...skipping 13 matching lines...) Expand all
39 if (base::EqualsCaseInsensitiveASCII(it.GetKey(), kBingSourceQueryKey)) { 78 if (base::EqualsCaseInsensitiveASCII(it.GetKey(), kBingSourceQueryKey)) {
40 std::string source = it.GetValue(); 79 std::string source = it.GetValue();
41 if (source == kBingSourceDesktopText || source == kBingSourceDesktopVoice) 80 if (source == kBingSourceDesktopText || source == kBingSourceDesktopVoice)
42 return true; 81 return true;
43 } 82 }
44 } 83 }
45 84
46 search_terms->clear(); 85 search_terms->clear();
47 return false; 86 return false;
48 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698