Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: chromeos/network/managed_network_configuration_handler.h

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang errors. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ 5 #ifndef CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
6 #define CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ 6 #define CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/weak_ptr.h"
14 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
15 #include "chromeos/network/network_handler_callbacks.h" 16 #include "chromeos/network/network_handler_callbacks.h"
17 #include "chromeos/network/onc/onc_constants.h"
16 18
17 namespace base { 19 namespace base {
18 class DictionaryValue; 20 class DictionaryValue;
19 } 21 }
20 22
21 namespace chromeos { 23 namespace chromeos {
22 24
23 // The ManagedNetworkConfigurationHandler class is used to create and configure 25 // The ManagedNetworkConfigurationHandler class is used to create and configure
24 // networks in ChromeOS using ONC. 26 // networks in ChromeOS using ONC and takes care of network policies.
25 // 27 //
26 // Its interface exposes only ONC and should decouple users from Shill. 28 // Its interface exposes only ONC and should decouple users from Shill.
27 // Internally it translates ONC to Shill dictionaries and calls through to the 29 // Internally it translates ONC to Shill dictionaries and calls through to the
28 // NetworkConfigurationHandler. 30 // NetworkConfigurationHandler.
29 // 31 //
30 // For accessing lists of visible networks, and other state information, see the 32 // For accessing lists of visible networks, and other state information, see the
31 // class NetworkStateHandler. 33 // class NetworkStateHandler.
32 // 34 //
33 // This is a singleton and its lifetime is managed by the Chrome startup code. 35 // This is a singleton and its lifetime is managed by the Chrome startup code.
34 // 36 //
35 // Network configurations are referred to by Shill's service path. These 37 // Network configurations are referred to by Shill's service path. These
36 // identifiers should at most be used to also access network state using the 38 // identifiers should at most be used to also access network state using the
37 // NetworkStateHandler, but dependencies to Shill should be avoided. In the 39 // NetworkStateHandler, but dependencies to Shill should be avoided. In the
38 // future, we may switch to other identifiers. 40 // future, we may switch to other identifiers.
39 // 41 //
40 // Note on callbacks: Because all the functions here are meant to be 42 // Note on callbacks: Because all the functions here are meant to be
41 // asynchronous, they all take a |callback| of some type, and an 43 // asynchronous, they all take a |callback| of some type, and an
42 // |error_callback|. When the operation succeeds, |callback| will be called, and 44 // |error_callback|. When the operation succeeds, |callback| will be called, and
43 // when it doesn't, |error_callback| will be called with information about the 45 // when it doesn't, |error_callback| will be called with information about the
44 // error, including a symbolic name for the error and often some error message 46 // error, including a symbolic name for the error and often some error message
45 // that is suitable for logging. None of the error message text is meant for 47 // that is suitable for logging. None of the error message text is meant for
46 // user consumption. 48 // user consumption.
47 //
48 // TODO(pneubeck): Enforce network policies.
49 49
50 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler { 50 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler {
51 public: 51 public:
52 typedef std::map<std::string, const base::DictionaryValue*> PolicyMap;
53
52 // Initializes the singleton. 54 // Initializes the singleton.
53 static void Initialize(); 55 static void Initialize();
54 56
55 // Returns if the singleton is initialized. 57 // Returns if the singleton is initialized.
56 static bool IsInitialized(); 58 static bool IsInitialized();
57 59
58 // Destroys the singleton. 60 // Destroys the singleton.
59 static void Shutdown(); 61 static void Shutdown();
60 62
61 // Initialize() must be called before this. 63 // Initialize() must be called before this.
62 static ManagedNetworkConfigurationHandler* Get(); 64 static ManagedNetworkConfigurationHandler* Get();
63 65
64 // Provides the properties of the network with |service_path| to |callback|. 66 // Provides the properties of the network with |service_path| to |callback|.
65 void GetProperties( 67 void GetProperties(
66 const std::string& service_path, 68 const std::string& service_path,
67 const network_handler::DictionaryResultCallback& callback, 69 const network_handler::DictionaryResultCallback& callback,
68 const network_handler::ErrorCallback& error_callback) const; 70 const network_handler::ErrorCallback& error_callback) const;
69 71
72 // Provides the managed properties of the network with |service_path| to
73 // |callback|.
74 void GetManagedProperties(
75 const std::string& service_path,
76 const network_handler::DictionaryResultCallback& callback,
77 const network_handler::ErrorCallback& error_callback);
78
70 // Sets the user's settings of an already configured network with 79 // Sets the user's settings of an already configured network with
71 // |service_path|. A network can be initially configured by calling 80 // |service_path|. A network can be initially configured by calling
72 // CreateConfiguration or if it is managed by a policy. The given properties 81 // CreateConfiguration or if it is managed by a policy. The given properties
73 // will be merged with the existing settings, and it won't clear any existing 82 // will be merged with the existing settings, and it won't clear any existing
74 // properties. 83 // properties.
75 void SetProperties( 84 void SetProperties(
76 const std::string& service_path, 85 const std::string& service_path,
77 const base::DictionaryValue& properties, 86 const base::DictionaryValue& user_settings,
78 const base::Closure& callback, 87 const base::Closure& callback,
79 const network_handler::ErrorCallback& error_callback) const; 88 const network_handler::ErrorCallback& error_callback) const;
80 89
81 // Initiates a connection with network that has |service_path|. |callback| is 90 // Initiates a connection with network that has |service_path|. |callback| is
82 // called if the connection request was successfully handled. That doesn't 91 // called if the connection request was successfully handled. That doesn't
83 // mean that the connection was successfully established. 92 // mean that the connection was successfully established.
84 void Connect(const std::string& service_path, 93 void Connect(const std::string& service_path,
85 const base::Closure& callback, 94 const base::Closure& callback,
86 const network_handler::ErrorCallback& error_callback) const; 95 const network_handler::ErrorCallback& error_callback) const;
87 96
(...skipping 14 matching lines...) Expand all
102 const network_handler::ErrorCallback& error_callback) const; 111 const network_handler::ErrorCallback& error_callback) const;
103 112
104 // Removes the user's configuration from the network with |service_path|. The 113 // Removes the user's configuration from the network with |service_path|. The
105 // network may still show up in the visible networks after this, but no user 114 // network may still show up in the visible networks after this, but no user
106 // configuration will remain. If it was managed, it will still be configured. 115 // configuration will remain. If it was managed, it will still be configured.
107 void RemoveConfiguration( 116 void RemoveConfiguration(
108 const std::string& service_path, 117 const std::string& service_path,
109 const base::Closure& callback, 118 const base::Closure& callback,
110 const network_handler::ErrorCallback& error_callback) const; 119 const network_handler::ErrorCallback& error_callback) const;
111 120
121 // Only to be called by NetworkConfigurationUpdater or from tests.
122 // Sets |toplevel_onc| as the current policy of |onc_source|. The network
123 // configurations of the policy will be applied (not necessarily immediately)
124 // to Shill's profiles and enforced in future configurations until the policy
125 // associated with |onc_source| is changed again with this function.
126 void SetPolicy(onc::ONCSource onc_source,
127 const base::DictionaryValue& toplevel_onc);
128
112 private: 129 private:
130 class PolicyApplicator;
131
113 ManagedNetworkConfigurationHandler(); 132 ManagedNetworkConfigurationHandler();
114 ~ManagedNetworkConfigurationHandler(); 133 ~ManagedNetworkConfigurationHandler();
115 134
135 void GetManagedPropertiesCallback(
136 const network_handler::DictionaryResultCallback& callback,
137 const network_handler::ErrorCallback& error_callback,
138 const std::string& service_path,
139 const base::DictionaryValue& shill_properties);
140
141 const PolicyMap* GetPoliciesForProfile(const std::string& profile) const;
142
143 // The entries of these maps are owned by this class and are explicitly
144 // deleted where necessary.
145 PolicyMap user_policies_by_guid_;
146 PolicyMap device_policies_by_guid_;
147 bool user_policies_initialized_;
148 bool device_policies_initialized_;
149
150 // For Shill client callbacks
151 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_;
152
116 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); 153 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
117 }; 154 };
118 155
119 } // namespace chromeos 156 } // namespace chromeos
120 157
121 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ 158 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_service_client_stub.cc ('k') | chromeos/network/managed_network_configuration_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698