| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The implementation of TranslateONCObjectToShill is structured in two parts: | 5 // The implementation of TranslateONCObjectToShill is structured in two parts: |
| 6 // - The recursion through the existing ONC hierarchy | 6 // - The recursion through the existing ONC hierarchy |
| 7 // see TranslateONCHierarchy | 7 // see TranslateONCHierarchy |
| 8 // - The local translation of an object depending on the associated signature | 8 // - The local translation of an object depending on the associated signature |
| 9 // see LocalTranslator::TranslateFields | 9 // see LocalTranslator::TranslateFields |
| 10 | 10 |
| 11 #include "chromeos/network/onc/onc_translator.h" | 11 #include "chromeos/network/onc/onc_translator.h" |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chromeos/network/onc/onc_signature.h" | 20 #include "chromeos/network/onc/onc_signature.h" |
| 21 #include "chromeos/network/onc/onc_translation_tables.h" | 21 #include "chromeos/network/onc/onc_translation_tables.h" |
| 22 #include "chromeos/network/onc/onc_utils.h" |
| 22 #include "chromeos/network/shill_property_util.h" | 23 #include "chromeos/network/shill_property_util.h" |
| 23 #include "components/onc/onc_constants.h" | 24 #include "components/onc/onc_constants.h" |
| 24 #include "third_party/cros_system_api/dbus/service_constants.h" | 25 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 25 | 26 |
| 26 namespace chromeos { | 27 namespace chromeos { |
| 27 namespace onc { | 28 namespace onc { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 scoped_ptr<base::StringValue> ConvertValueToString(const base::Value& value) { | 32 scoped_ptr<base::StringValue> ConvertValueToString(const base::Value& value) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 onc_object_->GetStringWithoutPathExpansion( | 278 onc_object_->GetStringWithoutPathExpansion( |
| 278 ::onc::network_config::kNameServersConfigType, &name_servers_config_type); | 279 ::onc::network_config::kNameServersConfigType, &name_servers_config_type); |
| 279 if ((ip_address_config_type == ::onc::network_config::kIPConfigTypeDHCP) || | 280 if ((ip_address_config_type == ::onc::network_config::kIPConfigTypeDHCP) || |
| 280 (name_servers_config_type == ::onc::network_config::kIPConfigTypeDHCP)) { | 281 (name_servers_config_type == ::onc::network_config::kIPConfigTypeDHCP)) { |
| 281 // If either type is set to DHCP, provide an empty dictionary to ensure | 282 // If either type is set to DHCP, provide an empty dictionary to ensure |
| 282 // that any unset properties are cleared. Note: if either type is specified, | 283 // that any unset properties are cleared. Note: if either type is specified, |
| 283 // the other type defaults to DHCP if not specified. | 284 // the other type defaults to DHCP if not specified. |
| 284 shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPConfigProperty, | 285 shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPConfigProperty, |
| 285 new base::DictionaryValue); | 286 new base::DictionaryValue); |
| 286 } | 287 } |
| 288 |
| 289 const base::DictionaryValue* proxy_settings = nullptr; |
| 290 if (onc_object_->GetDictionaryWithoutPathExpansion( |
| 291 ::onc::network_config::kProxySettings, &proxy_settings)) { |
| 292 scoped_ptr<base::DictionaryValue> proxy_config = |
| 293 ConvertOncProxySettingsToProxyConfig(*proxy_settings); |
| 294 std::string proxy_config_str; |
| 295 base::JSONWriter::Write(*proxy_config.get(), &proxy_config_str); |
| 296 shill_dictionary_->SetStringWithoutPathExpansion( |
| 297 shill::kProxyConfigProperty, proxy_config_str); |
| 298 } |
| 299 |
| 287 CopyFieldsAccordingToSignature(); | 300 CopyFieldsAccordingToSignature(); |
| 288 } | 301 } |
| 289 | 302 |
| 290 void LocalTranslator::CopyFieldsAccordingToSignature() { | 303 void LocalTranslator::CopyFieldsAccordingToSignature() { |
| 291 for (base::DictionaryValue::Iterator it(*onc_object_); !it.IsAtEnd(); | 304 for (base::DictionaryValue::Iterator it(*onc_object_); !it.IsAtEnd(); |
| 292 it.Advance()) { | 305 it.Advance()) { |
| 293 AddValueAccordingToSignature(it.key(), | 306 AddValueAccordingToSignature(it.key(), |
| 294 make_scoped_ptr(it.value().DeepCopy())); | 307 make_scoped_ptr(it.value().DeepCopy())); |
| 295 } | 308 } |
| 296 } | 309 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 const OncValueSignature* onc_signature, | 414 const OncValueSignature* onc_signature, |
| 402 const base::DictionaryValue& onc_object) { | 415 const base::DictionaryValue& onc_object) { |
| 403 CHECK(onc_signature != NULL); | 416 CHECK(onc_signature != NULL); |
| 404 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 417 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
| 405 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 418 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 406 return shill_dictionary.Pass(); | 419 return shill_dictionary.Pass(); |
| 407 } | 420 } |
| 408 | 421 |
| 409 } // namespace onc | 422 } // namespace onc |
| 410 } // namespace chromeos | 423 } // namespace chromeos |
| OLD | NEW |