| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_UI_DATA_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_UI_DATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/values.h" | 12 |
| 13 #include "chrome/browser/chromeos/cros/certificate_pattern.h" | 13 namespace base { |
| 14 #include "chrome/browser/chromeos/cros/enum_mapper.h" | 14 class DictionaryValue; |
| 15 #include "chrome/browser/chromeos/cros/network_constants.h" | 15 class Value; |
| 16 #include "chromeos/network/onc/onc_constants.h" | 16 } |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 class NetworkPropertyUIData; | 20 class NetworkUIData; |
| 21 | |
| 22 // Helper for accessing and setting values in the network's UI data dictionary. | |
| 23 // Accessing values is done via static members that take the network as an | |
| 24 // argument. In order to fill a UI data dictionary, construct an instance, set | |
| 25 // up your data members, and call FillDictionary(). For example, if you have a | |
| 26 // |network|: | |
| 27 // | |
| 28 // NetworkUIData ui_data; | |
| 29 // ui_data.set_onc_source(onc::ONC_SOURCE_USER_IMPORT); | |
| 30 // ui_data.FillDictionary(network->ui_data()); | |
| 31 class NetworkUIData { | |
| 32 public: | |
| 33 NetworkUIData(); | |
| 34 explicit NetworkUIData(const base::DictionaryValue& dict); | |
| 35 ~NetworkUIData(); | |
| 36 | |
| 37 void set_onc_source(onc::ONCSource onc_source) { onc_source_ = onc_source; } | |
| 38 onc::ONCSource onc_source() const { return onc_source_; } | |
| 39 | |
| 40 void set_certificate_pattern(const CertificatePattern& pattern) { | |
| 41 certificate_pattern_ = pattern; | |
| 42 } | |
| 43 const CertificatePattern& certificate_pattern() const { | |
| 44 return certificate_pattern_; | |
| 45 } | |
| 46 void set_certificate_type(ClientCertType type) { | |
| 47 certificate_type_ = type; | |
| 48 } | |
| 49 ClientCertType certificate_type() const { | |
| 50 return certificate_type_; | |
| 51 } | |
| 52 bool is_managed() const { | |
| 53 return onc_source_ == onc::ONC_SOURCE_DEVICE_POLICY || | |
| 54 onc_source_ == onc::ONC_SOURCE_USER_POLICY; | |
| 55 } | |
| 56 | |
| 57 // Fills in |dict| with the currently configured values. This will write the | |
| 58 // keys appropriate for Network::ui_data() as defined below (kKeyXXX). | |
| 59 void FillDictionary(base::DictionaryValue* dict) const; | |
| 60 | |
| 61 // Key for storing source of the ONC network, which is an integer according to | |
| 62 // enum ONCSource. | |
| 63 static const char kKeyONCSource[]; | |
| 64 | |
| 65 // Key for storing certificate pattern for this network (if any). | |
| 66 static const char kKeyCertificatePattern[]; | |
| 67 | |
| 68 // Key for storing certificate type for this network (if any), which is one of | |
| 69 // "pattern", "ref", or "none", according to ClientCertType. | |
| 70 static const char kKeyCertificateType[]; | |
| 71 | |
| 72 private: | |
| 73 static EnumMapper<onc::ONCSource>& GetONCSourceMapper(); | |
| 74 static EnumMapper<ClientCertType>& GetClientCertMapper(); | |
| 75 | |
| 76 CertificatePattern certificate_pattern_; | |
| 77 onc::ONCSource onc_source_; | |
| 78 ClientCertType certificate_type_; | |
| 79 | |
| 80 static const EnumMapper<onc::ONCSource>::Pair kONCSourceTable[]; | |
| 81 static const EnumMapper<ClientCertType>::Pair kClientCertTable[]; | |
| 82 }; | |
| 83 | 21 |
| 84 // Holds meta information for a network property: Whether the property is under | 22 // Holds meta information for a network property: Whether the property is under |
| 85 // policy control, if it is user-editable, and whether the policy-provided | 23 // policy control, if it is user-editable, and whether the policy-provided |
| 86 // default value, if applicable. | 24 // default value, if applicable. |
| 87 class NetworkPropertyUIData { | 25 class NetworkPropertyUIData { |
| 88 public: | 26 public: |
| 89 // Enum values indicating the entity controlling the property. | 27 // Enum values indicating the entity controlling the property. |
| 90 enum Controller { | 28 enum Controller { |
| 91 // Property is managed by policy. | 29 // Property is managed by policy. |
| 92 CONTROLLER_POLICY, | 30 CONTROLLER_POLICY, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 static const char kKeyDefaultValue[]; | 64 static const char kKeyDefaultValue[]; |
| 127 | 65 |
| 128 // So it can access the kKeyXYZ constants. | 66 // So it can access the kKeyXYZ constants. |
| 129 friend class NetworkUIDataTest; | 67 friend class NetworkUIDataTest; |
| 130 | 68 |
| 131 DISALLOW_COPY_AND_ASSIGN(NetworkPropertyUIData); | 69 DISALLOW_COPY_AND_ASSIGN(NetworkPropertyUIData); |
| 132 }; | 70 }; |
| 133 | 71 |
| 134 } // namespace chromeos | 72 } // namespace chromeos |
| 135 | 73 |
| 136 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_UI_DATA_H_ | 74 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_PROPERTY_UI_DATA_H_ |
| OLD | NEW |