- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / net / onc_utils.h
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.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "components/onc/onc_constants.h"
12
13 class PrefService;
14
15 namespace base {
16 class DictionaryValue;
17 class ListValue;
18 }
19
20 namespace chromeos {
21
22 class FavoriteState;
23 class NetworkState;
24 class User;
25
26 namespace onc {
27
28 // Translates |onc_proxy_settings|, which has to be a valid ONC ProxySettings
29 // dictionary, to a ProxyConfig dictionary (see
30 // chrome/browser/prefs/proxy_config_dictionary.h).
31 //
32 // This function is used to translate ONC ProxySettings to the "ProxyConfig"
33 // field of the Shill configuration.
34 scoped_ptr<base::DictionaryValue> ConvertOncProxySettingsToProxyConfig(
35     const base::DictionaryValue& onc_proxy_settings);
36
37 // Replaces string placeholders in |network_configs|, which must be a list of
38 // ONC NetworkConfigurations. Currently only user name placeholders are
39 // implemented, which are replaced by attributes of the logged-in user with
40 // |hashed_username|.
41 void ExpandStringPlaceholdersInNetworksForUser(
42     const chromeos::User* user,
43     base::ListValue* network_configs);
44
45 void ImportNetworksForUser(const chromeos::User* user,
46                            const base::ListValue& network_configs,
47                            std::string* error);
48
49 // Looks up the policy for |guid| for the current active user and sets
50 // |global_config| (if not NULL) and |onc_source| (if not NULL) accordingly. If
51 // |guid| is empty, returns NULL and sets the |global_config| and |onc_source|
52 // if a policy is found.
53 const base::DictionaryValue* FindPolicyForActiveUser(
54     const std::string& guid,
55     ::onc::ONCSource* onc_source);
56
57 // Returns the global network configuration section of the active user's network
58 // policy (if |for_active_user| is true) or of the device policy.
59 const base::DictionaryValue* GetGlobalConfigFromPolicy(bool for_active_user);
60
61 // Convenvience function to retrieve the "AllowOnlyPolicyNetworksToAutoconnect"
62 // setting from the global network configuration (see
63 // GetGlobalConfigFromPolicy).
64 bool PolicyAllowsOnlyPolicyNetworksToAutoconnect(bool for_active_user);
65
66 // Returns the effective (user or device) policy for network |favorite|. Both
67 // |profile_prefs| and |local_state_prefs| might be NULL. Returns NULL if no
68 // applicable policy is found. Sets |onc_source| accordingly.
69 const base::DictionaryValue* GetPolicyForFavoriteNetwork(
70     const PrefService* profile_prefs,
71     const PrefService* local_state_prefs,
72     const FavoriteState& favorite,
73     ::onc::ONCSource* onc_source);
74
75 // Convenience function to check only whether a policy for a network exists.
76 bool HasPolicyForFavoriteNetwork(const PrefService* profile_prefs,
77                                  const PrefService* local_state_prefs,
78                                  const FavoriteState& network);
79
80 }  // namespace onc
81 }  // namespace chromeos
82
83 #endif  // CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_