summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_util.cc5
-rw-r--r--chrome/browser/extensions/extension_history_api.cc8
-rw-r--r--chrome/browser/extensions/extension_tts_api.cc6
-rw-r--r--chrome/browser/extensions/extension_tts_api_util.cc24
-rw-r--r--chrome/browser/extensions/extension_tts_api_util.h6
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc18
-rw-r--r--chrome/browser/themes/browser_theme_pack.cc21
-rw-r--r--chrome/common/extensions/extension.cc14
-rw-r--r--chrome/common/json_schema_validator.cc33
-rw-r--r--chrome/test/webdriver/cookie.cc5
-rw-r--r--content/browser/host_zoom_map.cc18
11 files changed, 27 insertions, 131 deletions
diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc
index 159b16c..cc66bfd 100644
--- a/chrome/browser/automation/automation_util.cc
+++ b/chrome/browser/automation/automation_util.cc
@@ -303,10 +303,7 @@ void SetCookieJSON(AutomationProvider* provider,
return;
}
if (cookie_dict->HasKey("expiry")) {
- int expiry_int;
- if (cookie_dict->GetInteger("expiry", &expiry_int)) {
- expiry = expiry_int;
- } else if (!cookie_dict->GetDouble("expiry", &expiry)) {
+ if (!cookie_dict->GetDouble("expiry", &expiry)) {
reply.SendError("optional 'expiry' invalid");
return;
}
diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc
index 49929bd..9ead422 100644
--- a/chrome/browser/extensions/extension_history_api.cc
+++ b/chrome/browser/extensions/extension_history_api.cc
@@ -176,12 +176,8 @@ bool HistoryFunction::GetUrlFromValue(Value* value, GURL* url) {
bool HistoryFunction::GetTimeFromValue(Value* value, base::Time* time) {
double ms_from_epoch = 0.0;
- if (!value->GetAsDouble(&ms_from_epoch)) {
- int ms_from_epoch_as_int = 0;
- if (!value->GetAsInteger(&ms_from_epoch_as_int))
- return false;
- ms_from_epoch = static_cast<double>(ms_from_epoch_as_int);
- }
+ if (!value->GetAsDouble(&ms_from_epoch))
+ return false;
// The history service has seconds resolution, while javascript Date() has
// milliseconds resolution.
double seconds_from_epoch = ms_from_epoch / 1000.0;
diff --git a/chrome/browser/extensions/extension_tts_api.cc b/chrome/browser/extensions/extension_tts_api.cc
index 997f080..4781751 100644
--- a/chrome/browser/extensions/extension_tts_api.cc
+++ b/chrome/browser/extensions/extension_tts_api.cc
@@ -79,17 +79,17 @@ Utterance::Utterance(Profile* profile,
if (options->HasKey(util::kGenderKey))
options->GetString(util::kGenderKey, &gender_);
- if (util::ReadNumberByKey(options, util::kRateKey, &rate_)) {
+ if (options->GetDouble(util::kRateKey, &rate_)) {
if (!base::IsFinite(rate_) || rate_ < 0.0 || rate_ > 1.0)
rate_ = -1.0;
}
- if (util::ReadNumberByKey(options, util::kPitchKey, &pitch_)) {
+ if (options->GetDouble(util::kPitchKey, &pitch_)) {
if (!base::IsFinite(pitch_) || pitch_ < 0.0 || pitch_ > 1.0)
pitch_ = -1.0;
}
- if (util::ReadNumberByKey(options, util::kVolumeKey, &volume_)) {
+ if (options->GetDouble(util::kVolumeKey, &volume_)) {
if (!base::IsFinite(volume_) || volume_ < 0.0 || volume_ > 1.0)
volume_ = -1.0;
}
diff --git a/chrome/browser/extensions/extension_tts_api_util.cc b/chrome/browser/extensions/extension_tts_api_util.cc
index b630387..8884966 100644
--- a/chrome/browser/extensions/extension_tts_api_util.cc
+++ b/chrome/browser/extensions/extension_tts_api_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,26 +14,4 @@ const char kPitchKey[] = "pitch";
const char kVolumeKey[] = "volume";
const char kEnqueueKey[] = "enqueue";
-// Static.
-bool ReadNumberByKey(DictionaryValue* dict,
- const char* key,
- double* ret_value) {
- Value* value;
- if (!dict->Get(key, &value))
- return false;
-
- if (value->IsType(Value::TYPE_INTEGER)) {
- int int_value;
- if (!dict->GetInteger(key, &int_value))
- return false;
- *ret_value = int_value;
- } else if (value->IsType(Value::TYPE_DOUBLE)) {
- if (!dict->GetDouble(key, ret_value))
- return false;
- } else {
- return false;
- }
- return true;
-}
-
} // namespace extension_tts_api_util.
diff --git a/chrome/browser/extensions/extension_tts_api_util.h b/chrome/browser/extensions/extension_tts_api_util.h
index 9d13e75..4ca782c 100644
--- a/chrome/browser/extensions/extension_tts_api_util.h
+++ b/chrome/browser/extensions/extension_tts_api_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,9 +19,5 @@ extern const char kPitchKey[];
extern const char kVolumeKey[];
extern const char kEnqueueKey[];
-bool ReadNumberByKey(DictionaryValue* dict,
- const char* key,
- double* ret_value);
-
} // namespace extension_tts_api_util.
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TTS_API_UTIL_H_
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index 83f94e5..64c2fea 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -99,18 +99,6 @@
namespace internal_cloud_print_helpers {
-bool GetDoubleOrInt(const DictionaryValue& dictionary,
- const std::string& path,
- double* out_value) {
- if (!dictionary.GetDouble(path, out_value)) {
- int int_value = 0;
- if (!dictionary.GetInteger(path, &int_value))
- return false;
- *out_value = int_value;
- }
- return true;
-}
-
// From the JSON parsed value, get the entries for the page setup
// parameters.
bool GetPageSetupParameters(const std::string& json,
@@ -124,9 +112,9 @@ bool GetPageSetupParameters(const std::string& json,
bool result = true;
DictionaryValue* params = static_cast<DictionaryValue*>(parsed_value.get());
- result &= GetDoubleOrInt(*params, "dpi", &parameters.dpi);
- result &= GetDoubleOrInt(*params, "min_shrink", &parameters.min_shrink);
- result &= GetDoubleOrInt(*params, "max_shrink", &parameters.max_shrink);
+ result &= params->GetDouble("dpi", &parameters.dpi);
+ result &= params->GetDouble("min_shrink", &parameters.min_shrink);
+ result &= params->GetDouble("max_shrink", &parameters.max_shrink);
result &= params->GetBoolean("selection_only", &parameters.selection_only);
return result;
}
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 5bfcd88..95945b4 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -298,21 +298,6 @@ RefCountedMemory* ReadFileData(const FilePath& path) {
return NULL;
}
-// Does error checking for invalid incoming data while trying to read an
-// floating point value.
-bool ValidDoubleValue(ListValue* tint_list, int index, double* out) {
- if (tint_list->GetDouble(index, out))
- return true;
-
- int value = 0;
- if (tint_list->GetInteger(index, &value)) {
- *out = value;
- return true;
- }
-
- return false;
-}
-
// Shifts a bitmap's HSL values. The caller is responsible for deleting
// the returned image.
gfx::Image* CreateHSLShiftedImage(const gfx::Image& image,
@@ -646,9 +631,9 @@ void BrowserThemePack::BuildTintsFromJSON(DictionaryValue* tints_value) {
(tint_list->GetSize() == 3)) {
color_utils::HSL hsl = { -1, -1, -1 };
- if (ValidDoubleValue(tint_list, 0, &hsl.h) &&
- ValidDoubleValue(tint_list, 1, &hsl.s) &&
- ValidDoubleValue(tint_list, 2, &hsl.l)) {
+ if (tint_list->GetDouble(0, &hsl.h) &&
+ tint_list->GetDouble(1, &hsl.s) &&
+ tint_list->GetDouble(2, &hsl.l)) {
int id = GetIntForString(*iter, kTintTable);
if (id != -1) {
temp_tints[id] = hsl;
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 815e23e..050d6b8 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1882,16 +1882,15 @@ bool Extension::InitFromValue(const DictionaryValue& source, int flags,
iter != colors_value->end_keys(); ++iter) {
ListValue* color_list = NULL;
double alpha = 0.0;
- int alpha_int = 0;
int color = 0;
// The color must be a list
if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) ||
// And either 3 items (RGB) or 4 (RGBA)
((color_list->GetSize() != 3) &&
((color_list->GetSize() != 4) ||
- // For RGBA, the fourth item must be a real or int alpha value
- (!color_list->GetDouble(3, &alpha) &&
- !color_list->GetInteger(3, &alpha_int)))) ||
+ // For RGBA, the fourth item must be a real or int alpha value.
+ // Note that GetDouble() can get an integer value.
+ !color_list->GetDouble(3, &alpha))) ||
// For both RGB and RGBA, the first three items must be ints (R,G,B)
!color_list->GetInteger(0, &color) ||
!color_list->GetInteger(1, &color) ||
@@ -1910,12 +1909,11 @@ bool Extension::InitFromValue(const DictionaryValue& source, int flags,
iter != tints_value->end_keys(); ++iter) {
ListValue* tint_list = NULL;
double v = 0.0;
- int vi = 0;
if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) ||
tint_list->GetSize() != 3 ||
- !(tint_list->GetDouble(0, &v) || tint_list->GetInteger(0, &vi)) ||
- !(tint_list->GetDouble(1, &v) || tint_list->GetInteger(1, &vi)) ||
- !(tint_list->GetDouble(2, &v) || tint_list->GetInteger(2, &vi))) {
+ !tint_list->GetDouble(0, &v) ||
+ !tint_list->GetDouble(1, &v) ||
+ !tint_list->GetDouble(2, &v)) {
*error = errors::kInvalidThemeTints;
return false;
}
diff --git a/chrome/common/json_schema_validator.cc b/chrome/common/json_schema_validator.cc
index 7da218f..0662fcf 100644
--- a/chrome/common/json_schema_validator.cc
+++ b/chrome/common/json_schema_validator.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,30 +16,9 @@ namespace {
double GetNumberValue(Value* value) {
double result = 0;
- if (value->GetAsDouble(&result))
- return result;
-
- int int_result = 0;
- if (value->GetAsInteger(&int_result)) {
- return int_result;
- }
-
- CHECK(false) << "Unexpected value type: " << value->GetType();
- return 0;
-}
-
-bool GetNumberFromDictionary(DictionaryValue* value, const std::string& key,
- double* number) {
- if (value->GetDouble(key, number))
- return true;
-
- int int_value = 0;
- if (value->GetInteger(key, &int_value)) {
- *number = int_value;
- return true;
- }
-
- return false;
+ CHECK(value->GetAsDouble(&result))
+ << "Unexpected value type: " << value->GetType();
+ return result;
}
} // namespace
@@ -459,14 +438,14 @@ void JSONSchemaValidator::ValidateNumber(Value* instance,
// but isnan and isinf aren't defined on Windows.
double minimum = 0;
- if (GetNumberFromDictionary(schema, "minimum", &minimum)) {
+ if (schema->GetDouble("minimum", &minimum)) {
if (value < minimum)
errors_.push_back(Error(path, FormatErrorMessage(
kNumberMinimum, base::DoubleToString(minimum))));
}
double maximum = 0;
- if (GetNumberFromDictionary(schema, "maximum", &maximum)) {
+ if (schema->GetDouble("maximum", &maximum)) {
if (value > maximum)
errors_.push_back(Error(path, FormatErrorMessage(
kNumberMaximum, base::DoubleToString(maximum))));
diff --git a/chrome/test/webdriver/cookie.cc b/chrome/test/webdriver/cookie.cc
index fdabc5e..a5a492a 100644
--- a/chrome/test/webdriver/cookie.cc
+++ b/chrome/test/webdriver/cookie.cc
@@ -72,10 +72,7 @@ Cookie::Cookie(const DictionaryValue& dict) {
// it could be either a floating point or integer number.
double expiry;
if (!dict.GetDouble("expiry", &expiry)) {
- int tmp;
- if (!dict.GetInteger("expiry", &tmp))
- return; // Expiry is not a number, so the cookie is invalid.
- expiry = static_cast<double>(tmp);
+ return; // Expiry is not a number, so the cookie is invalid.
}
expiration_ = base::Time::FromDoubleT(expiry);
diff --git a/content/browser/host_zoom_map.cc b/content/browser/host_zoom_map.cc
index 3d50403..98ebc1c 100644
--- a/content/browser/host_zoom_map.cc
+++ b/content/browser/host_zoom_map.cc
@@ -64,24 +64,6 @@ void HostZoomMap::Load() {
bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion(
host, &zoom_level);
- if (!success) {
- // The data used to be stored as ints, so try that.
- int int_zoom_level;
- success = host_zoom_dictionary->GetIntegerWithoutPathExpansion(
- host, &int_zoom_level);
- if (success) {
- zoom_level = static_cast<double>(int_zoom_level);
- // Since the values were once stored as non-clamped, clamp now.
- double zoom_factor = WebView::zoomLevelToZoomFactor(zoom_level);
- if (zoom_factor < WebView::minTextSizeMultiplier) {
- zoom_level =
- WebView::zoomFactorToZoomLevel(WebView::minTextSizeMultiplier);
- } else if (zoom_factor > WebView::maxTextSizeMultiplier) {
- zoom_level =
- WebView::zoomFactorToZoomLevel(WebView::maxTextSizeMultiplier);
- }
- }
- }
DCHECK(success);
host_zoom_levels_[host] = zoom_level;
}