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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "components/onc/onc_constants.h"
16 class DictionaryValue
;
20 namespace user_manager
{
30 // Translates |onc_proxy_settings|, which has to be a valid ONC ProxySettings
31 // dictionary, to a ProxyConfig dictionary (see
32 // chrome/browser/prefs/proxy_config_dictionary.h).
34 // This function is used to translate ONC ProxySettings to the "ProxyConfig"
35 // field of the Shill configuration.
36 scoped_ptr
<base::DictionaryValue
> ConvertOncProxySettingsToProxyConfig(
37 const base::DictionaryValue
& onc_proxy_settings
);
39 // Replaces string placeholders in |network_configs|, which must be a list of
40 // ONC NetworkConfigurations. Currently only user name placeholders are
41 // implemented, which are replaced by attributes of the logged-in user with
43 void ExpandStringPlaceholdersInNetworksForUser(
44 const user_manager::User
* user
,
45 base::ListValue
* network_configs
);
47 void ImportNetworksForUser(const user_manager::User
* user
,
48 const base::ListValue
& network_configs
,
51 // Looks up the policy for |guid| for the current active user and sets
52 // |global_config| (if not NULL) and |onc_source| (if not NULL) accordingly. If
53 // |guid| is empty, returns NULL and sets the |global_config| and |onc_source|
54 // if a policy is found.
55 const base::DictionaryValue
* FindPolicyForActiveUser(
56 const std::string
& guid
,
57 ::onc::ONCSource
* onc_source
);
59 // Returns the global network configuration section of the active user's network
60 // policy (if |for_active_user| is true) or of the device policy.
61 const base::DictionaryValue
* GetGlobalConfigFromPolicy(bool for_active_user
);
63 // Convenvience function to retrieve the "AllowOnlyPolicyNetworksToAutoconnect"
64 // setting from the global network configuration (see
65 // GetGlobalConfigFromPolicy).
66 bool PolicyAllowsOnlyPolicyNetworksToAutoconnect(bool for_active_user
);
68 // Returns the effective (user or device) policy for network |network|. Both
69 // |profile_prefs| and |local_state_prefs| might be NULL. Returns NULL if no
70 // applicable policy is found. Sets |onc_source| accordingly.
71 const base::DictionaryValue
* GetPolicyForNetwork(
72 const PrefService
* profile_prefs
,
73 const PrefService
* local_state_prefs
,
74 const NetworkState
& network
,
75 ::onc::ONCSource
* onc_source
);
77 // Convenience function to check only whether a policy for a network exists.
78 bool HasPolicyForNetwork(const PrefService
* profile_prefs
,
79 const PrefService
* local_state_prefs
,
80 const NetworkState
& network
);
83 } // namespace chromeos
85 #endif // CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_