Index: components/search_engines/desktop_search_win.cc |
diff --git a/components/search_engines/detect_desktop_search_win.cc b/components/search_engines/desktop_search_win.cc |
similarity index 55% |
rename from components/search_engines/detect_desktop_search_win.cc |
rename to components/search_engines/desktop_search_win.cc |
index 563e80de7f16d668065bbfb24ea25e68aef1cadf..16d7f92ee6aefdf000a1e9807cab085261c86271 100644 |
--- a/components/search_engines/detect_desktop_search_win.cc |
+++ b/components/search_engines/desktop_search_win.cc |
@@ -2,17 +2,56 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/search_engines/detect_desktop_search_win.h" |
+#include "components/search_engines/desktop_search_win.h" |
#include <string> |
#include "base/memory/scoped_ptr.h" |
+#include "base/prefs/pref_service.h" |
#include "base/strings/string_util.h" |
+#include "components/pref_registry/pref_registry_syncable.h" |
#include "components/search_engines/prepopulated_engines.h" |
#include "components/search_engines/template_url.h" |
#include "components/search_engines/template_url_prepopulate_data.h" |
#include "net/base/url_util.h" |
+namespace { |
+// Name of the Windows desktop search redirection preference. |
+const char kWindowsDesktopSearchRedirectionPref[] = |
+ "windows_desktop_search_redirection"; |
+} // namespace |
+ |
+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
|
+ "WindowsDesktopSearchRedirection", base::FEATURE_DISABLED_BY_DEFAULT |
+}; |
+ |
+void RegisterWindowsDesktopSearchRedirectionPref( |
+ user_prefs::PrefRegistrySyncable* registry) { |
+ registry->RegisterBooleanPref(kWindowsDesktopSearchRedirectionPref, false); |
+} |
+ |
+WindowsDesktopSearchRedirectionPref GetWindowsDesktopSearchRedirectionPref( |
+ PrefService* pref_service) { |
+ const PrefService::Preference* preference = |
+ pref_service->FindPreference(kWindowsDesktopSearchRedirectionPref); |
+ DCHECK(preference); |
+ if (preference->IsDefaultValue()) |
+ return WindowsDesktopSearchRedirectionPref::UNSET; |
+ |
+ bool pref_value = false; |
+ const bool has_boolean_value = |
+ preference->GetValue()->GetAsBoolean(&pref_value); |
+ DCHECK(has_boolean_value); |
+ |
+ if (pref_value) |
+ return WindowsDesktopSearchRedirectionPref::ENABLED; |
+ 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.
|
+} |
+ |
+bool WindowsDesktopSearchRedirectionFeatureIsEnabled() { |
+ return base::FeatureList::IsEnabled(kWindowsDesktopSearchRedirectionFeature); |
+} |
+ |
bool DetectWindowsDesktopSearch(const GURL& url, |
const SearchTermsData& search_terms_data, |
base::string16* search_terms) { |