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

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

Issue 14729017: Add NetworkHandler to own network handlers in src/chromeos/network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromeos_unittests Created 7 years, 7 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 "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
16 #include "chromeos/network/network_handler.h"
16 #include "chromeos/network/network_handler_callbacks.h" 17 #include "chromeos/network/network_handler_callbacks.h"
17 #include "chromeos/network/network_profile_observer.h" 18 #include "chromeos/network/network_profile_observer.h"
18 #include "chromeos/network/onc/onc_constants.h" 19 #include "chromeos/network/onc/onc_constants.h"
19 20
20 namespace base { 21 namespace base {
21 class DictionaryValue; 22 class DictionaryValue;
22 class ListValue; 23 class ListValue;
23 } 24 }
24 25
25 namespace chromeos { 26 namespace chromeos {
26 27
28 class NetworkConfigurationHandler;
27 class NetworkProfileHandler; 29 class NetworkProfileHandler;
30 class NetworkStateHandler;
28 class NetworkUIData; 31 class NetworkUIData;
29 32
30 // The ManagedNetworkConfigurationHandler class is used to create and configure 33 // The ManagedNetworkConfigurationHandler class is used to create and configure
31 // networks in ChromeOS using ONC and takes care of network policies. 34 // networks in ChromeOS using ONC and takes care of network policies.
32 // 35 //
33 // Its interface exposes only ONC and should decouple users from Shill. 36 // Its interface exposes only ONC and should decouple users from Shill.
34 // Internally it translates ONC to Shill dictionaries and calls through to the 37 // Internally it translates ONC to Shill dictionaries and calls through to the
35 // NetworkConfigurationHandler. 38 // NetworkConfigurationHandler.
36 // 39 //
37 // For accessing lists of visible networks, and other state information, see the 40 // For accessing lists of visible networks, and other state information, see the
(...skipping 13 matching lines...) Expand all
51 // error, including a symbolic name for the error and often some error message 54 // error, including a symbolic name for the error and often some error message
52 // that is suitable for logging. None of the error message text is meant for 55 // that is suitable for logging. None of the error message text is meant for
53 // user consumption. 56 // user consumption.
54 57
55 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler 58 class CHROMEOS_EXPORT ManagedNetworkConfigurationHandler
56 : public NetworkProfileObserver { 59 : public NetworkProfileObserver {
57 public: 60 public:
58 typedef std::map<std::string, const base::DictionaryValue*> GuidToPolicyMap; 61 typedef std::map<std::string, const base::DictionaryValue*> GuidToPolicyMap;
59 typedef std::map<std::string, GuidToPolicyMap> UserToPoliciesMap; 62 typedef std::map<std::string, GuidToPolicyMap> UserToPoliciesMap;
60 63
61 // Initializes the singleton. 64 virtual ~ManagedNetworkConfigurationHandler();
62 static void Initialize(NetworkProfileHandler* profile_handler);
63
64 // Returns if the singleton is initialized.
65 static bool IsInitialized();
66
67 // Destroys the singleton.
68 static void Shutdown();
69
70 // Initialize() must be called before this.
71 static ManagedNetworkConfigurationHandler* Get();
72 65
73 // Returns the NetworkUIData parsed from the UIData property of 66 // Returns the NetworkUIData parsed from the UIData property of
74 // |shill_dictionary|. If parsing fails or the field doesn't exist, returns 67 // |shill_dictionary|. If parsing fails or the field doesn't exist, returns
75 // NULL. 68 // NULL.
76 static scoped_ptr<NetworkUIData> GetUIData( 69 static scoped_ptr<NetworkUIData> GetUIData(
77 const base::DictionaryValue& shill_dictionary); 70 const base::DictionaryValue& shill_dictionary);
78 71
79 // Provides the properties of the network with |service_path| to |callback|. 72 // Provides the properties of the network with |service_path| to |callback|.
80 void GetProperties( 73 void GetProperties(
81 const std::string& service_path, 74 const std::string& service_path,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // associated with |onc_source| is changed again with this function. For 121 // associated with |onc_source| is changed again with this function. For
129 // device policies, |userhash| must be empty. 122 // device policies, |userhash| must be empty.
130 void SetPolicy(onc::ONCSource onc_source, 123 void SetPolicy(onc::ONCSource onc_source,
131 const std::string& userhash, 124 const std::string& userhash,
132 const base::ListValue& network_configs_onc); 125 const base::ListValue& network_configs_onc);
133 126
134 // NetworkProfileObserver overrides 127 // NetworkProfileObserver overrides
135 virtual void OnProfileAdded(const NetworkProfile& profile) OVERRIDE; 128 virtual void OnProfileAdded(const NetworkProfile& profile) OVERRIDE;
136 virtual void OnProfileRemoved(const NetworkProfile& profile) OVERRIDE; 129 virtual void OnProfileRemoved(const NetworkProfile& profile) OVERRIDE;
137 130
131 NetworkConfigurationHandler* network_configuration_handler() {
132 return network_configuration_handler_;
133 }
134
138 private: 135 private:
136 friend class NetworkHandler;
137 friend class ManagedNetworkConfigurationHandlerTest;
139 class PolicyApplicator; 138 class PolicyApplicator;
140 139
141 explicit ManagedNetworkConfigurationHandler( 140 ManagedNetworkConfigurationHandler();
142 NetworkProfileHandler* profile_handler); 141
143 virtual ~ManagedNetworkConfigurationHandler(); 142 void Init(NetworkStateHandler* network_state_handler,
143 NetworkProfileHandler* network_profile_handler,
144 NetworkConfigurationHandler* network_configuration_handler);
145
144 146
145 void GetManagedPropertiesCallback( 147 void GetManagedPropertiesCallback(
146 const network_handler::DictionaryResultCallback& callback, 148 const network_handler::DictionaryResultCallback& callback,
147 const network_handler::ErrorCallback& error_callback, 149 const network_handler::ErrorCallback& error_callback,
148 const std::string& service_path, 150 const std::string& service_path,
149 const base::DictionaryValue& shill_properties); 151 const base::DictionaryValue& shill_properties);
150 152
151 const GuidToPolicyMap* GetPoliciesForUser(const std::string& userhash) const; 153 const GuidToPolicyMap* GetPoliciesForUser(const std::string& userhash) const;
152 const GuidToPolicyMap* GetPoliciesForProfile( 154 const GuidToPolicyMap* GetPoliciesForProfile(
153 const NetworkProfile& profile) const; 155 const NetworkProfile& profile) const;
154 156
155 // The DictionaryValues of the nested maps are owned by this class and are 157 // The DictionaryValues of the nested maps are owned by this class and are
156 // explicitly deleted where necessary. If present, the empty string maps to 158 // explicitly deleted where necessary. If present, the empty string maps to
157 // the device policy. 159 // the device policy.
158 UserToPoliciesMap policies_by_user_; 160 UserToPoliciesMap policies_by_user_;
159 161
160 // A local reference to the policy handler singleton. 162 // Local references to the associated handler instances.
161 NetworkProfileHandler* profile_handler_; 163 NetworkStateHandler* network_state_handler_;
164 NetworkProfileHandler* network_profile_handler_;
165 NetworkConfigurationHandler* network_configuration_handler_;
162 166
163 // For Shill client callbacks 167 // For Shill client callbacks
164 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_; 168 base::WeakPtrFactory<ManagedNetworkConfigurationHandler> weak_ptr_factory_;
165 169
166 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler); 170 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandler);
167 }; 171 };
168 172
169 } // namespace chromeos 173 } // namespace chromeos
170 174
171 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_ 175 #endif // CHROMEOS_NETWORK_MANAGED_NETWORK_CONFIGURATION_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/network/geolocation_handler.cc ('k') | chromeos/network/managed_network_configuration_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698