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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 // SaveCredentials needs special handling when translating from Shill -> ONC | 212 // SaveCredentials needs special handling when translating from Shill -> ONC |
213 // so handle it explicitly here. | 213 // so handle it explicitly here. |
214 CopyFieldFromONCToShill(::onc::vpn::kSaveCredentials, | 214 CopyFieldFromONCToShill(::onc::vpn::kSaveCredentials, |
215 shill::kSaveCredentialsProperty); | 215 shill::kSaveCredentialsProperty); |
216 } | 216 } |
217 | 217 |
218 void LocalTranslator::TranslateVPN() { | 218 void LocalTranslator::TranslateVPN() { |
219 CopyFieldFromONCToShill(::onc::vpn::kHost, shill::kProviderHostProperty); | 219 CopyFieldFromONCToShill(::onc::vpn::kHost, shill::kProviderHostProperty); |
220 std::string type; | 220 std::string type; |
221 onc_object_->GetStringWithoutPathExpansion(::onc::vpn::kType, &type); | 221 if (onc_object_->GetStringWithoutPathExpansion(::onc::vpn::kType, &type)) |
222 TranslateWithTableAndSet(type, kVPNTypeTable, shill::kProviderTypeProperty); | 222 TranslateWithTableAndSet(type, kVPNTypeTable, shill::kProviderTypeProperty); |
223 | 223 |
224 CopyFieldsAccordingToSignature(); | 224 CopyFieldsAccordingToSignature(); |
225 } | 225 } |
226 | 226 |
227 void LocalTranslator::TranslateWiFi() { | 227 void LocalTranslator::TranslateWiFi() { |
228 std::string security; | 228 std::string security; |
229 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSecurity, &security); | 229 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSecurity, &security); |
230 TranslateWithTableAndSet(security, kWiFiSecurityTable, | 230 TranslateWithTableAndSet(security, kWiFiSecurityTable, |
231 shill::kSecurityProperty); | 231 shill::kSecurityProperty); |
232 | 232 |
233 std::string ssid; | 233 std::string ssid; |
234 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid); | 234 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid); |
235 shill_property_util::SetSSID(ssid, shill_dictionary_); | 235 if (!ssid.empty()) |
| 236 shill_property_util::SetSSID(ssid, shill_dictionary_); |
236 | 237 |
237 // We currently only support managed and no adhoc networks. | 238 // We currently only support managed and no adhoc networks. |
238 shill_dictionary_->SetStringWithoutPathExpansion(shill::kModeProperty, | 239 shill_dictionary_->SetStringWithoutPathExpansion(shill::kModeProperty, |
239 shill::kModeManaged); | 240 shill::kModeManaged); |
240 | 241 |
241 bool allow_gateway_arp_polling; | 242 bool allow_gateway_arp_polling; |
242 if (onc_object_->GetBooleanWithoutPathExpansion( | 243 if (onc_object_->GetBooleanWithoutPathExpansion( |
243 ::onc::wifi::kAllowGatewayARPPolling, &allow_gateway_arp_polling)) { | 244 ::onc::wifi::kAllowGatewayARPPolling, &allow_gateway_arp_polling)) { |
244 shill_dictionary_->SetBooleanWithoutPathExpansion( | 245 shill_dictionary_->SetBooleanWithoutPathExpansion( |
245 shill::kLinkMonitorDisableProperty, !allow_gateway_arp_polling); | 246 shill::kLinkMonitorDisableProperty, !allow_gateway_arp_polling); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 const OncValueSignature* onc_signature, | 402 const OncValueSignature* onc_signature, |
402 const base::DictionaryValue& onc_object) { | 403 const base::DictionaryValue& onc_object) { |
403 CHECK(onc_signature != NULL); | 404 CHECK(onc_signature != NULL); |
404 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 405 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
405 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 406 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
406 return shill_dictionary.Pass(); | 407 return shill_dictionary.Pass(); |
407 } | 408 } |
408 | 409 |
409 } // namespace onc | 410 } // namespace onc |
410 } // namespace chromeos | 411 } // namespace chromeos |
OLD | NEW |