| Index: chrome/browser/chromeos/cros/network_library_impl_base.cc
|
| diff --git a/chrome/browser/chromeos/cros/network_library_impl_base.cc b/chrome/browser/chromeos/cros/network_library_impl_base.cc
|
| index 89e5194b87f79d9a05fd0a09fcc83b0d4edfcd80..681761b81cc5f24d4a56ae1709d9ab017bb17e04 100644
|
| --- a/chrome/browser/chromeos/cros/network_library_impl_base.cc
|
| +++ b/chrome/browser/chromeos/cros/network_library_impl_base.cc
|
| @@ -1024,8 +1024,8 @@ void NetworkLibraryImplBase::SwitchToPreferredNetwork() {
|
| bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| const std::string& passphrase,
|
| NetworkUIData::ONCSource source,
|
| - bool allow_web_trust_from_policy,
|
| - std::string* error) {
|
| + bool allow_web_trust_from_policy) {
|
| + VLOG(2) << __func__ << ": called on " << onc_blob;
|
| NetworkProfile* profile = NULL;
|
| bool from_policy = (source == NetworkUIData::ONC_SOURCE_USER_POLICY ||
|
| source == NetworkUIData::ONC_SOURCE_DEVICE_POLICY);
|
| @@ -1037,20 +1037,17 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| if (from_policy) {
|
| profile = GetProfileForType(GetProfileTypeForSource(source));
|
| if (profile == NULL) {
|
| - DLOG(WARNING) << "Profile for ONC source " << source << " doesn't exist.";
|
| - return false;
|
| + VLOG(2) << "Profile for ONC source " << source << " doesn't exist.";
|
| + return true;
|
| }
|
| }
|
|
|
| - VLOG(2) << __func__ << ": called on " << onc_blob;
|
| std::string json_error;
|
| scoped_ptr<base::DictionaryValue> root_dict =
|
| onc::ReadDictionaryFromJson(onc_blob, &json_error);
|
| if (root_dict.get() == NULL) {
|
| - if (error != NULL)
|
| - *error = json_error;
|
| - LOG(WARNING) << "ONC loaded from ONC source " << source
|
| - << " is not a valid json dictionary: " << json_error;
|
| + LOG(ERROR) << "ONC loaded from ONC source " << source
|
| + << " is not a valid json dictionary: " << json_error;
|
| return false;
|
| }
|
|
|
| @@ -1061,10 +1058,8 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| std::string decrypt_error;
|
| root_dict = onc::Decrypt(passphrase, *root_dict, &decrypt_error);
|
| if (root_dict.get() == NULL) {
|
| - if (error != NULL)
|
| - *error = decrypt_error;
|
| - LOG(WARNING) << "Couldn't decrypt the ONC from source " << source
|
| - << " with error: " << decrypt_error;
|
| + LOG(ERROR) << "Couldn't decrypt the ONC from source " << source
|
| + << " with error: " << decrypt_error;
|
| return false;
|
| }
|
| }
|
| @@ -1077,13 +1072,16 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| from_policy);
|
|
|
| // Unknown fields are removed from the result.
|
| + onc::Validator::Result validation_result;
|
| root_dict = validator.ValidateAndRepairObject(
|
| - &onc::kUnencryptedConfigurationSignature,
|
| - *root_dict);
|
| -
|
| - if (root_dict.get() == NULL) {
|
| - LOG(WARNING) << "ONC from source " << source
|
| - << " is invalid and couldn't be repaired.";
|
| + &onc::kToplevelConfigurationSignature, *root_dict, &validation_result);
|
| +
|
| + if (validation_result == onc::Validator::VALID_WITH_WARNINGS) {
|
| + LOG(WARNING) << "ONC from source " << source << " produced warnings.";
|
| + } else if (validation_result == onc::Validator::INVALID ||
|
| + root_dict.get() == NULL) {
|
| + LOG(ERROR) << "ONC from source " << source
|
| + << " is invalid and couldn't be repaired.";
|
| return false;
|
| }
|
|
|
| @@ -1096,21 +1094,14 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| onc::kNetworkConfigurations,
|
| &network_configs);
|
|
|
| - // At least one of NetworkConfigurations or Certificates is required.
|
| - LOG_IF(WARNING, (!has_network_configurations && !has_certificates))
|
| - << "ONC from source " << source
|
| - << " has neither NetworkConfigurations nor Certificates.";
|
| -
|
| if (has_certificates) {
|
| VLOG(2) << "ONC file has " << certificates->GetSize() << " certificates";
|
|
|
| onc::CertificateImporter cert_importer(source, allow_web_trust_from_policy);
|
| std::string cert_error;
|
| if (!cert_importer.ParseAndStoreCertificates(*certificates, &cert_error)) {
|
| - if (error != NULL)
|
| - *error = cert_error;
|
| - LOG(WARNING) << "Cannot parse some of the certificates in the ONC from "
|
| - << "source " << source << " with error: " << cert_error;
|
| + LOG(ERROR) << "Cannot parse some of the certificates in the ONC from "
|
| + << "source " << source << " with error: " << cert_error;
|
| return false;
|
| }
|
| }
|
| @@ -1130,9 +1121,7 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| bool marked_for_removal = false;
|
| Network* network = parser.ParseNetwork(i, &marked_for_removal);
|
| if (!network) {
|
| - if (error != NULL)
|
| - *error = parser.parse_error();
|
| - LOG(WARNING) << "Error during parsing network at index " << i
|
| + LOG(ERROR) << "Error during parsing network at index " << i
|
| << " from ONC source " << source
|
| << ": " << parser.parse_error();
|
| return false;
|
| @@ -1205,8 +1194,8 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| if (ethernet) {
|
| CallConfigureService(ethernet->unique_id(), &dict);
|
| } else {
|
| - DLOG(WARNING) << "Tried to import ONC with an Ethernet network when "
|
| - << "there is no active Ethernet connection.";
|
| + LOG(WARNING) << "Tried to import ONC with an Ethernet network when "
|
| + << "there is no active Ethernet connection.";
|
| }
|
| } else {
|
| CallConfigureService(network->unique_id(), &dict);
|
| @@ -1222,10 +1211,8 @@ bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
|
| // ONC blob. We first collect the networks and do the actual deletion later
|
| // because ForgetNetwork() changes the remembered network vectors.
|
| ForgetNetworksById(source, network_ids, false);
|
| - } else if (source == NetworkUIData::ONC_SOURCE_USER_IMPORT) {
|
| - if (removal_ids.empty())
|
| - return true;
|
| -
|
| + } else if (source == NetworkUIData::ONC_SOURCE_USER_IMPORT &&
|
| + !removal_ids.empty()) {
|
| ForgetNetworksById(source, removal_ids, true);
|
| }
|
|
|
|
|