OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/contextual_search_policy_handler_android.h" | 5 #include "chrome/browser/search/contextual_search_policy_handler_android.h" |
6 | 6 |
7 #include "base/prefs/pref_value_map.h" | |
8 #include "base/values.h" | 7 #include "base/values.h" |
9 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
10 #include "components/policy/core/common/policy_map.h" | 9 #include "components/policy/core/common/policy_map.h" |
| 10 #include "components/prefs/pref_value_map.h" |
11 #include "policy/policy_constants.h" | 11 #include "policy/policy_constants.h" |
12 | 12 |
13 namespace policy { | 13 namespace policy { |
14 | 14 |
15 ContextualSearchPolicyHandlerAndroid::ContextualSearchPolicyHandlerAndroid() | 15 ContextualSearchPolicyHandlerAndroid::ContextualSearchPolicyHandlerAndroid() |
16 : TypeCheckingPolicyHandler(key::kContextualSearchEnabled, | 16 : TypeCheckingPolicyHandler(key::kContextualSearchEnabled, |
17 base::Value::TYPE_BOOLEAN) {} | 17 base::Value::TYPE_BOOLEAN) {} |
18 | 18 |
19 ContextualSearchPolicyHandlerAndroid::~ContextualSearchPolicyHandlerAndroid() { | 19 ContextualSearchPolicyHandlerAndroid::~ContextualSearchPolicyHandlerAndroid() { |
20 } | 20 } |
21 | 21 |
22 void ContextualSearchPolicyHandlerAndroid::ApplyPolicySettings( | 22 void ContextualSearchPolicyHandlerAndroid::ApplyPolicySettings( |
23 const PolicyMap& policies, | 23 const PolicyMap& policies, |
24 PrefValueMap* prefs) { | 24 PrefValueMap* prefs) { |
25 const base::Value* value = policies.GetValue(policy_name()); | 25 const base::Value* value = policies.GetValue(policy_name()); |
26 bool contextual_search_enabled = true; | 26 bool contextual_search_enabled = true; |
27 // From a Contextual Search preference point of view, "false" means the | 27 // From a Contextual Search preference point of view, "false" means the |
28 // feature is turned off completely. "" means the feature is uninitialized and | 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 | 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 | 30 // either "true" or "false", depending on their choice. Here a false policy |
31 // explicitly disables Contextual Search. | 31 // explicitly disables Contextual Search. |
32 if (value && | 32 if (value && |
33 value->GetAsBoolean(&contextual_search_enabled) && | 33 value->GetAsBoolean(&contextual_search_enabled) && |
34 !contextual_search_enabled) { | 34 !contextual_search_enabled) { |
35 prefs->SetString(prefs::kContextualSearchEnabled, "false"); | 35 prefs->SetString(prefs::kContextualSearchEnabled, "false"); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 } // namespace policy | 39 } // namespace policy |
OLD | NEW |