Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / net / onc_utils.h
blob3f6cae4cd3abb112e3d602a7a207a3d321a87215
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "components/onc/onc_constants.h"
13 class PrefService;
15 namespace base {
16 class DictionaryValue;
17 class ListValue;
20 namespace user_manager {
21 class User;
24 namespace chromeos {
26 class NetworkState;
28 namespace onc {
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
42 // |hashed_username|.
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,
49 std::string* error);
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);
82 } // namespace onc
83 } // namespace chromeos
85 #endif // CHROME_BROWSER_CHROMEOS_NET_ONC_UTILS_H_