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(
const std::string& onc_spec,
const base::Closure& success_callback,
const network_handler::ErrorCallback& error_callback) const {
std::string error;
std::unique_ptr<base::Value> root =
base::JSONReader::ReadAndReturnErrorDeprecated(
onc_spec, base::JSON_ALLOW_TRAILING_COMMAS, nullptr, &error);
base::JSONReader::ValueWithError parsed_json =
base::JSONReader::ReadAndReturnValueWithError(
onc_spec, base::JSON_ALLOW_TRAILING_COMMAS);
base::DictionaryValue* toplevel_onc = nullptr;
if (!root || !root->GetAsDictionary(&toplevel_onc)) {
LOG(ERROR) << kInvalidJsonError << ": " << error;
if (!parsed_json.value ||
!parsed_json.value->GetAsDictionary(&toplevel_onc)) {
LOG(ERROR) << kInvalidJsonError << ": " << parsed_json.error_message;
std::unique_ptr<base::DictionaryValue> error_data =
std::make_unique<base::DictionaryValue>();
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));
return;
}
......
......@@ -82,17 +82,18 @@ void OobeConfiguration::OnConfigurationCheck(bool has_configuration,
return;
}
int error_code, row, col;
std::string error_message;
auto value = base::JSONReader::ReadAndReturnErrorDeprecated(
configuration, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS,
&error_code, &error_message, &row, &col);
if (!value) {
LOG(ERROR) << "Error parsing OOBE configuration: " << error_message;
} else if (!chromeos::configuration::ValidateConfiguration(*value)) {
base::JSONReader::ValueWithError parsed_json =
base::JSONReader::ReadAndReturnValueWithError(
configuration, base::JSON_ALLOW_TRAILING_COMMAS);
if (!parsed_json.value) {
LOG(ERROR) << "Error parsing OOBE configuration: "
<< parsed_json.error_message;
} else if (!chromeos::configuration::ValidateConfiguration(
*parsed_json.value)) {
LOG(ERROR) << "Invalid OOBE configuration";
} else {
configuration_ = std::move(value);
configuration_ =
base::Value::ToUniquePtrValue(std::move(*parsed_json.value));
UpdateConfigurationValues();
}
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