| 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 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 void LocalTranslator::TranslateIPsec() { | 181 void LocalTranslator::TranslateIPsec() { |
| 182 CopyFieldsAccordingToSignature(); | 182 CopyFieldsAccordingToSignature(); |
| 183 | 183 |
| 184 // SaveCredentials needs special handling when translating from Shill -> ONC | 184 // SaveCredentials needs special handling when translating from Shill -> ONC |
| 185 // so handle it explicitly here. | 185 // so handle it explicitly here. |
| 186 CopyFieldFromONCToShill(::onc::vpn::kSaveCredentials, | 186 CopyFieldFromONCToShill(::onc::vpn::kSaveCredentials, |
| 187 shill::kSaveCredentialsProperty); | 187 shill::kSaveCredentialsProperty); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void LocalTranslator::TranslateVPN() { | 190 void LocalTranslator::TranslateVPN() { |
| 191 CopyFieldFromONCToShill(::onc::vpn::kHost, shill::kProviderHostProperty); | 191 std::string onc_type; |
| 192 std::string type; | 192 if (onc_object_->GetStringWithoutPathExpansion(::onc::vpn::kType, |
| 193 if (onc_object_->GetStringWithoutPathExpansion(::onc::vpn::kType, &type)) | 193 &onc_type)) { |
| 194 TranslateWithTableAndSet(type, kVPNTypeTable, shill::kProviderTypeProperty); | 194 TranslateWithTableAndSet(onc_type, kVPNTypeTable, |
| 195 shill::kProviderTypeProperty); |
| 196 } |
| 197 if (onc_type == ::onc::vpn::kThirdPartyVpn) { |
| 198 // For third-party VPNs, |shill::kProviderHostProperty| is used to store the |
| 199 // provider's extension ID. |
| 200 const base::DictionaryValue* onc_third_party_vpn = nullptr; |
| 201 onc_object_->GetDictionaryWithoutPathExpansion(::onc::vpn::kThirdPartyVpn, |
| 202 &onc_third_party_vpn); |
| 203 std::string onc_extension_id; |
| 204 if (onc_third_party_vpn && |
| 205 onc_third_party_vpn->GetStringWithoutPathExpansion( |
| 206 ::onc::third_party_vpn::kExtensionID, &onc_extension_id)) { |
| 207 shill_dictionary_->SetStringWithoutPathExpansion( |
| 208 shill::kProviderHostProperty, onc_extension_id); |
| 209 } |
| 210 } else { |
| 211 CopyFieldFromONCToShill(::onc::vpn::kHost, shill::kProviderHostProperty); |
| 212 } |
| 195 | 213 |
| 196 CopyFieldsAccordingToSignature(); | 214 CopyFieldsAccordingToSignature(); |
| 197 } | 215 } |
| 198 | 216 |
| 199 void LocalTranslator::TranslateWiFi() { | 217 void LocalTranslator::TranslateWiFi() { |
| 200 std::string security; | 218 std::string security; |
| 201 if (onc_object_->GetStringWithoutPathExpansion( | 219 if (onc_object_->GetStringWithoutPathExpansion( |
| 202 ::onc::wifi::kSecurity, &security)) { | 220 ::onc::wifi::kSecurity, &security)) { |
| 203 TranslateWithTableAndSet(security, kWiFiSecurityTable, | 221 TranslateWithTableAndSet(security, kWiFiSecurityTable, |
| 204 shill::kSecurityClassProperty); | 222 shill::kSecurityClassProperty); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 const OncValueSignature* onc_signature, | 403 const OncValueSignature* onc_signature, |
| 386 const base::DictionaryValue& onc_object) { | 404 const base::DictionaryValue& onc_object) { |
| 387 CHECK(onc_signature != NULL); | 405 CHECK(onc_signature != NULL); |
| 388 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 406 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
| 389 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 407 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 390 return shill_dictionary.Pass(); | 408 return shill_dictionary.Pass(); |
| 391 } | 409 } |
| 392 | 410 |
| 393 } // namespace onc | 411 } // namespace onc |
| 394 } // namespace chromeos | 412 } // namespace chromeos |
| OLD | NEW |