1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/search/contextual_search_policy_handler_android.h"
7 #include "base/prefs/pref_value_map.h"
8 #include "base/values.h"
9 #include "chrome/common/pref_names.h"
10 #include "components/policy/core/common/policy_map.h"
11 #include "policy/policy_constants.h"
15 ContextualSearchPolicyHandlerAndroid::ContextualSearchPolicyHandlerAndroid()
16 : TypeCheckingPolicyHandler(key::kContextualSearchEnabled
,
17 base::Value::TYPE_BOOLEAN
) {}
19 ContextualSearchPolicyHandlerAndroid::~ContextualSearchPolicyHandlerAndroid() {
22 void ContextualSearchPolicyHandlerAndroid::ApplyPolicySettings(
23 const PolicyMap
& policies
,
24 PrefValueMap
* prefs
) {
25 const base::Value
* value
= policies
.GetValue(policy_name());
26 bool contextual_search_enabled
= true;
27 // From a Contextual Search preference point of view, "false" means the
28 // feature is turned off completely. "" means the feature is uninitialized and
29 // an opt-in screen is presented to the user, after which the preference is
30 // either "true" or "false", depending on their choice. Here a false policy
31 // explicitly disables Contextual Search.
33 value
->GetAsBoolean(&contextual_search_enabled
) &&
34 !contextual_search_enabled
) {
35 prefs
->SetString(prefs::kContextualSearchEnabled
, "false");