| 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 CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 5 #ifndef CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
| 6 #define CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 6 #define CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
| 16 #include "chromeos/network/network_type_pattern.h" | 16 #include "chromeos/network/network_type_pattern.h" |
| 17 #include "components/onc/onc_constants.h" | 17 #include "components/onc/onc_constants.h" |
| 18 | 18 |
| 19 class PrefService; |
| 20 |
| 19 namespace base { | 21 namespace base { |
| 20 class DictionaryValue; | 22 class DictionaryValue; |
| 21 class ListValue; | 23 class ListValue; |
| 22 } | 24 } |
| 23 | 25 |
| 24 namespace net { | 26 namespace net { |
| 25 class X509Certificate; | 27 class X509Certificate; |
| 26 } | 28 } |
| 27 | 29 |
| 30 namespace user_manager { |
| 31 class User; |
| 32 } |
| 33 |
| 28 namespace chromeos { | 34 namespace chromeos { |
| 35 |
| 36 class NetworkState; |
| 37 |
| 29 namespace onc { | 38 namespace onc { |
| 30 | 39 |
| 31 struct OncValueSignature; | 40 struct OncValueSignature; |
| 32 | 41 |
| 33 // A valid but empty (no networks and no certificates) and unencrypted | 42 // A valid but empty (no networks and no certificates) and unencrypted |
| 34 // configuration. | 43 // configuration. |
| 35 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; | 44 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; |
| 36 | 45 |
| 37 typedef std::map<std::string, std::string> CertPEMsByGUIDMap; | 46 typedef std::map<std::string, std::string> CertPEMsByGUIDMap; |
| 38 | 47 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 CHROMEOS_EXPORT std::unique_ptr<base::DictionaryValue> | 159 CHROMEOS_EXPORT std::unique_ptr<base::DictionaryValue> |
| 151 ConvertOncProxySettingsToProxyConfig( | 160 ConvertOncProxySettingsToProxyConfig( |
| 152 const base::DictionaryValue& onc_proxy_settings); | 161 const base::DictionaryValue& onc_proxy_settings); |
| 153 | 162 |
| 154 // Translates |proxy_config_value|, which must be a valid ProxyConfig dictionary | 163 // Translates |proxy_config_value|, which must be a valid ProxyConfig dictionary |
| 155 // (see proxy_config_dictionary.h) to an ONC ProxySettings dictionary. | 164 // (see proxy_config_dictionary.h) to an ONC ProxySettings dictionary. |
| 156 CHROMEOS_EXPORT std::unique_ptr<base::DictionaryValue> | 165 CHROMEOS_EXPORT std::unique_ptr<base::DictionaryValue> |
| 157 ConvertProxyConfigToOncProxySettings( | 166 ConvertProxyConfigToOncProxySettings( |
| 158 const base::DictionaryValue& proxy_config_value); | 167 const base::DictionaryValue& proxy_config_value); |
| 159 | 168 |
| 169 // Replaces string placeholders in |network_configs|, which must be a list of |
| 170 // ONC NetworkConfigurations. Currently only user name placeholders are |
| 171 // implemented, which are replaced by attributes from |user|. |
| 172 CHROMEOS_EXPORT void ExpandStringPlaceholdersInNetworksForUser( |
| 173 const user_manager::User* user, |
| 174 base::ListValue* network_configs); |
| 175 |
| 176 CHROMEOS_EXPORT void ImportNetworksForUser( |
| 177 const user_manager::User* user, |
| 178 const base::ListValue& network_configs, |
| 179 std::string* error); |
| 180 |
| 181 // Looks up the policy for |guid| for the current active user and sets |
| 182 // |global_config| (if not NULL) and |onc_source| (if not NULL) accordingly. If |
| 183 // |guid| is empty, returns NULL and sets the |global_config| and |onc_source| |
| 184 // if a policy is found. |
| 185 CHROMEOS_EXPORT const base::DictionaryValue* FindPolicyForActiveUser( |
| 186 const std::string& guid, |
| 187 ::onc::ONCSource* onc_source); |
| 188 |
| 189 // Convenvience function to retrieve the "AllowOnlyPolicyNetworksToAutoconnect" |
| 190 // setting from the global network configuration (see |
| 191 // GetGlobalConfigFromPolicy). |
| 192 CHROMEOS_EXPORT bool PolicyAllowsOnlyPolicyNetworksToAutoconnect( |
| 193 bool for_active_user); |
| 194 |
| 195 // Returns the effective (user or device) policy for network |network|. Both |
| 196 // |profile_prefs| and |local_state_prefs| might be NULL. Returns NULL if no |
| 197 // applicable policy is found. Sets |onc_source| accordingly. |
| 198 CHROMEOS_EXPORT const base::DictionaryValue* GetPolicyForNetwork( |
| 199 const PrefService* profile_prefs, |
| 200 const PrefService* local_state_prefs, |
| 201 const NetworkState& network, |
| 202 ::onc::ONCSource* onc_source); |
| 203 |
| 204 // Convenience function to check only whether a policy for a network exists. |
| 205 CHROMEOS_EXPORT bool HasPolicyForNetwork(const PrefService* profile_prefs, |
| 206 const PrefService* local_state_prefs, |
| 207 const NetworkState& network); |
| 208 |
| 160 } // namespace onc | 209 } // namespace onc |
| 161 } // namespace chromeos | 210 } // namespace chromeos |
| 162 | 211 |
| 163 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ | 212 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ |
| OLD | NEW |