Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: chromeos/network/onc/onc_translator_onc_to_shill.cc

Issue 708563005: Use setProperties for IP Config. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_430113_internet_options_1
Patch Set: Add managed indicator to userNameServers, feedback, fix tests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 CopyFieldFromONCToShill(::onc::vpn::kHost, shill::kProviderHostProperty); 191 CopyFieldFromONCToShill(::onc::vpn::kHost, shill::kProviderHostProperty);
192 std::string type; 192 std::string type;
193 if (onc_object_->GetStringWithoutPathExpansion(::onc::vpn::kType, &type)) 193 if (onc_object_->GetStringWithoutPathExpansion(::onc::vpn::kType, &type))
194 TranslateWithTableAndSet(type, kVPNTypeTable, shill::kProviderTypeProperty); 194 TranslateWithTableAndSet(type, kVPNTypeTable, shill::kProviderTypeProperty);
195 195
196 CopyFieldsAccordingToSignature(); 196 CopyFieldsAccordingToSignature();
197 } 197 }
198 198
199 void LocalTranslator::TranslateWiFi() { 199 void LocalTranslator::TranslateWiFi() {
200 std::string security; 200 std::string security;
201 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSecurity, &security); 201 if (onc_object_->GetStringWithoutPathExpansion(
202 TranslateWithTableAndSet(security, kWiFiSecurityTable, 202 ::onc::wifi::kSecurity, &security)) {
203 shill::kSecurityProperty); 203 TranslateWithTableAndSet(security, kWiFiSecurityTable,
204 shill::kSecurityProperty);
205 }
204 206
205 std::string ssid; 207 std::string ssid;
206 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid); 208 onc_object_->GetStringWithoutPathExpansion(::onc::wifi::kSSID, &ssid);
207 if (!ssid.empty()) 209 if (!ssid.empty())
208 shill_property_util::SetSSID(ssid, shill_dictionary_); 210 shill_property_util::SetSSID(ssid, shill_dictionary_);
209 211
210 // We currently only support managed and no adhoc networks. 212 // We currently only support managed and no adhoc networks.
211 shill_dictionary_->SetStringWithoutPathExpansion(shill::kModeProperty, 213 shill_dictionary_->SetStringWithoutPathExpansion(shill::kModeProperty,
212 shill::kModeManaged); 214 shill::kModeManaged);
213 215
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 std::string shill_value; 331 std::string shill_value;
330 if (TranslateStringToShill(table, onc_value, &shill_value)) { 332 if (TranslateStringToShill(table, onc_value, &shill_value)) {
331 shill_dictionary_->SetStringWithoutPathExpansion(shill_property_name, 333 shill_dictionary_->SetStringWithoutPathExpansion(shill_property_name,
332 shill_value); 334 shill_value);
333 return; 335 return;
334 } 336 }
335 // As we previously validate ONC, this case should never occur. If it still 337 // As we previously validate ONC, this case should never occur. If it still
336 // occurs, we should check here. Otherwise the failure will only show up much 338 // occurs, we should check here. Otherwise the failure will only show up much
337 // later in Shill. 339 // later in Shill.
338 LOG(ERROR) << "Value '" << onc_value 340 LOG(ERROR) << "Value '" << onc_value
339 << "' cannot be translated to Shill property " 341 << "' cannot be translated to Shill property: "
340 << shill_property_name; 342 << shill_property_name;
341 } 343 }
342 344
343 // Iterates recursively over |onc_object| and its |signature|. At each object 345 // Iterates recursively over |onc_object| and its |signature|. At each object
344 // applies the local translation using LocalTranslator::TranslateFields. The 346 // applies the local translation using LocalTranslator::TranslateFields. The
345 // results are written to |shill_dictionary|. 347 // results are written to |shill_dictionary|.
346 void TranslateONCHierarchy(const OncValueSignature& signature, 348 void TranslateONCHierarchy(const OncValueSignature& signature,
347 const base::DictionaryValue& onc_object, 349 const base::DictionaryValue& onc_object,
348 base::DictionaryValue* shill_dictionary) { 350 base::DictionaryValue* shill_dictionary) {
349 base::DictionaryValue* target_shill_dictionary = shill_dictionary; 351 base::DictionaryValue* target_shill_dictionary = shill_dictionary;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 const OncValueSignature* onc_signature, 389 const OncValueSignature* onc_signature,
388 const base::DictionaryValue& onc_object) { 390 const base::DictionaryValue& onc_object) {
389 CHECK(onc_signature != NULL); 391 CHECK(onc_signature != NULL);
390 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); 392 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue);
391 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); 393 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get());
392 return shill_dictionary.Pass(); 394 return shill_dictionary.Pass();
393 } 395 }
394 396
395 } // namespace onc 397 } // namespace onc
396 } // namespace chromeos 398 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698