Commit 74dabe93 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Upgrade login from deprecated base::JSONReader API

Bug: 1070409
Change-Id: I15d324e82d7c5b8e8aa069207ce528a14e8eb0aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214652Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772191}
parent 8cc706be
...@@ -126,18 +126,19 @@ void NetworkStateHelper::CreateAndConnectNetworkFromOnc( ...@@ -126,18 +126,19 @@ void NetworkStateHelper::CreateAndConnectNetworkFromOnc(
const std::string& onc_spec, const std::string& onc_spec,
const base::Closure& success_callback, const base::Closure& success_callback,
const network_handler::ErrorCallback& error_callback) const { const network_handler::ErrorCallback& error_callback) const {
std::string error; base::JSONReader::ValueWithError parsed_json =
std::unique_ptr<base::Value> root = base::JSONReader::ReadAndReturnValueWithError(
base::JSONReader::ReadAndReturnErrorDeprecated( onc_spec, base::JSON_ALLOW_TRAILING_COMMAS);
onc_spec, base::JSON_ALLOW_TRAILING_COMMAS, nullptr, &error);
base::DictionaryValue* toplevel_onc = nullptr; base::DictionaryValue* toplevel_onc = nullptr;
if (!root || !root->GetAsDictionary(&toplevel_onc)) { if (!parsed_json.value ||
LOG(ERROR) << kInvalidJsonError << ": " << error; !parsed_json.value->GetAsDictionary(&toplevel_onc)) {
LOG(ERROR) << kInvalidJsonError << ": " << parsed_json.error_message;
std::unique_ptr<base::DictionaryValue> error_data = std::unique_ptr<base::DictionaryValue> error_data =
std::make_unique<base::DictionaryValue>(); std::make_unique<base::DictionaryValue>();
error_data->SetString(network_handler::kErrorName, kInvalidJsonError); error_data->SetString(network_handler::kErrorName, kInvalidJsonError);
error_data->SetString(network_handler::kErrorDetail, error); error_data->SetString(network_handler::kErrorDetail,
parsed_json.error_message);
error_callback.Run(kInvalidJsonError, std::move(error_data)); error_callback.Run(kInvalidJsonError, std::move(error_data));
return; return;
} }
......
...@@ -82,17 +82,18 @@ void OobeConfiguration::OnConfigurationCheck(bool has_configuration, ...@@ -82,17 +82,18 @@ void OobeConfiguration::OnConfigurationCheck(bool has_configuration,
return; return;
} }
int error_code, row, col; base::JSONReader::ValueWithError parsed_json =
std::string error_message; base::JSONReader::ReadAndReturnValueWithError(
auto value = base::JSONReader::ReadAndReturnErrorDeprecated( configuration, base::JSON_ALLOW_TRAILING_COMMAS);
configuration, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS, if (!parsed_json.value) {
&error_code, &error_message, &row, &col); LOG(ERROR) << "Error parsing OOBE configuration: "
if (!value) { << parsed_json.error_message;
LOG(ERROR) << "Error parsing OOBE configuration: " << error_message; } else if (!chromeos::configuration::ValidateConfiguration(
} else if (!chromeos::configuration::ValidateConfiguration(*value)) { *parsed_json.value)) {
LOG(ERROR) << "Invalid OOBE configuration"; LOG(ERROR) << "Invalid OOBE configuration";
} else { } else {
configuration_ = std::move(value); configuration_ =
base::Value::ToUniquePtrValue(std::move(*parsed_json.value));
UpdateConfigurationValues(); UpdateConfigurationValues();
} }
NotifyObservers(); NotifyObservers();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment