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

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

Issue 22327005: Automatically resolve ClientCertificatePatterns. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added more documentation. Created 7 years, 4 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 <map>
9 #include <string> 9 #include <string>
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 "base/memory/weak_ptr.h"
15 #include "base/observer_list.h"
15 #include "chromeos/chromeos_export.h" 16 #include "chromeos/chromeos_export.h"
16 #include "chromeos/network/network_handler.h" 17 #include "chromeos/network/network_handler.h"
17 #include "chromeos/network/network_handler_callbacks.h" 18 #include "chromeos/network/network_handler_callbacks.h"
18 #include "chromeos/network/network_profile_observer.h" 19 #include "chromeos/network/network_profile_observer.h"
19 #include "chromeos/network/onc/onc_constants.h" 20 #include "chromeos/network/onc/onc_constants.h"
20 21
21 namespace base { 22 namespace base {
22 class DictionaryValue; 23 class DictionaryValue;
23 class ListValue; 24 class ListValue;
24 } 25 }
25 26
26 namespace chromeos { 27 namespace chromeos {
27 28
28 class NetworkConfigurationHandler; 29 class NetworkConfigurationHandler;
30 class NetworkPolicyObserver;
29 class NetworkProfileHandler; 31 class NetworkProfileHandler;
30 class NetworkStateHandler; 32 class NetworkStateHandler;
31 class NetworkUIData; 33 class NetworkUIData;
32 34
33 // The ManagedNetworkConfigurationHandler class is used to create and configure 35 // The ManagedNetworkConfigurationHandler class is used to create and configure
34 // networks in ChromeOS using ONC and takes care of network policies. 36 // networks in ChromeOS using ONC and takes care of network policies.
35 // 37 //
36 // Its interface exposes only ONC and should decouple users from Shill. 38 // Its interface exposes only ONC and should decouple users from Shill.
37 // Internally it translates ONC to Shill dictionaries and calls through to the 39 // Internally it translates ONC to Shill dictionaries and calls through to the
38 // NetworkConfigurationHandler. 40 // NetworkConfigurationHandler.
(...skipping 23 matching lines...) Expand all
62 typedef std::map<std::string, GuidToPolicyMap> UserToPoliciesMap; 64 typedef std::map<std::string, GuidToPolicyMap> UserToPoliciesMap;
63 65
64 virtual ~ManagedNetworkConfigurationHandler(); 66 virtual ~ManagedNetworkConfigurationHandler();
65 67
66 // Returns the NetworkUIData parsed from the UIData property of 68 // Returns the NetworkUIData parsed from the UIData property of
67 // |shill_dictionary|. If parsing fails or the field doesn't exist, returns 69 // |shill_dictionary|. If parsing fails or the field doesn't exist, returns
68 // NULL. 70 // NULL.
69 static scoped_ptr<NetworkUIData> GetUIData( 71 static scoped_ptr<NetworkUIData> GetUIData(
70 const base::DictionaryValue& shill_dictionary); 72 const base::DictionaryValue& shill_dictionary);
71 73
74 void AddObserver(NetworkPolicyObserver* observer);
75 void RemoveObserver(NetworkPolicyObserver* observer);
76
72 // Provides the properties of the network with |service_path| to |callback|. 77 // Provides the properties of the network with |service_path| to |callback|.
73 void GetProperties( 78 void GetProperties(
74 const std::string& service_path, 79 const std::string& service_path,
75 const network_handler::DictionaryResultCallback& callback, 80 const network_handler::DictionaryResultCallback& callback,
76 const network_handler::ErrorCallback& error_callback) const; 81 const network_handler::ErrorCallback& error_callback) const;
77 82
78 // Provides the managed properties of the network with |service_path| to 83 // Provides the managed properties of the network with |service_path| to
79 // |callback|. |userhash| is only used to ensure that the user's policy is 84 // |callback|. |userhash| is only used to ensure that the user's policy is
80 // already applied. 85 // already applied.
81 void GetManagedProperties( 86 void GetManagedProperties(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const base::ListValue& network_configs_onc); 130 const base::ListValue& network_configs_onc);
126 131
127 // Returns the user policy for user |userhash| or device policy, which has 132 // Returns the user policy for user |userhash| or device policy, which has
128 // |guid|. If |userhash| is empty, only looks for a device policy. If such 133 // |guid|. If |userhash| is empty, only looks for a device policy. If such
129 // doesn't exist, returns NULL. Sets |onc_source| accordingly. 134 // doesn't exist, returns NULL. Sets |onc_source| accordingly.
130 const base::DictionaryValue* FindPolicyByGUID( 135 const base::DictionaryValue* FindPolicyByGUID(
131 const std::string userhash, 136 const std::string userhash,
132 const std::string& guid, 137 const std::string& guid,
133 onc::ONCSource* onc_source) const; 138 onc::ONCSource* onc_source) const;
134 139
135 // NetworkProfileObserver overrides 140 // Returns the policy with |guid| for profile |profile_path|. If such
141 // doesn't exist, returns NULL.
142 const base::DictionaryValue* FindPolicyByGuidAndProfile(
143 const std::string& guid,
144 const std::string& profile_path) const;
145
146 // NetworkProfileObserver overrides
136 virtual void OnProfileAdded(const NetworkProfile& profile) OVERRIDE; 147 virtual void OnProfileAdded(const NetworkProfile& profile) OVERRIDE;
137 virtual void OnProfileRemoved(const NetworkProfile& profile) OVERRIDE; 148 virtual void OnProfileRemoved(const NetworkProfile& profile) OVERRIDE;
138 149
139 NetworkConfigurationHandler* network_configuration_handler() { 150 NetworkConfigurationHandler* network_configuration_handler() {
140 return network_configuration_handler_; 151 return network_configuration_handler_;
141 } 152 }
142 153
143 private: 154 private:
144 friend class NetworkHandler; 155 friend class NetworkHandler;
145 friend class ManagedNetworkConfigurationHandlerTest; 156 friend class ManagedNetworkConfigurationHandlerTest;
146 class PolicyApplicator; 157 class PolicyApplicator;
147 158
148 ManagedNetworkConfigurationHandler(); 159 ManagedNetworkConfigurationHandler();
149 160
150 void Init(NetworkStateHandler* network_state_handler, 161 void Init(NetworkStateHandler* network_state_handler,
151 NetworkProfileHandler* network_profile_handler, 162 NetworkProfileHandler* network_profile_handler,
152 NetworkConfigurationHandler* network_configuration_handler); 163 NetworkConfigurationHandler* network_configuration_handler);
153 164
154
155 void GetManagedPropertiesCallback( 165 void GetManagedPropertiesCallback(
156 const network_handler::DictionaryResultCallback& callback, 166 const network_handler::DictionaryResultCallback& callback,
157 const network_handler::ErrorCallback& error_callback, 167 const network_handler::ErrorCallback& error_callback,
158 const std::string& service_path, 168 const std::string& service_path,
159 const base::DictionaryValue& shill_properties); 169 const base::DictionaryValue& shill_properties);
160 170
161 const GuidToPolicyMap* GetPoliciesForUser(const std::string& userhash) const; 171 const GuidToPolicyMap* GetPoliciesForUser(const std::string& userhash) const;
162 const GuidToPolicyMap* GetPoliciesForProfile( 172 const GuidToPolicyMap* GetPoliciesForProfile(
163 const NetworkProfile& profile) const; 173 const NetworkProfile& profile) const;
164 174
175 void OnPolicyApplied(const std::string& service_path);
176
165 // The DictionaryValues of the nested maps are owned by this class and are 177 // The DictionaryValues of the nested maps are owned by this class and are
166 // explicitly deleted where necessary. If present, the empty string maps to 178 // explicitly deleted where necessary. If present, the empty string maps to
167 // the device policy. 179 // the device policy.
168 UserToPoliciesMap policies_by_user_; 180 UserToPoliciesMap policies_by_user_;
169 181
170 // Local references to the associated handler instances. 182 // Local references to the associated handler instances.
171 NetworkStateHandler* network_state_handler_; 183 NetworkStateHandler* network_state_handler_;
172 NetworkProfileHandler* network_profile_handler_; 184 NetworkProfileHandler* network_profile_handler_;
173 NetworkConfigurationHandler* network_configuration_handler_; 185 NetworkConfigurationHandler* network_configuration_handler_;
174 186
187 ObserverList<NetworkPolicyObserver> observers_;
188
175 // For Shill client callbacks 189 // For Shill client callbacks
176 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_; 190 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_;
177 191
178 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); 192 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
179 }; 193 };
180 194
181 } // namespace chromeos 195 } // namespace chromeos
182 196
183 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ 197 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698