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

Side by Side Diff: components/policy/core/common/registry_dict_win.cc

Issue 390233003: Decrement CreateDoubleValue count (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/registry_dict_win.h" 5 #include "components/policy/core/common/registry_dict_win.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Integers may be string-encoded. 79 // Integers may be string-encoded.
80 if (value.GetAsString(&string_value) && 80 if (value.GetAsString(&string_value) &&
81 base::StringToInt(string_value, &int_value)) { 81 base::StringToInt(string_value, &int_value)) {
82 return scoped_ptr<base::Value>(new base::FundamentalValue(int_value)); 82 return scoped_ptr<base::Value>(new base::FundamentalValue(int_value));
83 } 83 }
84 break; 84 break;
85 } 85 }
86 case base::Value::TYPE_DOUBLE: { 86 case base::Value::TYPE_DOUBLE: {
87 // Doubles may be string-encoded or integer-encoded. 87 // Doubles may be string-encoded or integer-encoded.
88 double double_value = 0; 88 double double_value = 0;
89 if (value.GetAsInteger(&int_value)) { 89 if (value.GetAsDouble(&double_value) ||
90 (value.GetAsString(&string_value) &&
91 base::StringToDouble(string_value, &double_value))) {
90 return scoped_ptr<base::Value>( 92 return scoped_ptr<base::Value>(
91 base::Value::CreateDoubleValue(int_value)); 93 new base::FundamentalValue(double_value));
92 } else if (value.GetAsString(&string_value) &&
93 base::StringToDouble(string_value, &double_value)) {
94 return scoped_ptr<base::Value>(
95 base::Value::CreateDoubleValue(double_value));
96 } 94 }
97 break; 95 break;
98 } 96 }
99 case base::Value::TYPE_LIST: { 97 case base::Value::TYPE_LIST: {
100 // Lists are encoded as subkeys with numbered value in the registry. 98 // Lists are encoded as subkeys with numbered value in the registry.
101 const base::DictionaryValue* dict = NULL; 99 const base::DictionaryValue* dict = NULL;
102 if (value.GetAsDictionary(&dict)) { 100 if (value.GetAsDictionary(&dict)) {
103 scoped_ptr<base::ListValue> result(new base::ListValue()); 101 scoped_ptr<base::ListValue> result(new base::ListValue());
104 for (int i = 1; ; ++i) { 102 for (int i = 1; ; ++i) {
105 const base::Value* entry = NULL; 103 const base::Value* entry = NULL;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 return result.PassAs<base::Value>(); 341 return result.PassAs<base::Value>();
344 } 342 }
345 default: 343 default:
346 LOG(WARNING) << "Can't convert registry key to schema type " << type; 344 LOG(WARNING) << "Can't convert registry key to schema type " << type;
347 } 345 }
348 346
349 return scoped_ptr<base::Value>(); 347 return scoped_ptr<base::Value>();
350 } 348 }
351 349
352 } // namespace policy 350 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/mac_util.cc ('k') | components/policy/core/common/schema_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698