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

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

Issue 1019033002: Add an ONC property for the third-party VPN provider extension ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 // Translates the associated Shill dictionary and creates an ONC object of the 72 // Translates the associated Shill dictionary and creates an ONC object of the
73 // given signature. 73 // given signature.
74 scoped_ptr<base::DictionaryValue> CreateTranslatedONCObject(); 74 scoped_ptr<base::DictionaryValue> CreateTranslatedONCObject();
75 75
76 private: 76 private:
77 void TranslateEthernet(); 77 void TranslateEthernet();
78 void TranslateOpenVPN(); 78 void TranslateOpenVPN();
79 void TranslateIPsec(); 79 void TranslateIPsec();
80 void TranslateThirdPartyVPN();
80 void TranslateVPN(); 81 void TranslateVPN();
81 void TranslateWiFiWithState(); 82 void TranslateWiFiWithState();
82 void TranslateWiMAXWithState(); 83 void TranslateWiMAXWithState();
83 void TranslateCellularWithState(); 84 void TranslateCellularWithState();
84 void TranslateCellularDevice(); 85 void TranslateCellularDevice();
85 void TranslateNetworkWithState(); 86 void TranslateNetworkWithState();
86 void TranslateIPConfig(); 87 void TranslateIPConfig();
87 void TranslateSavedOrStaticIPConfig(); 88 void TranslateSavedOrStaticIPConfig();
88 void TranslateSavedIPConfig(); 89 void TranslateSavedIPConfig();
89 void TranslateStaticIPConfig(); 90 void TranslateStaticIPConfig();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (onc_signature_ == &kNetworkWithStateSignature) { 153 if (onc_signature_ == &kNetworkWithStateSignature) {
153 TranslateNetworkWithState(); 154 TranslateNetworkWithState();
154 } else if (onc_signature_ == &kEthernetSignature) { 155 } else if (onc_signature_ == &kEthernetSignature) {
155 TranslateEthernet(); 156 TranslateEthernet();
156 } else if (onc_signature_ == &kVPNSignature) { 157 } else if (onc_signature_ == &kVPNSignature) {
157 TranslateVPN(); 158 TranslateVPN();
158 } else if (onc_signature_ == &kOpenVPNSignature) { 159 } else if (onc_signature_ == &kOpenVPNSignature) {
159 TranslateOpenVPN(); 160 TranslateOpenVPN();
160 } else if (onc_signature_ == &kIPsecSignature) { 161 } else if (onc_signature_ == &kIPsecSignature) {
161 TranslateIPsec(); 162 TranslateIPsec();
163 } else if (onc_signature_ == &kThirdPartyVPNSignature) {
164 TranslateThirdPartyVPN();
162 } else if (onc_signature_ == &kWiFiWithStateSignature) { 165 } else if (onc_signature_ == &kWiFiWithStateSignature) {
163 TranslateWiFiWithState(); 166 TranslateWiFiWithState();
164 } else if (onc_signature_ == &kWiMAXWithStateSignature) { 167 } else if (onc_signature_ == &kWiMAXWithStateSignature) {
165 TranslateWiMAXWithState(); 168 TranslateWiMAXWithState();
166 } else if (onc_signature_ == &kCellularWithStateSignature) { 169 } else if (onc_signature_ == &kCellularWithStateSignature) {
167 if (field_translation_table_ == kCellularDeviceTable) 170 if (field_translation_table_ == kCellularDeviceTable)
168 TranslateCellularDevice(); 171 TranslateCellularDevice();
169 else 172 else
170 TranslateCellularWithState(); 173 TranslateCellularWithState();
171 } else if (onc_signature_ == &kIPConfigSignature) { 174 } else if (onc_signature_ == &kIPConfigSignature) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 TranslateAndAddNestedObject(::onc::ipsec::kXAUTH); 262 TranslateAndAddNestedObject(::onc::ipsec::kXAUTH);
260 std::string client_cert_id; 263 std::string client_cert_id;
261 shill_dictionary_->GetStringWithoutPathExpansion( 264 shill_dictionary_->GetStringWithoutPathExpansion(
262 shill::kL2tpIpsecClientCertIdProperty, &client_cert_id); 265 shill::kL2tpIpsecClientCertIdProperty, &client_cert_id);
263 std::string authentication_type = 266 std::string authentication_type =
264 client_cert_id.empty() ? ::onc::ipsec::kPSK : ::onc::ipsec::kCert; 267 client_cert_id.empty() ? ::onc::ipsec::kPSK : ::onc::ipsec::kCert;
265 onc_object_->SetStringWithoutPathExpansion(::onc::ipsec::kAuthenticationType, 268 onc_object_->SetStringWithoutPathExpansion(::onc::ipsec::kAuthenticationType,
266 authentication_type); 269 authentication_type);
267 } 270 }
268 271
272 void ShillToONCTranslator::TranslateThirdPartyVPN() {
273 CopyPropertiesAccordingToSignature();
274
275 std::string shill_extension_id;
pneubeck (no reviews) 2015/03/18 19:35:29 nit: same comment as in the other direction: // F
bartfab (slow) 2015/03/18 20:02:14 Done.
276 shill_dictionary_->GetStringWithoutPathExpansion(shill::kHostProperty,
277 &shill_extension_id);
278 onc_object_->SetStringWithoutPathExpansion(
279 ::onc::third_party_vpn::kExtensionID, shill_extension_id);
280 }
281
269 void ShillToONCTranslator::TranslateVPN() { 282 void ShillToONCTranslator::TranslateVPN() {
270 CopyPropertiesAccordingToSignature(); 283 CopyPropertiesAccordingToSignature();
271 284
272 // Parse Shill Provider dictionary. Note, this may not exist, e.g. if we are 285 // Parse Shill Provider dictionary. Note, this may not exist, e.g. if we are
273 // just translating network state in network_util::TranslateNetworkStateToONC. 286 // just translating network state in network_util::TranslateNetworkStateToONC.
274 const base::DictionaryValue* provider = NULL; 287 const base::DictionaryValue* provider = NULL;
275 if (!shill_dictionary_->GetDictionaryWithoutPathExpansion( 288 if (!shill_dictionary_->GetDictionaryWithoutPathExpansion(
276 shill::kProviderProperty, &provider)) { 289 shill::kProviderProperty, &provider)) {
277 return; 290 return;
278 } 291 }
279 std::string shill_provider_type, onc_provider_type; 292 std::string shill_provider_type, onc_provider_type;
280 provider->GetStringWithoutPathExpansion(shill::kTypeProperty, 293 provider->GetStringWithoutPathExpansion(shill::kTypeProperty,
281 &shill_provider_type); 294 &shill_provider_type);
282 if (!TranslateStringToONC( 295 if (!TranslateStringToONC(
283 kVPNTypeTable, shill_provider_type, &onc_provider_type)) { 296 kVPNTypeTable, shill_provider_type, &onc_provider_type)) {
284 return; 297 return;
285 } 298 }
286 onc_object_->SetStringWithoutPathExpansion(::onc::vpn::kType, 299 onc_object_->SetStringWithoutPathExpansion(::onc::vpn::kType,
287 onc_provider_type); 300 onc_provider_type);
288 std::string provider_host; 301 std::string shill_provider_host;
289 if (provider->GetStringWithoutPathExpansion(shill::kHostProperty, 302 if (onc_provider_type != ::onc::vpn::kThirdPartyVpn &&
290 &provider_host)) { 303 provider->GetStringWithoutPathExpansion(shill::kHostProperty,
304 &shill_provider_host)) {
291 onc_object_->SetStringWithoutPathExpansion(::onc::vpn::kHost, 305 onc_object_->SetStringWithoutPathExpansion(::onc::vpn::kHost,
292 provider_host); 306 shill_provider_host);
293 } 307 }
294 308
295 // Translate the nested dictionary. 309 // Translate the nested dictionary.
296 std::string provider_type_dictionary; 310 std::string provider_type_dictionary;
297 if (onc_provider_type == ::onc::vpn::kTypeL2TP_IPsec) { 311 if (onc_provider_type == ::onc::vpn::kTypeL2TP_IPsec) {
298 TranslateAndAddNestedObject(::onc::vpn::kIPsec, *provider); 312 TranslateAndAddNestedObject(::onc::vpn::kIPsec, *provider);
299 TranslateAndAddNestedObject(::onc::vpn::kL2TP, *provider); 313 TranslateAndAddNestedObject(::onc::vpn::kL2TP, *provider);
300 provider_type_dictionary = ::onc::vpn::kIPsec; 314 provider_type_dictionary = ::onc::vpn::kIPsec;
301 } else if (onc_provider_type != ::onc::vpn::kThirdPartyVpn) { 315 } else {
302 TranslateAndAddNestedObject(onc_provider_type, *provider); 316 TranslateAndAddNestedObject(onc_provider_type, *provider);
303 provider_type_dictionary = onc_provider_type; 317 provider_type_dictionary = onc_provider_type;
304 } 318 }
305 319
306 bool save_credentials; 320 bool save_credentials;
307 if (shill_dictionary_->GetBooleanWithoutPathExpansion( 321 if (onc_provider_type != ::onc::vpn::kThirdPartyVpn &&
322 shill_dictionary_->GetBooleanWithoutPathExpansion(
308 shill::kSaveCredentialsProperty, &save_credentials)) { 323 shill::kSaveCredentialsProperty, &save_credentials)) {
309 SetNestedOncValue(provider_type_dictionary, 324 SetNestedOncValue(provider_type_dictionary,
310 ::onc::vpn::kSaveCredentials, 325 ::onc::vpn::kSaveCredentials,
311 base::FundamentalValue(save_credentials)); 326 base::FundamentalValue(save_credentials));
312 } 327 }
313 } 328 }
314 329
315 void ShillToONCTranslator::TranslateWiFiWithState() { 330 void ShillToONCTranslator::TranslateWiFiWithState() {
316 TranslateWithTableAndSet(shill::kSecurityClassProperty, 331 TranslateWithTableAndSet(shill::kSecurityClassProperty,
317 kWiFiSecurityTable, 332 kWiFiSecurityTable,
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 ::onc::ONCSource onc_source, 729 ::onc::ONCSource onc_source,
715 const OncValueSignature* onc_signature) { 730 const OncValueSignature* onc_signature) {
716 CHECK(onc_signature != NULL); 731 CHECK(onc_signature != NULL);
717 732
718 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature); 733 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature);
719 return translator.CreateTranslatedONCObject(); 734 return translator.CreateTranslatedONCObject();
720 } 735 }
721 736
722 } // namespace onc 737 } // namespace onc
723 } // namespace chromeos 738 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698