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

Side by Side Diff: chrome/browser/policy/user_policy_cache.cc

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/user_policy_cache.h" 5 #include "chrome/browser/policy/user_policy_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 Value* UserPolicyCache::DecodeIntegerValue( 168 Value* UserPolicyCache::DecodeIntegerValue(
169 google::protobuf::int64 value) const { 169 google::protobuf::int64 value) const {
170 if (value < std::numeric_limits<int>::min() || 170 if (value < std::numeric_limits<int>::min() ||
171 value > std::numeric_limits<int>::max()) { 171 value > std::numeric_limits<int>::max()) {
172 LOG(WARNING) << "Integer value " << value 172 LOG(WARNING) << "Integer value " << value
173 << " out of numeric limits, ignoring."; 173 << " out of numeric limits, ignoring.";
174 return NULL; 174 return NULL;
175 } 175 }
176 176
177 return Value::CreateIntegerValue(static_cast<int>(value)); 177 return base::NumberValue::New(static_cast<int>(value));
178 } 178 }
179 179
180 Value* UserPolicyCache::DecodeValue(const em::GenericValue& value) const { 180 Value* UserPolicyCache::DecodeValue(const em::GenericValue& value) const {
181 if (!value.has_value_type()) 181 if (!value.has_value_type())
182 return NULL; 182 return NULL;
183 183
184 switch (value.value_type()) { 184 switch (value.value_type()) {
185 case em::GenericValue::VALUE_TYPE_BOOL: 185 case em::GenericValue::VALUE_TYPE_BOOL:
186 if (value.has_bool_value()) 186 if (value.has_bool_value())
187 return Value::CreateBooleanValue(value.bool_value()); 187 return base::BooleanValue::New(value.bool_value());
188 return NULL; 188 return NULL;
189 case em::GenericValue::VALUE_TYPE_INT64: 189 case em::GenericValue::VALUE_TYPE_INT64:
190 if (value.has_int64_value()) 190 if (value.has_int64_value())
191 return DecodeIntegerValue(value.int64_value()); 191 return DecodeIntegerValue(value.int64_value());
192 return NULL; 192 return NULL;
193 case em::GenericValue::VALUE_TYPE_STRING: 193 case em::GenericValue::VALUE_TYPE_STRING:
194 if (value.has_string_value()) 194 if (value.has_string_value())
195 return Value::CreateStringValue(value.string_value()); 195 return base::StringValue::New(value.string_value());
196 return NULL; 196 return NULL;
197 case em::GenericValue::VALUE_TYPE_DOUBLE: 197 case em::GenericValue::VALUE_TYPE_DOUBLE:
198 if (value.has_double_value()) 198 if (value.has_double_value())
199 return Value::CreateDoubleValue(value.double_value()); 199 return base::NumberValue::New(value.double_value());
200 return NULL; 200 return NULL;
201 case em::GenericValue::VALUE_TYPE_BYTES: 201 case em::GenericValue::VALUE_TYPE_BYTES:
202 if (value.has_bytes_value()) { 202 if (value.has_bytes_value()) {
203 std::string bytes = value.bytes_value(); 203 std::string bytes = value.bytes_value();
204 return base::BinaryValue::CreateWithCopiedBuffer(bytes.c_str(), 204 return base::BinaryValue::CreateWithCopiedBuffer(bytes.c_str(),
205 bytes.size()); 205 bytes.size());
206 } 206 }
207 return NULL; 207 return NULL;
208 case em::GenericValue::VALUE_TYPE_BOOL_ARRAY: { 208 case em::GenericValue::VALUE_TYPE_BOOL_ARRAY: {
209 ListValue* list = new ListValue; 209 ListValue* list = new ListValue;
210 RepeatedField<bool>::const_iterator i; 210 RepeatedField<bool>::const_iterator i;
211 for (i = value.bool_array().begin(); i != value.bool_array().end(); ++i) 211 for (i = value.bool_array().begin(); i != value.bool_array().end(); ++i)
212 list->Append(Value::CreateBooleanValue(*i)); 212 list->Append(base::BooleanValue::New(*i));
213 return list; 213 return list;
214 } 214 }
215 case em::GenericValue::VALUE_TYPE_INT64_ARRAY: { 215 case em::GenericValue::VALUE_TYPE_INT64_ARRAY: {
216 ListValue* list = new ListValue; 216 ListValue* list = new ListValue;
217 RepeatedField<google::protobuf::int64>::const_iterator i; 217 RepeatedField<google::protobuf::int64>::const_iterator i;
218 for (i = value.int64_array().begin(); 218 for (i = value.int64_array().begin();
219 i != value.int64_array().end(); ++i) { 219 i != value.int64_array().end(); ++i) {
220 Value* int_value = DecodeIntegerValue(*i); 220 Value* int_value = DecodeIntegerValue(*i);
221 if (int_value) 221 if (int_value)
222 list->Append(int_value); 222 list->Append(int_value);
223 } 223 }
224 return list; 224 return list;
225 } 225 }
226 case em::GenericValue::VALUE_TYPE_STRING_ARRAY: { 226 case em::GenericValue::VALUE_TYPE_STRING_ARRAY: {
227 ListValue* list = new ListValue; 227 ListValue* list = new ListValue;
228 RepeatedPtrField<std::string>::const_iterator i; 228 RepeatedPtrField<std::string>::const_iterator i;
229 for (i = value.string_array().begin(); 229 for (i = value.string_array().begin();
230 i != value.string_array().end(); ++i) 230 i != value.string_array().end(); ++i)
231 list->Append(Value::CreateStringValue(*i)); 231 list->Append(base::StringValue::New(*i));
232 return list; 232 return list;
233 } 233 }
234 case em::GenericValue::VALUE_TYPE_DOUBLE_ARRAY: { 234 case em::GenericValue::VALUE_TYPE_DOUBLE_ARRAY: {
235 ListValue* list = new ListValue; 235 ListValue* list = new ListValue;
236 RepeatedField<double>::const_iterator i; 236 RepeatedField<double>::const_iterator i;
237 for (i = value.double_array().begin(); 237 for (i = value.double_array().begin();
238 i != value.double_array().end(); ++i) 238 i != value.double_array().end(); ++i)
239 list->Append(Value::CreateDoubleValue(*i)); 239 list->Append(base::NumberValue::New(*i));
240 return list; 240 return list;
241 } 241 }
242 default: 242 default:
243 NOTREACHED() << "Unhandled value type"; 243 NOTREACHED() << "Unhandled value type";
244 } 244 }
245 245
246 return NULL; 246 return NULL;
247 } 247 }
248 248
249 } // namespace policy 249 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_map_unittest.cc ('k') | chrome/browser/policy/user_policy_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698