| 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void TranslateVPN(); | 83 void TranslateVPN(); |
| 84 void TranslateWiFiWithState(); | 84 void TranslateWiFiWithState(); |
| 85 void TranslateWiMAXWithState(); | 85 void TranslateWiMAXWithState(); |
| 86 void TranslateCellularWithState(); | 86 void TranslateCellularWithState(); |
| 87 void TranslateCellularDevice(); | 87 void TranslateCellularDevice(); |
| 88 void TranslateNetworkWithState(); | 88 void TranslateNetworkWithState(); |
| 89 void TranslateIPConfig(); | 89 void TranslateIPConfig(); |
| 90 void TranslateSavedOrStaticIPConfig(); | 90 void TranslateSavedOrStaticIPConfig(); |
| 91 void TranslateSavedIPConfig(); | 91 void TranslateSavedIPConfig(); |
| 92 void TranslateStaticIPConfig(); | 92 void TranslateStaticIPConfig(); |
| 93 void TranslateEap(); |
| 93 | 94 |
| 94 // Creates an ONC object from |dictionary| according to the signature | 95 // Creates an ONC object from |dictionary| according to the signature |
| 95 // associated to |onc_field_name| and adds it to |onc_object_| at | 96 // associated to |onc_field_name| and adds it to |onc_object_| at |
| 96 // |onc_field_name|. | 97 // |onc_field_name|. |
| 97 void TranslateAndAddNestedObject(const std::string& onc_field_name, | 98 void TranslateAndAddNestedObject(const std::string& onc_field_name, |
| 98 const base::DictionaryValue& dictionary); | 99 const base::DictionaryValue& dictionary); |
| 99 | 100 |
| 100 // Creates an ONC object from |shill_dictionary_| according to the signature | 101 // Creates an ONC object from |shill_dictionary_| according to the signature |
| 101 // associated to |onc_field_name| and adds it to |onc_object_| at | 102 // associated to |onc_field_name| and adds it to |onc_object_| at |
| 102 // |onc_field_name|. | 103 // |onc_field_name|. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (field_translation_table_ == kCellularDeviceTable) | 174 if (field_translation_table_ == kCellularDeviceTable) |
| 174 TranslateCellularDevice(); | 175 TranslateCellularDevice(); |
| 175 else | 176 else |
| 176 TranslateCellularWithState(); | 177 TranslateCellularWithState(); |
| 177 } else if (onc_signature_ == &kIPConfigSignature) { | 178 } else if (onc_signature_ == &kIPConfigSignature) { |
| 178 TranslateIPConfig(); | 179 TranslateIPConfig(); |
| 179 } else if (onc_signature_ == &kSavedIPConfigSignature) { | 180 } else if (onc_signature_ == &kSavedIPConfigSignature) { |
| 180 TranslateSavedIPConfig(); | 181 TranslateSavedIPConfig(); |
| 181 } else if (onc_signature_ == &kStaticIPConfigSignature) { | 182 } else if (onc_signature_ == &kStaticIPConfigSignature) { |
| 182 TranslateStaticIPConfig(); | 183 TranslateStaticIPConfig(); |
| 184 } else if (onc_signature_ == &kEAPSignature) { |
| 185 TranslateEap(); |
| 183 } else { | 186 } else { |
| 184 CopyPropertiesAccordingToSignature(); | 187 CopyPropertiesAccordingToSignature(); |
| 185 } | 188 } |
| 186 return std::move(onc_object_); | 189 return std::move(onc_object_); |
| 187 } | 190 } |
| 188 | 191 |
| 189 void ShillToONCTranslator::TranslateEthernet() { | 192 void ShillToONCTranslator::TranslateEthernet() { |
| 190 std::string shill_network_type; | 193 std::string shill_network_type; |
| 191 shill_dictionary_->GetStringWithoutPathExpansion(shill::kTypeProperty, | 194 shill_dictionary_->GetStringWithoutPathExpansion(shill::kTypeProperty, |
| 192 &shill_network_type); | 195 &shill_network_type); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 626 } |
| 624 | 627 |
| 625 void ShillToONCTranslator::TranslateSavedIPConfig() { | 628 void ShillToONCTranslator::TranslateSavedIPConfig() { |
| 626 TranslateSavedOrStaticIPConfig(); | 629 TranslateSavedOrStaticIPConfig(); |
| 627 } | 630 } |
| 628 | 631 |
| 629 void ShillToONCTranslator::TranslateStaticIPConfig() { | 632 void ShillToONCTranslator::TranslateStaticIPConfig() { |
| 630 TranslateSavedOrStaticIPConfig(); | 633 TranslateSavedOrStaticIPConfig(); |
| 631 } | 634 } |
| 632 | 635 |
| 636 void ShillToONCTranslator::TranslateEap() { |
| 637 CopyPropertiesAccordingToSignature(); |
| 638 |
| 639 // Translate EAP Outer and Inner values. |
| 640 TranslateWithTableAndSet(shill::kEapMethodProperty, kEAPOuterTable, |
| 641 ::onc::eap::kOuter); |
| 642 TranslateWithTableAndSet(shill::kEapPhase2AuthProperty, kEAP_TTLS_InnerTable, |
| 643 ::onc::eap::kInner); |
| 644 } |
| 645 |
| 633 void ShillToONCTranslator::TranslateAndAddNestedObject( | 646 void ShillToONCTranslator::TranslateAndAddNestedObject( |
| 634 const std::string& onc_field_name) { | 647 const std::string& onc_field_name) { |
| 635 TranslateAndAddNestedObject(onc_field_name, *shill_dictionary_); | 648 TranslateAndAddNestedObject(onc_field_name, *shill_dictionary_); |
| 636 } | 649 } |
| 637 | 650 |
| 638 void ShillToONCTranslator::TranslateAndAddNestedObject( | 651 void ShillToONCTranslator::TranslateAndAddNestedObject( |
| 639 const std::string& onc_field_name, | 652 const std::string& onc_field_name, |
| 640 const base::DictionaryValue& dictionary) { | 653 const base::DictionaryValue& dictionary) { |
| 641 const OncFieldSignature* field_signature = | 654 const OncFieldSignature* field_signature = |
| 642 GetFieldSignature(*onc_signature_, onc_field_name); | 655 GetFieldSignature(*onc_signature_, onc_field_name); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 const NetworkState* network_state) { | 791 const NetworkState* network_state) { |
| 779 CHECK(onc_signature != NULL); | 792 CHECK(onc_signature != NULL); |
| 780 | 793 |
| 781 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, | 794 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, |
| 782 network_state); | 795 network_state); |
| 783 return translator.CreateTranslatedONCObject(); | 796 return translator.CreateTranslatedONCObject(); |
| 784 } | 797 } |
| 785 | 798 |
| 786 } // namespace onc | 799 } // namespace onc |
| 787 } // namespace chromeos | 800 } // namespace chromeos |
| OLD | NEW |