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