Chromium Code Reviews| Index: chrome/browser/chromeos/network_settings/onc_signature.cc |
| diff --git a/chrome/browser/chromeos/network_settings/onc_signature.cc b/chrome/browser/chromeos/network_settings/onc_signature.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc64bdebf3333717ba508993689f91d74bcabfe1 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/network_settings/onc_signature.cc |
| @@ -0,0 +1,197 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/network_settings/onc_signature.h" |
| + |
| +#include "chrome/browser/chromeos/cros/onc_constants.h" |
| +#include "third_party/cros_system_api/dbus/service_constants.h" |
| + |
| +namespace chromeos { |
| +namespace onc { |
| +namespace { |
| + |
| +const base::Value::Type TYPE_DICTIONARY = base::Value::TYPE_DICTIONARY; |
|
stevenjb
2012/10/11 19:54:00
using base::Value
pneubeck (no reviews)
2012/10/15 13:57:44
Would be nice, but unfortunately doesn't work.
stevenjb
2012/10/15 17:23:54
You still have to use Value::TYPE_DICTIONARY, but
pneubeck (no reviews)
2012/10/30 08:42:04
Done.
|
| +const base::Value::Type TYPE_LIST = base::Value::TYPE_LIST; |
| + |
| +const OncValueSignature bool_signature = { |
| + base::Value::TYPE_BOOLEAN, NULL |
| +}; |
| +const OncValueSignature string_signature = { |
| + base::Value::TYPE_STRING, NULL |
| +}; |
| +const OncValueSignature integer_signature = { |
| + base::Value::TYPE_INTEGER, NULL |
| +}; |
| +// TODO: only temporary, remove this when all dictionaries are fully described |
| +const OncValueSignature dictionary_signature = { |
| + base::Value::TYPE_DICTIONARY, NULL |
| +}; |
| +const OncValueSignature string_list_signature = { |
| + base::Value::TYPE_LIST, NULL, &string_signature |
| +}; |
| +const OncValueSignature ipconfig_list_signature = { |
| + base::Value::TYPE_LIST, NULL, &ipconfig_signature |
| +}; |
| + |
| +OncFieldSignature certificate_pattern_fields[] = { |
| + { onc::kRecommended, NULL, &recommended_signature }, |
| + { onc::certificate::kIssuerCARef, NULL, &string_list_signature }, |
| + { onc::certificate::kIssuer, NULL, &dictionary_signature }, |
| + { onc::certificate::kSubject, NULL, &dictionary_signature }, |
| + { onc::certificate::kEnrollmentURI, NULL, &string_list_signature }, |
| + { NULL } |
| +}; |
| + |
| +const OncFieldSignature ipsec_fields[] = { |
| + { onc::kRecommended, NULL, &recommended_signature }, |
| + { onc::vpn::kAuthenticationType, flimflam::kL2tpIpsecAuthenticationType, |
| + &string_signature }, |
| + { onc::vpn::kClientCertPattern, NULL, &certificate_pattern_signature }, |
| + { onc::vpn::kClientCertRef, NULL, &string_signature }, |
| + { onc::vpn::kClientCertType, NULL, &string_signature }, |
| + { onc::vpn::kEAP, NULL, &dictionary_signature }, |
| + { onc::vpn::kGroup, flimflam::kL2tpIpsecGroupNameProperty, |
| + &string_signature }, |
| + { onc::vpn::kIKEVersion, flimflam::kL2tpIpsecIkeVersion, &integer_signature }, |
| + { onc::vpn::kPSK, flimflam::kL2tpIpsecPskProperty, &string_signature }, |
| + { onc::vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty, |
| + &bool_signature }, |
| + { onc::vpn::kServerCARef, flimflam::kL2tpIpsecCaCertNssProperty, |
| + &string_signature }, |
| + { onc::vpn::kXAUTH, NULL, &dictionary_signature }, |
| + { NULL } |
| +}; |
| + |
| +OncFieldSignature openvpn_fields[] = { |
| + { onc::kRecommended, NULL, &recommended_signature }, |
| + { onc::vpn::kAuth, flimflam::kOpenVPNAuthProperty, &string_signature }, |
| + { onc::vpn::kAuthRetry, flimflam::kOpenVPNAuthRetryProperty, |
| + &string_signature }, |
| + { onc::vpn::kAuthNoCache, flimflam::kOpenVPNAuthNoCacheProperty, |
| + &bool_signature }, |
| + { onc::vpn::kCipher, flimflam::kOpenVPNCipherProperty, &string_signature }, |
| + { onc::vpn::kClientCertPattern, NULL, &certificate_pattern_signature }, |
| + { onc::vpn::kClientCertRef, NULL, &string_signature }, |
| + { onc::vpn::kClientCertType, NULL, &string_signature }, |
| + { onc::vpn::kCompLZO, flimflam::kOpenVPNCompLZOProperty, &string_signature }, |
| + { onc::vpn::kCompNoAdapt, flimflam::kOpenVPNCompNoAdaptProperty, |
| + &bool_signature }, |
| + { onc::vpn::kKeyDirection, flimflam::kOpenVPNKeyDirectionProperty, |
| + &string_signature }, |
| + { onc::vpn::kNsCertType, flimflam::kOpenVPNNsCertTypeProperty, |
| + &string_signature }, |
| + { onc::vpn::kPassword, flimflam::kOpenVPNPasswordProperty, |
| + &string_signature }, |
| + { onc::vpn::kPort, flimflam::kOpenVPNPortProperty, &integer_signature }, |
| + { onc::vpn::kProto, flimflam::kOpenVPNProtoProperty, &string_signature }, |
| + { onc::vpn::kPushPeerInfo, flimflam::kOpenVPNPushPeerInfoProperty, |
| + &bool_signature }, |
| + { onc::vpn::kRemoteCertEKU, flimflam::kOpenVPNRemoteCertEKUProperty, |
| + &string_signature }, |
| + { onc::vpn::kRemoteCertKU, flimflam::kOpenVPNRemoteCertKUProperty, |
| + &string_list_signature }, |
| + { onc::vpn::kRemoteCertTLS, flimflam::kOpenVPNRemoteCertTLSProperty, |
| + &string_signature }, |
| + { onc::vpn::kRenegSec, flimflam::kOpenVPNRenegSecProperty, |
| + &integer_signature }, |
| + { onc::vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty, |
| + &bool_signature }, |
| + { onc::vpn::kServerCARef, flimflam::kOpenVPNCaCertNSSProperty, |
| + &string_signature }, |
| + { onc::vpn::kServerCertRef, NULL, &string_signature }, |
| + { onc::vpn::kServerPollTimeout, flimflam::kOpenVPNServerPollTimeoutProperty, |
| + &integer_signature }, |
| + { onc::vpn::kShaper, flimflam::kOpenVPNShaperProperty, &integer_signature }, |
| + { onc::vpn::kStaticChallenge, flimflam::kOpenVPNStaticChallengeProperty, |
| + &string_signature }, |
| + { onc::vpn::kTLSAuthContents, flimflam::kOpenVPNTLSAuthContentsProperty, |
| + &string_signature }, |
| + { onc::vpn::kTLSRemote, flimflam::kOpenVPNTLSRemoteProperty, |
| + &string_signature }, |
| + { onc::vpn::kUsername, flimflam::kOpenVPNUserProperty, &string_signature }, |
| + { NULL } |
| +}; |
| + |
| +const OncFieldSignature vpn_fields[] = { |
| + { onc::kRecommended, NULL, &recommended_signature }, |
| + { onc::vpn::kHost, flimflam::kProviderHostProperty, &string_signature }, |
| + { onc::vpn::kIPsec, NULL, &ipsec_signature }, |
| + { onc::vpn::kL2TP, NULL, &dictionary_signature }, |
| + { onc::vpn::kOpenVPN, NULL, &openvpn_signature }, |
| + { onc::vpn::kType, flimflam::kProviderTypeProperty, &string_signature }, |
| + { NULL } |
| +}; |
| + |
| +OncFieldSignature ethernet_fields[] = { |
| + { onc::kRecommended, NULL, &recommended_signature }, |
| + { onc::ethernet::kAuthentication, NULL, &string_signature }, |
| + { onc::ethernet::kEAP, NULL, &eap_signature }, |
| + { NULL } |
| +}; |
| + |
| +const OncFieldSignature ipconfig_fields[] = { |
| + { onc::ipconfig::kType, NULL, &string_signature }, |
| + { onc::ipconfig::kIPAddress, NULL, &string_signature }, |
| + { NULL } |
| +}; |
| + |
| +const OncFieldSignature network_configuration_fields[] = { |
| + { onc::kRecommended, NULL, &recommended_signature }, |
| + { onc::kEthernet, NULL, ðernet_signature }, |
| + { onc::kGUID, flimflam::kGuidProperty, &string_signature }, |
| + { onc::kIPConfigs, NULL, &ipconfig_list_signature }, |
| + { onc::kName, flimflam::kNameProperty, &string_signature }, |
| + { onc::kProxySettings, NULL, &dictionary_signature }, |
| + { onc::kRemove, NULL, &bool_signature }, |
| + { onc::kType, flimflam::kTypeProperty, &string_signature }, |
| + { onc::kVPN, NULL, &vpn_signature }, |
| + { onc::kWiFi, NULL, &dictionary_signature }, |
| + { NULL } |
| +}; |
| + |
| +} // namespace |
| + |
| + |
| +const OncValueSignature recommended_signature = { |
| + TYPE_LIST, NULL, &string_signature |
| +}; |
| +const OncValueSignature eap_signature = { |
| + TYPE_DICTIONARY, NULL |
| +}; |
| +const OncValueSignature certificate_pattern_signature = { |
| + TYPE_DICTIONARY, certificate_pattern_fields, NULL |
| +}; |
| +const OncValueSignature ipsec_signature = { |
| + TYPE_DICTIONARY, ipsec_fields, NULL |
| +}; |
| +const OncValueSignature openvpn_signature = { |
| + TYPE_DICTIONARY, openvpn_fields, NULL |
| +}; |
| +const OncValueSignature vpn_signature = { |
| + TYPE_DICTIONARY, vpn_fields, NULL |
| +}; |
| +const OncValueSignature ethernet_signature = { |
| + TYPE_DICTIONARY, ethernet_fields, NULL |
| +}; |
| +const OncValueSignature ipconfig_signature = { |
| + TYPE_DICTIONARY, ipconfig_fields, NULL |
| +}; |
| +const OncValueSignature network_configuration_signature = { |
| + TYPE_DICTIONARY, network_configuration_fields, NULL |
| +}; |
| + |
| +const OncFieldSignature* OncValueSignature::GetFieldSignature( |
| + const std::string& onc_field_name) const { |
| + if (!fields) |
| + return NULL; |
| + for (const OncFieldSignature* field_signature = fields; |
| + field_signature->onc_field_name != NULL; ++field_signature) { |
| + if (onc_field_name == field_signature->onc_field_name) |
| + return field_signature; |
| + } |
| + return NULL; |
| +} |
| + |
| +} // namespace onc |
| +} // namespace chromeos |