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

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

Issue 1431563005: Handle prohibited technologies in device policy ONC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dependencies for NetworkHandler in ShillPropertyHandlerTest.ProhibitedTechnologies Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_SHILL_PROPERTY_HANDLER_H_ 5 #ifndef CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_
6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ 6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector>
12 13
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "chromeos/dbus/dbus_method_call_status.h" 15 #include "chromeos/dbus/dbus_method_call_status.h"
15 #include "chromeos/dbus/shill_property_changed_observer.h" 16 #include "chromeos/dbus/shill_property_changed_observer.h"
17 #include "chromeos/login/login_state.h"
16 #include "chromeos/network/managed_state.h" 18 #include "chromeos/network/managed_state.h"
17 #include "chromeos/network/network_handler_callbacks.h" 19 #include "chromeos/network/network_handler_callbacks.h"
20 #include "chromeos/network/network_policy_observer.h"
18 21
19 namespace base { 22 namespace base {
20 class DictionaryValue; 23 class DictionaryValue;
21 class ListValue; 24 class ListValue;
22 class Value; 25 class Value;
23 } 26 }
24 27
25 namespace chromeos { 28 namespace chromeos {
26 29
27 class ShillManagerClient; 30 class ShillManagerClient;
28 31
29 namespace internal { 32 namespace internal {
30 33
31 class ShillPropertyObserver; 34 class ShillPropertyObserver;
32 35
33 // This class handles Shill calls and observers to reflect the state of the 36 // This class handles Shill calls and observers to reflect the state of the
34 // Shill Manager and its services and devices. It observes Shill.Manager and 37 // Shill Manager and its services and devices. It observes Shill.Manager and
35 // requests properties for new devices/networks. It takes a Listener in its 38 // requests properties for new devices/networks. It takes a Listener in its
36 // constructor (e.g. NetworkStateHandler) that it calls when properties change 39 // constructor (e.g. NetworkStateHandler) that it calls when properties change
37 // (including once to set their initial state after Init() gets called). 40 // (including once to set their initial state after Init() gets called).
38 // It also observes Shill.Service for all services in Manager.ServiceWatchList. 41 // It also observes Shill.Service for all services in Manager.ServiceWatchList.
39 // This class must not outlive the ShillManagerClient instance. 42 // This class must not outlive the ShillManagerClient instance.
40 class CHROMEOS_EXPORT ShillPropertyHandler 43 class CHROMEOS_EXPORT ShillPropertyHandler
41 : public ShillPropertyChangedObserver, 44 : public ShillPropertyChangedObserver,
42 public base::SupportsWeakPtr<ShillPropertyHandler> { 45 public base::SupportsWeakPtr<ShillPropertyHandler>,
46 public LoginState::Observer {
stevenjb 2015/11/10 21:40:21 I really don't like adding this dependency here, o
fqj 2015/11/11 16:53:55 Done.
43 public: 47 public:
44 typedef std::map<std::string, ShillPropertyObserver*> 48 typedef std::map<std::string, ShillPropertyObserver*>
45 ShillPropertyObserverMap; 49 ShillPropertyObserverMap;
46 50
47 class CHROMEOS_EXPORT Listener { 51 class CHROMEOS_EXPORT Listener {
48 public: 52 public:
49 // Called when the entries in a managed list have changed. 53 // Called when the entries in a managed list have changed.
50 virtual void UpdateManagedList(ManagedState::ManagedType type, 54 virtual void UpdateManagedList(ManagedState::ManagedType type,
51 const base::ListValue& entries) = 0; 55 const base::ListValue& entries) = 0;
52 56
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ~ShillPropertyHandler() override; 106 ~ShillPropertyHandler() override;
103 107
104 // Sets up the observer and calls UpdateManagerProperties(). 108 // Sets up the observer and calls UpdateManagerProperties().
105 void Init(); 109 void Init();
106 110
107 // Requests all Manager properties. Called from Init() and any time 111 // Requests all Manager properties. Called from Init() and any time
108 // properties that do not signal changes might have been updated (e.g. 112 // properties that do not signal changes might have been updated (e.g.
109 // ServiceCompleteList). 113 // ServiceCompleteList).
110 void UpdateManagerProperties(); 114 void UpdateManagerProperties();
111 115
116 // LoginState::Observer
117 void LoggedInStateChanged() override;
118
112 // Returns true if |technology| is available, enabled, etc. 119 // Returns true if |technology| is available, enabled, etc.
113 bool IsTechnologyAvailable(const std::string& technology) const; 120 bool IsTechnologyAvailable(const std::string& technology) const;
114 bool IsTechnologyEnabled(const std::string& technology) const; 121 bool IsTechnologyEnabled(const std::string& technology) const;
115 bool IsTechnologyEnabling(const std::string& technology) const; 122 bool IsTechnologyEnabling(const std::string& technology) const;
116 bool IsTechnologyUninitialized(const std::string& technology) const; 123 bool IsTechnologyUninitialized(const std::string& technology) const;
117 124
118 // Asynchronously sets the enabled state for |technology|. 125 // Asynchronously sets the enabled state for |technology|.
119 // Note: Modifies Manager state. Calls |error_callback| on failure. 126 // Note: Modifies Manager state. Calls |error_callback| on failure.
120 void SetTechnologyEnabled( 127 void SetTechnologyEnabled(
121 const std::string& technology, 128 const std::string& technology,
122 bool enabled, 129 bool enabled,
123 const network_handler::ErrorCallback& error_callback); 130 const network_handler::ErrorCallback& error_callback);
124 131
132 // Asynchronously sets the prohibited state for every network technology
133 // listed in |technologies|. Note: Modifies Manager state. Calls
134 // |error_callback| on failure.
135 void SetProhibitedTechnologies(
136 const std::vector<std::string>& technologies,
137 const network_handler::ErrorCallback& error_callback);
138
125 // Sets the list of devices on which portal check is enabled. 139 // Sets the list of devices on which portal check is enabled.
126 void SetCheckPortalList(const std::string& check_portal_list); 140 void SetCheckPortalList(const std::string& check_portal_list);
127 141
128 // Sets the Manager.WakeOnLan property. Note: we do not track this state, we 142 // Sets the Manager.WakeOnLan property. Note: we do not track this state, we
129 // only set it. 143 // only set it.
130 void SetWakeOnLanEnabled(bool enabled); 144 void SetWakeOnLanEnabled(bool enabled);
131 145
132 // Requests an immediate network scan. 146 // Requests an immediate network scan.
133 void RequestScan() const; 147 void RequestScan() const;
134 148
135 // Requests all properties for the service or device (called for new items). 149 // Requests all properties for the service or device (called for new items).
136 void RequestProperties(ManagedState::ManagedType type, 150 void RequestProperties(ManagedState::ManagedType type,
137 const std::string& path); 151 const std::string& path);
138 152
139 // ShillPropertyChangedObserver overrides 153 // ShillPropertyChangedObserver overrides
140 void OnPropertyChanged(const std::string& key, 154 void OnPropertyChanged(const std::string& key,
141 const base::Value& value) override; 155 const base::Value& value) override;
142 156
157 // Called when user policy is applied
158 void UserPolicyApplied();
159
143 private: 160 private:
144 typedef std::map<ManagedState::ManagedType, std::set<std::string> > 161 typedef std::map<ManagedState::ManagedType, std::set<std::string> >
145 TypeRequestMap; 162 TypeRequestMap;
146 163
147 // Callback for dbus method fetching properties. 164 // Callback for dbus method fetching properties.
148 void ManagerPropertiesCallback(DBusMethodCallStatus call_status, 165 void ManagerPropertiesCallback(DBusMethodCallStatus call_status,
149 const base::DictionaryValue& properties); 166 const base::DictionaryValue& properties);
150 167
151 // Notifies the listener when a ManagedStateList has changed and all pending 168 // Notifies the listener when a ManagedStateList has changed and all pending
152 // updates have been received. |key| can either identify the list that 169 // updates have been received. |key| can either identify the list that
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 224
208 // Callback for getting the IPConfig property of a network or device. Handled 225 // Callback for getting the IPConfig property of a network or device. Handled
209 // here instead of in NetworkState so that all asynchronous requests are done 226 // here instead of in NetworkState so that all asynchronous requests are done
210 // in a single place (also simplifies NetworkState considerably). 227 // in a single place (also simplifies NetworkState considerably).
211 void GetIPConfigCallback(ManagedState::ManagedType type, 228 void GetIPConfigCallback(ManagedState::ManagedType type,
212 const std::string& path, 229 const std::string& path,
213 const std::string& ip_config_path, 230 const std::string& ip_config_path,
214 DBusMethodCallStatus call_status, 231 DBusMethodCallStatus call_status,
215 const base::DictionaryValue& properties); 232 const base::DictionaryValue& properties);
216 233
234 void SetProhibitedTechnologiesEnforced(bool enforced);
235
236 // Is user logged in
237 bool in_user_session_;
238
239 // Is user policy applied
240 bool user_policy_applied_;
241
217 // Pointer to containing class (owns this) 242 // Pointer to containing class (owns this)
218 Listener* listener_; 243 Listener* listener_;
219 244
220 // Convenience pointer for ShillManagerClient 245 // Convenience pointer for ShillManagerClient
221 ShillManagerClient* shill_manager_; 246 ShillManagerClient* shill_manager_;
222 247
223 // Pending update list for each managed state type 248 // Pending update list for each managed state type
224 TypeRequestMap pending_updates_; 249 TypeRequestMap pending_updates_;
225 250
226 // List of states for which properties have been requested, for each managed 251 // List of states for which properties have been requested, for each managed
227 // state type 252 // state type
228 TypeRequestMap requested_updates_; 253 TypeRequestMap requested_updates_;
229 254
230 // List of network services with Shill property changed observers 255 // List of network services with Shill property changed observers
231 ShillPropertyObserverMap observed_networks_; 256 ShillPropertyObserverMap observed_networks_;
232 257
233 // List of network devices with Shill property changed observers 258 // List of network devices with Shill property changed observers
234 ShillPropertyObserverMap observed_devices_; 259 ShillPropertyObserverMap observed_devices_;
235 260
236 // Lists of available / enabled / uninitialized technologies 261 // Lists of available / enabled / uninitialized technologies
237 std::set<std::string> available_technologies_; 262 std::set<std::string> available_technologies_;
238 std::set<std::string> enabled_technologies_; 263 std::set<std::string> enabled_technologies_;
239 std::set<std::string> enabling_technologies_; 264 std::set<std::string> enabling_technologies_;
265 std::set<std::string> prohibited_technologies_;
240 std::set<std::string> uninitialized_technologies_; 266 std::set<std::string> uninitialized_technologies_;
241 267
242 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandler); 268 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandler);
243 }; 269 };
244 270
245 } // namespace internal 271 } // namespace internal
246 } // namespace chromeos 272 } // namespace chromeos
247 273
248 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ 274 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698