Index: chrome/browser/chromeos/cros/network_property_ui_data.cc |
diff --git a/chrome/browser/chromeos/cros/network_ui_data.cc b/chrome/browser/chromeos/cros/network_property_ui_data.cc |
similarity index 36% |
rename from chrome/browser/chromeos/cros/network_ui_data.cc |
rename to chrome/browser/chromeos/cros/network_property_ui_data.cc |
index 55dd4f2a6841bac0ec790e02dc484f8246b2b6d4..6c98f80a28ef857fda15cd11769a997d0e1fac6e 100644 |
--- a/chrome/browser/chromeos/cros/network_ui_data.cc |
+++ b/chrome/browser/chromeos/cros/network_property_ui_data.cc |
@@ -2,106 +2,17 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/chromeos/cros/network_ui_data.h" |
+#include "chrome/browser/chromeos/cros/network_property_ui_data.h" |
-#include "base/logging.h" |
-#include "chrome/browser/chromeos/cros/network_library.h" |
+#include "base/values.h" |
+#include "chromeos/network/network_ui_data.h" |
namespace chromeos { |
-// Top-level UI data dictionary keys. |
-const char NetworkUIData::kKeyONCSource[] = "onc_source"; |
-const char NetworkUIData::kKeyCertificatePattern[] = "certificate_pattern"; |
-const char NetworkUIData::kKeyCertificateType[] = "certificate_type"; |
- |
-// Property names for per-property data stored under |kKeyProperties|. |
-const EnumMapper<onc::ONCSource>::Pair |
- NetworkUIData::kONCSourceTable[] = { |
- { "user_import", onc::ONC_SOURCE_USER_IMPORT }, |
- { "device_policy", onc::ONC_SOURCE_DEVICE_POLICY }, |
- { "user_policy", onc::ONC_SOURCE_USER_POLICY }, |
-}; |
- |
-// Property names for per-property data stored under |kKeyProperties|. |
-const EnumMapper<ClientCertType>::Pair |
- NetworkUIData::kClientCertTable[] = { |
- { "none", CLIENT_CERT_TYPE_NONE }, |
- { "pattern", CLIENT_CERT_TYPE_PATTERN }, |
- { "ref", CLIENT_CERT_TYPE_REF }, |
-}; |
- |
// Property names for the per-property dictionary. |
const char NetworkPropertyUIData::kKeyController[] = "controller"; |
const char NetworkPropertyUIData::kKeyDefaultValue[] = "default_value"; |
-NetworkUIData::NetworkUIData() |
- : onc_source_(onc::ONC_SOURCE_NONE), |
- certificate_type_(CLIENT_CERT_TYPE_NONE) { |
-} |
- |
-NetworkUIData::NetworkUIData(const DictionaryValue& dict) { |
- std::string source; |
- if (dict.GetString(kKeyONCSource, &source)) { |
- onc_source_ = GetONCSourceMapper().Get(source); |
- } else { |
- onc_source_ = onc::ONC_SOURCE_NONE; |
- } |
- const DictionaryValue* cert_dict = NULL; |
- if (dict.GetDictionary(kKeyCertificatePattern, &cert_dict) && cert_dict) |
- certificate_pattern_.CopyFromDictionary(*cert_dict); |
- std::string type_string; |
- if (dict.GetString(kKeyCertificateType, &type_string)) { |
- certificate_type_ = GetClientCertMapper().Get(type_string); |
- } else { |
- certificate_type_ = CLIENT_CERT_TYPE_NONE; |
- } |
- DCHECK(certificate_type_ != CLIENT_CERT_TYPE_PATTERN || |
- (certificate_type_ == CLIENT_CERT_TYPE_PATTERN && |
- !certificate_pattern_.Empty())); |
-} |
- |
-NetworkUIData::~NetworkUIData() { |
-} |
- |
-void NetworkUIData::FillDictionary(base::DictionaryValue* dict) const { |
- dict->Clear(); |
- |
- std::string source_string(GetONCSourceMapper().GetKey(onc_source_)); |
- if (!source_string.empty()) |
- dict->SetString(kKeyONCSource, source_string); |
- std::string type_string(GetClientCertMapper().GetKey(certificate_type_)); |
- switch (certificate_type_) { |
- case CLIENT_CERT_TYPE_REF: |
- dict->SetString(kKeyCertificateType, "ref"); |
- break; |
- case CLIENT_CERT_TYPE_PATTERN: |
- dict->SetString(kKeyCertificateType, "pattern"); |
- if (!certificate_pattern_.Empty()) { |
- dict->Set(kKeyCertificatePattern, |
- certificate_pattern_.CreateAsDictionary()); |
- } |
- case CLIENT_CERT_TYPE_NONE: |
- default: |
- break; |
- } |
-} |
- |
-// static |
-EnumMapper<onc::ONCSource>& NetworkUIData::GetONCSourceMapper() { |
- CR_DEFINE_STATIC_LOCAL(EnumMapper<onc::ONCSource>, mapper, |
- (kONCSourceTable, arraysize(kONCSourceTable), |
- onc::ONC_SOURCE_NONE)); |
- return mapper; |
-} |
- |
-// static |
-EnumMapper<ClientCertType>& NetworkUIData::GetClientCertMapper() { |
- CR_DEFINE_STATIC_LOCAL(EnumMapper<ClientCertType>, mapper, |
- (kClientCertTable, arraysize(kClientCertTable), |
- CLIENT_CERT_TYPE_NONE)); |
- return mapper; |
-} |
- |
NetworkPropertyUIData::NetworkPropertyUIData() |
: controller_(CONTROLLER_USER) { |
} |