Chromium Code Reviews| 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 #include "chromeos/network/onc/onc_translator.h" | 5 #include "chromeos/network/onc/onc_translator.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chromeos/network/network_profile_handler.h" | 15 #include "chromeos/network/network_profile_handler.h" |
| 16 #include "chromeos/network/network_state.h" | 16 #include "chromeos/network/network_state.h" |
| 17 #include "chromeos/network/network_util.h" | 17 #include "chromeos/network/network_util.h" |
| 18 #include "chromeos/network/onc/onc_signature.h" | 18 #include "chromeos/network/onc/onc_signature.h" |
| 19 #include "chromeos/network/onc/onc_translation_tables.h" | 19 #include "chromeos/network/onc/onc_translation_tables.h" |
| 20 #include "chromeos/network/onc/onc_utils.h" | |
| 20 #include "chromeos/network/shill_property_util.h" | 21 #include "chromeos/network/shill_property_util.h" |
| 21 #include "components/onc/onc_constants.h" | 22 #include "components/onc/onc_constants.h" |
| 22 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 23 | 24 |
| 24 namespace chromeos { | 25 namespace chromeos { |
| 25 namespace onc { | 26 namespace onc { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 // Converts |str| to a base::Value of the given |type|. If the conversion fails, | 30 // Converts |str| to a base::Value of the given |type|. If the conversion fails, |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 !name_servers->empty()) { | 556 !name_servers->empty()) { |
| 556 onc_object_->SetStringWithoutPathExpansion( | 557 onc_object_->SetStringWithoutPathExpansion( |
| 557 ::onc::network_config::kNameServersConfigType, | 558 ::onc::network_config::kNameServersConfigType, |
| 558 ::onc::network_config::kIPConfigTypeStatic); | 559 ::onc::network_config::kIPConfigTypeStatic); |
| 559 } | 560 } |
| 560 if (!ip_address.empty() || (name_servers && !name_servers->empty())) { | 561 if (!ip_address.empty() || (name_servers && !name_servers->empty())) { |
| 561 TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig, | 562 TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig, |
| 562 *static_ipconfig); | 563 *static_ipconfig); |
| 563 } | 564 } |
| 564 } | 565 } |
| 566 | |
| 567 std::string proxy_config_str; | |
| 568 if (shill_dictionary_->GetStringWithoutPathExpansion( | |
| 569 shill::kProxyConfigProperty, &proxy_config_str) && | |
| 570 !proxy_config_str.empty()) { | |
| 571 scoped_ptr<base::DictionaryValue> proxy_config_value( | |
| 572 ReadDictionaryFromJson(proxy_config_str)); | |
|
eroman
2015/07/08 21:26:37
This can return NULL.
stevenjb
2015/07/08 22:13:07
Good catch, added test.
| |
| 573 scoped_ptr<base::DictionaryValue> proxy_settings = | |
| 574 ConvertProxyConfigToOncProxySettings(*proxy_config_value); | |
|
eroman
2015/07/08 21:26:37
Note that proxy_config_value could be NULL here.
stevenjb
2015/07/08 22:13:08
ConvertProxyConfigToOncProxySettings can also retu
| |
| 575 onc_object_->SetWithoutPathExpansion(::onc::network_config::kProxySettings, | |
| 576 proxy_settings.release()); | |
| 577 } | |
| 565 } | 578 } |
| 566 | 579 |
| 567 void ShillToONCTranslator::TranslateIPConfig() { | 580 void ShillToONCTranslator::TranslateIPConfig() { |
| 568 CopyPropertiesAccordingToSignature(); | 581 CopyPropertiesAccordingToSignature(); |
| 569 std::string shill_ip_method; | 582 std::string shill_ip_method; |
| 570 shill_dictionary_->GetStringWithoutPathExpansion(shill::kMethodProperty, | 583 shill_dictionary_->GetStringWithoutPathExpansion(shill::kMethodProperty, |
| 571 &shill_ip_method); | 584 &shill_ip_method); |
| 572 std::string type; | 585 std::string type; |
| 573 if (shill_ip_method == shill::kTypeIPv4 || | 586 if (shill_ip_method == shill::kTypeIPv4 || |
| 574 shill_ip_method == shill::kTypeDHCP) { | 587 shill_ip_method == shill::kTypeDHCP) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 const NetworkState* network_state) { | 763 const NetworkState* network_state) { |
| 751 CHECK(onc_signature != NULL); | 764 CHECK(onc_signature != NULL); |
| 752 | 765 |
| 753 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, | 766 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, |
| 754 network_state); | 767 network_state); |
| 755 return translator.CreateTranslatedONCObject(); | 768 return translator.CreateTranslatedONCObject(); |
| 756 } | 769 } |
| 757 | 770 |
| 758 } // namespace onc | 771 } // namespace onc |
| 759 } // namespace chromeos | 772 } // namespace chromeos |
| OLD | NEW |