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

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

Issue 11414101: This adds ManagedNetworkConfigurationHandler first pass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload after merge Created 7 years, 10 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 | Annotate | Revision Log
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 #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"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 std::string bssid; 184 std::string bssid;
185 if (shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kWifiBSsid, 185 if (shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kWifiBSsid,
186 &bssid)) { 186 &bssid)) {
187 onc_object_->SetStringWithoutPathExpansion(wifi::kBSSID, bssid); 187 onc_object_->SetStringWithoutPathExpansion(wifi::kBSSID, bssid);
188 } 188 }
189 } 189 }
190 190
191 void ShillToONCTranslator::TranslateAndAddNestedObject( 191 void ShillToONCTranslator::TranslateAndAddNestedObject(
192 const std::string& onc_field_name) { 192 const std::string& onc_field_name) {
193 const OncFieldSignature* field_signature = 193 const OncFieldSignature* field_signature =
194 GetFieldSignature(*onc_signature_, onc_field_name); 194 GetOncFieldSignature(*onc_signature_, onc_field_name);
195 ShillToONCTranslator nested_translator(*shill_dictionary_, 195 ShillToONCTranslator nested_translator(*shill_dictionary_,
196 *field_signature->value_signature); 196 *field_signature->value_signature);
197 scoped_ptr<base::DictionaryValue> nested_object = 197 scoped_ptr<base::DictionaryValue> nested_object =
198 nested_translator.CreateTranslatedONCObject(); 198 nested_translator.CreateTranslatedONCObject();
199 onc_object_->SetWithoutPathExpansion(onc_field_name, nested_object.release()); 199 onc_object_->SetWithoutPathExpansion(onc_field_name, nested_object.release());
200 } 200 }
201 201
202 void ShillToONCTranslator::TranslateNetworkConfiguration() { 202 void ShillToONCTranslator::TranslateNetworkConfiguration() {
203 TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable, 203 TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable,
204 network_config::kType); 204 network_config::kType);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 if (TranslateStringToONC(table, shill_value, &onc_value)) { 274 if (TranslateStringToONC(table, shill_value, &onc_value)) {
275 onc_object_->SetStringWithoutPathExpansion(onc_field_name, onc_value); 275 onc_object_->SetStringWithoutPathExpansion(onc_field_name, onc_value);
276 return; 276 return;
277 } 277 }
278 LOG(ERROR) << "Shill property '" << shill_property_name << "' with value " 278 LOG(ERROR) << "Shill property '" << shill_property_name << "' with value "
279 << shill_value << " couldn't be translated to ONC"; 279 << shill_value << " couldn't be translated to ONC";
280 } 280 }
281 281
282 } // namespace 282 } // namespace
283 283
284 std::vector<std::string> TranslateShillPropertyNamesToONC(
285 const std::vector<std::string>& shill_names,
286 const OncValueSignature* signature) {
287 std::vector<std::string> result;
288 for (std::vector<std::string>::const_iterator iter = shill_names.begin();
289 iter != shill_names.end(); ++iter) {
290 const OncFieldSignature* field_signature =
291 GetShillFieldSignature(*signature, *iter);
292 DCHECK(field_signature != NULL);
293 if (field_signature == NULL || field_signature->onc_field_name == NULL)
294 continue;
295 result.push_back(field_signature->onc_field_name);
296 }
297 return result;
298 }
299
284 scoped_ptr<base::DictionaryValue> TranslateShillServiceToONCPart( 300 scoped_ptr<base::DictionaryValue> TranslateShillServiceToONCPart(
285 const base::DictionaryValue& shill_dictionary, 301 const base::DictionaryValue& shill_dictionary,
286 const OncValueSignature* onc_signature) { 302 const OncValueSignature* onc_signature) {
287 CHECK(onc_signature != NULL); 303 CHECK(onc_signature != NULL);
288 304
289 ShillToONCTranslator translator(shill_dictionary, *onc_signature); 305 ShillToONCTranslator translator(shill_dictionary, *onc_signature);
290 return translator.CreateTranslatedONCObject(); 306 return translator.CreateTranslatedONCObject();
291 } 307 }
292 308
293 } // namespace onc 309 } // namespace onc
294 } // namespace chromeos 310 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/onc/onc_translator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698