summaryrefslogtreecommitdiffstats
path: root/components/policy
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-19 04:40:29 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-19 04:40:29 +0000
commite7518a191c3211e80331eba78a7d092fbf9c664a (patch)
tree0bcc1b1764fedde53840f9a3b04f33380f312819 /components/policy
parent9ff40b3bf0bff641b21890423fbe5e5e17190302 (diff)
downloadchromium_src-e7518a191c3211e80331eba78a7d092fbf9c664a.zip
chromium_src-e7518a191c3211e80331eba78a7d092fbf9c664a.tar.gz
chromium_src-e7518a191c3211e80331eba78a7d092fbf9c664a.tar.bz2
Decrement CreateDoubleValue count
BUG=160586 Review URL: https://codereview.chromium.org/390233003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284304 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/policy')
-rw-r--r--components/policy/core/browser/configuration_policy_handler.cc12
-rw-r--r--components/policy/core/browser/configuration_policy_handler_unittest.cc16
-rw-r--r--components/policy/core/common/mac_util.cc2
-rw-r--r--components/policy/core/common/registry_dict_win.cc10
-rw-r--r--components/policy/core/common/schema_map_unittest.cc7
-rw-r--r--components/policy/core/common/schema_unittest.cc2
6 files changed, 23 insertions, 26 deletions
diff --git a/components/policy/core/browser/configuration_policy_handler.cc b/components/policy/core/browser/configuration_policy_handler.cc
index 969b8d5..5927ab4 100644
--- a/components/policy/core/browser/configuration_policy_handler.cc
+++ b/components/policy/core/browser/configuration_policy_handler.cc
@@ -267,10 +267,8 @@ void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
return;
const base::Value* value = policies.GetValue(policy_name());
int value_in_range;
- if (value && EnsureInRange(value, &value_in_range, NULL)) {
- prefs->SetValue(pref_path_,
- new base::FundamentalValue(value_in_range));
- }
+ if (value && EnsureInRange(value, &value_in_range, NULL))
+ prefs->SetInteger(pref_path_, value_in_range);
}
@@ -296,10 +294,8 @@ void IntPercentageToDoublePolicyHandler::ApplyPolicySettings(
return;
const base::Value* value = policies.GetValue(policy_name());
int percentage;
- if (value && EnsureInRange(value, &percentage, NULL)) {
- prefs->SetValue(pref_path_, base::Value::CreateDoubleValue(
- static_cast<double>(percentage) / 100.));
- }
+ if (value && EnsureInRange(value, &percentage, NULL))
+ prefs->SetDouble(pref_path_, static_cast<double>(percentage) / 100.);
}
diff --git a/components/policy/core/browser/configuration_policy_handler_unittest.cc b/components/policy/core/browser/configuration_policy_handler_unittest.cc
index db30b0f..a969219 100644
--- a/components/policy/core/browser/configuration_policy_handler_unittest.cc
+++ b/components/policy/core/browser/configuration_policy_handler_unittest.cc
@@ -530,7 +530,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.0));
+ expected.reset(new base::FundamentalValue(0.0));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
@@ -541,7 +541,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.05));
+ expected.reset(new base::FundamentalValue(0.05));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
@@ -552,7 +552,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.1));
+ expected.reset(new base::FundamentalValue(0.1));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
@@ -565,7 +565,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.0));
+ expected.reset(new base::FundamentalValue(0.0));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
@@ -576,7 +576,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.1));
+ expected.reset(new base::FundamentalValue(0.1));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
}
@@ -600,7 +600,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsDontClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.0));
+ expected.reset(new base::FundamentalValue(0.0));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
@@ -611,7 +611,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsDontClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.05));
+ expected.reset(new base::FundamentalValue(0.05));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
@@ -622,7 +622,7 @@ TEST(IntPercentageToDoublePolicyHandler, ApplyPolicySettingsDontClamp) {
NULL);
prefs.Clear();
handler.ApplyPolicySettings(policy_map, &prefs);
- expected.reset(base::Value::CreateDoubleValue(0.1));
+ expected.reset(new base::FundamentalValue(0.1));
EXPECT_TRUE(prefs.GetValue(kTestPref, &value));
EXPECT_TRUE(base::Value::Equals(expected.get(), value));
}
diff --git a/components/policy/core/common/mac_util.cc b/components/policy/core/common/mac_util.cc
index b1bea9d..d8f4693 100644
--- a/components/policy/core/common/mac_util.cc
+++ b/components/policy/core/common/mac_util.cc
@@ -59,7 +59,7 @@ scoped_ptr<base::Value> PropertyToValue(CFPropertyListRef property) {
double double_value = 0.0;
if (CFNumberGetValue(number, kCFNumberDoubleType, &double_value)) {
return scoped_ptr<base::Value>(
- base::Value::CreateDoubleValue(double_value));
+ new base::FundamentalValue(double_value));
}
} else {
int int_value = 0;
diff --git a/components/policy/core/common/registry_dict_win.cc b/components/policy/core/common/registry_dict_win.cc
index dc78ebc..61657b8 100644
--- a/components/policy/core/common/registry_dict_win.cc
+++ b/components/policy/core/common/registry_dict_win.cc
@@ -86,13 +86,11 @@ scoped_ptr<base::Value> ConvertValue(const base::Value& value,
case base::Value::TYPE_DOUBLE: {
// Doubles may be string-encoded or integer-encoded.
double double_value = 0;
- if (value.GetAsInteger(&int_value)) {
- return scoped_ptr<base::Value>(
- base::Value::CreateDoubleValue(int_value));
- } else if (value.GetAsString(&string_value) &&
- base::StringToDouble(string_value, &double_value)) {
+ if (value.GetAsDouble(&double_value) ||
+ (value.GetAsString(&string_value) &&
+ base::StringToDouble(string_value, &double_value))) {
return scoped_ptr<base::Value>(
- base::Value::CreateDoubleValue(double_value));
+ new base::FundamentalValue(double_value));
}
break;
}
diff --git a/components/policy/core/common/schema_map_unittest.cc b/components/policy/core/common/schema_map_unittest.cc
index 77d332b..71dcc68 100644
--- a/components/policy/core/common/schema_map_unittest.cc
+++ b/components/policy/core/common/schema_map_unittest.cc
@@ -174,8 +174,11 @@ TEST_F(SchemaMapTest, FilterBundle) {
NULL);
map.Set("null", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
base::Value::CreateNullValue(), NULL);
- map.Set("double", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateDoubleValue(1.2), NULL);
+ map.Set("double",
+ POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER,
+ new base::FundamentalValue(1.2),
+ NULL);
base::DictionaryValue dict;
dict.SetString("a", "b");
dict.SetInteger("b", 2);
diff --git a/components/policy/core/common/schema_unittest.cc b/components/policy/core/common/schema_unittest.cc
index b8941e1..766c6d9 100644
--- a/components/policy/core/common/schema_unittest.cc
+++ b/components/policy/core/common/schema_unittest.cc
@@ -636,7 +636,7 @@ TEST(SchemaTest, Validate) {
bundle.SetBoolean("Boolean", true);
bundle.SetInteger("Integer", 123);
bundle.Set("Null", base::Value::CreateNullValue());
- bundle.Set("Number", base::Value::CreateDoubleValue(3.14));
+ bundle.Set("Number", new base::FundamentalValue(3.14));
bundle.SetString("String", "omg");
{