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

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

Issue 11664005: Extending the translation from ONC to Shill. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased. Created 7 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 #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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 onc_object_->SetWithoutPathExpansion(onc_field_name, nested_object.release()); 172 onc_object_->SetWithoutPathExpansion(onc_field_name, nested_object.release());
173 } 173 }
174 174
175 void ShillToONCTranslator::TranslateNetworkConfiguration() { 175 void ShillToONCTranslator::TranslateNetworkConfiguration() {
176 TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable, kType); 176 TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable, kType);
177 CopyPropertiesAccordingToSignature(); 177 CopyPropertiesAccordingToSignature();
178 178
179 std::string network_type; 179 std::string network_type;
180 if (onc_object_->GetStringWithoutPathExpansion(kType, &network_type)) 180 if (onc_object_->GetStringWithoutPathExpansion(kType, &network_type))
181 TranslateAndAddNestedObject(network_type); 181 TranslateAndAddNestedObject(network_type);
182
183 if (network_type == kVPN) {
184 std::string name;
185 shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kNameProperty,
186 &name);
187 onc_object_->SetStringWithoutPathExpansion(kName, name);
188 }
182 } 189 }
183 190
184 void ShillToONCTranslator::CopyPropertiesAccordingToSignature() { 191 void ShillToONCTranslator::CopyPropertiesAccordingToSignature() {
185 for (const OncFieldSignature* field_signature = onc_signature_->fields; 192 for (const OncFieldSignature* field_signature = onc_signature_->fields;
186 field_signature->onc_field_name != NULL; ++field_signature) { 193 field_signature->onc_field_name != NULL; ++field_signature) {
187 const base::Value* shill_value; 194 const base::Value* shill_value;
188 if (field_signature->shill_property_name == NULL || 195 if (field_signature->shill_property_name == NULL ||
189 !shill_dictionary_->GetWithoutPathExpansion( 196 !shill_dictionary_->GetWithoutPathExpansion(
190 field_signature->shill_property_name, &shill_value)) { 197 field_signature->shill_property_name, &shill_value)) {
191 continue; 198 continue;
(...skipping 30 matching lines...) Expand all
222 const base::DictionaryValue& shill_dictionary, 229 const base::DictionaryValue& shill_dictionary,
223 const OncValueSignature* onc_signature) { 230 const OncValueSignature* onc_signature) {
224 CHECK(onc_signature != NULL); 231 CHECK(onc_signature != NULL);
225 232
226 ShillToONCTranslator translator(shill_dictionary, *onc_signature); 233 ShillToONCTranslator translator(shill_dictionary, *onc_signature);
227 return translator.CreateTranslatedONCObject(); 234 return translator.CreateTranslatedONCObject();
228 } 235 }
229 236
230 } // namespace onc 237 } // namespace onc
231 } // namespace chromeos 238 } // 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