[CodeHealth] Remove ListValue::GetInteger in c/b/ui/webui
Modernizes methods in chrome/browser/ui/webui which contained
deprecated ListValue::GetInteger methods, removing both GetInteger and
other deprecated method usage.
Where CHECKS were removed, the behavior remains unchanged as the GetInt
method internally CHECKs if the value is not an int (and CHECKs were
added to ensure the list is of the appropriate size).
Unfortunately, the compiler was not able to convert the Callback types
which required a ListValue to bind to Methods that accepted simply a
Value.
Bug: 1187087
Change-Id: I17df4005270687ecc6079869b6e0d7109c4abd13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3033624
Commit-Queue: Alexander Cooper <[email protected]>
Auto-Submit: Alexander Cooper <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#902777}
diff --git a/chrome/browser/ui/webui/help/help_utils_chromeos.cc b/chrome/browser/ui/webui/help/help_utils_chromeos.cc
index b2a4f3ca..c248b453 100644
--- a/chrome/browser/ui/webui/help/help_utils_chromeos.cc
+++ b/chrome/browser/ui/webui/help/help_utils_chromeos.cc
@@ -27,19 +27,19 @@
if (!settings)
return default_update_over_cellular_allowed;
- const base::Value* raw_types_value =
+ const base::Value* types_value =
settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate);
- if (!raw_types_value)
+ if (!types_value)
return default_update_over_cellular_allowed;
- const base::ListValue* types_value;
- CHECK(raw_types_value->GetAsList(&types_value));
- for (size_t i = 0; i < types_value->GetSize(); ++i) {
- int connection_type;
- if (!types_value->GetInteger(i, &connection_type)) {
+ CHECK(types_value->is_list());
+ const auto& list = types_value->GetList();
+ for (size_t i = 0; i < list.size(); ++i) {
+ if (!list[i].is_int()) {
LOG(WARNING) << "Can't parse connection type #" << i;
continue;
}
- if (connection_type == 4)
+
+ if (list[i].GetInt() == 4)
return true;
}
// Device policy does not allow updates over cellular, as cellular is not