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

Side by Side Diff: components/policy/core/browser/configuration_policy_handler.cc

Issue 108603005: Update uses of Value in chromeos/, cloud_print/, components/, content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy/core/browser/configuration_policy_handler.h" 5 #include "components/policy/core/browser/configuration_policy_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/prefs/pref_value_map.h" 12 #include "base/prefs/pref_value_map.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "components/policy/core/browser/configuration_policy_pref_store.h" 16 #include "components/policy/core/browser/configuration_policy_pref_store.h"
17 #include "components/policy/core/browser/policy_error_map.h" 17 #include "components/policy/core/browser/policy_error_map.h"
18 #include "components/policy/core/common/policy_map.h" 18 #include "components/policy/core/common/policy_map.h"
19 #include "grit/component_strings.h" 19 #include "grit/component_strings.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 namespace policy { 22 namespace policy {
23 23
24 // ConfigurationPolicyHandler implementation ----------------------------------- 24 // ConfigurationPolicyHandler implementation -----------------------------------
25 25
26 // static 26 // static
27 std::string ConfigurationPolicyHandler::ValueTypeToString(Value::Type type) { 27 std::string ConfigurationPolicyHandler::ValueTypeToString(
28 base::Value::Type type) {
28 static const char* strings[] = { 29 static const char* strings[] = {
29 "null", 30 "null",
30 "boolean", 31 "boolean",
31 "integer", 32 "integer",
32 "double", 33 "double",
33 "string", 34 "string",
34 "binary", 35 "binary",
35 "dictionary", 36 "dictionary",
36 "list" 37 "list"
37 }; 38 };
38 CHECK(static_cast<size_t>(type) < arraysize(strings)); 39 CHECK(static_cast<size_t>(type) < arraysize(strings));
39 return std::string(strings[type]); 40 return std::string(strings[type]);
40 } 41 }
41 42
42 ConfigurationPolicyHandler::ConfigurationPolicyHandler() { 43 ConfigurationPolicyHandler::ConfigurationPolicyHandler() {
43 } 44 }
44 45
45 ConfigurationPolicyHandler::~ConfigurationPolicyHandler() { 46 ConfigurationPolicyHandler::~ConfigurationPolicyHandler() {
46 } 47 }
47 48
48 void ConfigurationPolicyHandler::PrepareForDisplaying( 49 void ConfigurationPolicyHandler::PrepareForDisplaying(
49 PolicyMap* policies) const {} 50 PolicyMap* policies) const {}
50 51
51 52
52 // TypeCheckingPolicyHandler implementation ------------------------------------ 53 // TypeCheckingPolicyHandler implementation ------------------------------------
53 54
54 TypeCheckingPolicyHandler::TypeCheckingPolicyHandler( 55 TypeCheckingPolicyHandler::TypeCheckingPolicyHandler(
55 const char* policy_name, 56 const char* policy_name,
56 Value::Type value_type) 57 base::Value::Type value_type)
57 : policy_name_(policy_name), 58 : policy_name_(policy_name),
58 value_type_(value_type) { 59 value_type_(value_type) {
59 } 60 }
60 61
61 TypeCheckingPolicyHandler::~TypeCheckingPolicyHandler() { 62 TypeCheckingPolicyHandler::~TypeCheckingPolicyHandler() {
62 } 63 }
63 64
64 const char* TypeCheckingPolicyHandler::policy_name() const { 65 const char* TypeCheckingPolicyHandler::policy_name() const {
65 return policy_name_; 66 return policy_name_;
66 } 67 }
67 68
68 bool TypeCheckingPolicyHandler::CheckPolicySettings(const PolicyMap& policies, 69 bool TypeCheckingPolicyHandler::CheckPolicySettings(const PolicyMap& policies,
69 PolicyErrorMap* errors) { 70 PolicyErrorMap* errors) {
70 const Value* value = NULL; 71 const base::Value* value = NULL;
71 return CheckAndGetValue(policies, errors, &value); 72 return CheckAndGetValue(policies, errors, &value);
72 } 73 }
73 74
74 bool TypeCheckingPolicyHandler::CheckAndGetValue(const PolicyMap& policies, 75 bool TypeCheckingPolicyHandler::CheckAndGetValue(const PolicyMap& policies,
75 PolicyErrorMap* errors, 76 PolicyErrorMap* errors,
76 const Value** value) { 77 const base::Value** value) {
77 *value = policies.GetValue(policy_name_); 78 *value = policies.GetValue(policy_name_);
78 if (*value && !(*value)->IsType(value_type_)) { 79 if (*value && !(*value)->IsType(value_type_)) {
79 errors->AddError(policy_name_, 80 errors->AddError(policy_name_,
80 IDS_POLICY_TYPE_ERROR, 81 IDS_POLICY_TYPE_ERROR,
81 ValueTypeToString(value_type_)); 82 ValueTypeToString(value_type_));
82 return false; 83 return false;
83 } 84 }
84 return true; 85 return true;
85 } 86 }
86 87
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 static_cast<double>(percentage) / 100.)); 272 static_cast<double>(percentage) / 100.));
272 } 273 }
273 } 274 }
274 275
275 276
276 // SimplePolicyHandler implementation ------------------------------------------ 277 // SimplePolicyHandler implementation ------------------------------------------
277 278
278 SimplePolicyHandler::SimplePolicyHandler( 279 SimplePolicyHandler::SimplePolicyHandler(
279 const char* policy_name, 280 const char* policy_name,
280 const char* pref_path, 281 const char* pref_path,
281 Value::Type value_type) 282 base::Value::Type value_type)
282 : TypeCheckingPolicyHandler(policy_name, value_type), 283 : TypeCheckingPolicyHandler(policy_name, value_type),
283 pref_path_(pref_path) { 284 pref_path_(pref_path) {
284 } 285 }
285 286
286 SimplePolicyHandler::~SimplePolicyHandler() { 287 SimplePolicyHandler::~SimplePolicyHandler() {
287 } 288 }
288 289
289 void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, 290 void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
290 PrefValueMap* prefs) { 291 PrefValueMap* prefs) {
291 if (!pref_path_) 292 if (!pref_path_)
292 return; 293 return;
293 const Value* value = policies.GetValue(policy_name()); 294 const base::Value* value = policies.GetValue(policy_name());
294 if (value) 295 if (value)
295 prefs->SetValue(pref_path_, value->DeepCopy()); 296 prefs->SetValue(pref_path_, value->DeepCopy());
296 } 297 }
297 298
298 } // namespace policy 299 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698