Skip to content

Commit

Permalink
[Code health] Avoid Value::GetAsDictionary (in /content/browser)
Browse files Browse the repository at this point in the history
This method is deprecated, so port away from it, along with other nearby deprecated base::Value APIs that can be modernized at least somewhat locally.

This CL was uploaded by git cl split.

R=kenrb@chromium.org

Bug: 1187011
Change-Id: I0bc940754a9254c1d9f3d3d4a0b16a599999f02d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3827421
Auto-Submit: Maks Orlovich <morlovich@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Commit-Queue: Ken Buchanan <kenrb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1034943}
  • Loading branch information
Maks Orlovich authored and Chromium LUCI CQ committed Aug 15, 2022
1 parent dab3bd5 commit 271262e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions content/browser/site_per_process_hit_test_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,14 @@ void HitTestRootWindowTransform(

#if defined(USE_AURA)
bool ConvertJSONToPoint(const std::string& str, gfx::PointF* point) {
std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(str);
absl::optional<base::Value> value = base::JSONReader::Read(str);
if (!value)
return false;
base::DictionaryValue* root;
if (!value->GetAsDictionary(&root))
base::Value::Dict* root = value->GetIfDict();
if (!root)
return false;
absl::optional<double> x = root->FindDoubleKey("x");
absl::optional<double> y = root->FindDoubleKey("y");
absl::optional<double> x = root->FindDouble("x");
absl::optional<double> y = root->FindDouble("y");
if (!x || !y)
return false;
point->set_x(*x);
Expand All @@ -660,22 +660,22 @@ bool ConvertJSONToPoint(const std::string& str, gfx::PointF* point) {
}

bool ConvertJSONToRect(const std::string& str, gfx::Rect* rect) {
std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(str);
absl::optional<base::Value> value = base::JSONReader::Read(str);
if (!value)
return false;
base::DictionaryValue* root;
if (!value->GetAsDictionary(&root))
base::Value::Dict* root = value->GetIfDict();
if (!root)
return false;
absl::optional<int> x = root->FindIntKey("x");
absl::optional<int> x = root->FindInt("x");
if (!x)
return false;
absl::optional<int> y = root->FindIntKey("y");
absl::optional<int> y = root->FindInt("y");
if (!y)
return false;
absl::optional<int> width = root->FindIntKey("width");
absl::optional<int> width = root->FindInt("width");
if (!width)
return false;
absl::optional<int> height = root->FindIntKey("height");
absl::optional<int> height = root->FindInt("height");
if (!height)
return false;
rect->set_x(*x);
Expand Down

0 comments on commit 271262e

Please sign in to comment.