Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromeos / dbus / shill_manager_client.h
blob68fcf44b960c1488b96cc29a1f795a761cfaf059
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 CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h"
13 #include "chromeos/dbus/dbus_method_call_status.h"
14 #include "chromeos/dbus/shill_client_helper.h"
16 namespace dbus {
17 class ObjectPath;
20 namespace net {
21 class IPEndPoint;
24 namespace chromeos {
26 class ShillPropertyChangedObserver;
28 // ShillManagerClient is used to communicate with the Shill Manager
29 // service. All methods should be called from the origin thread which
30 // initializes the DBusThreadManager instance.
31 class CHROMEOS_EXPORT ShillManagerClient : public DBusClient {
32 public:
33 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
34 typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
35 typedef ShillClientHelper::ErrorCallback ErrorCallback;
36 typedef ShillClientHelper::StringCallback StringCallback;
37 typedef ShillClientHelper::BooleanCallback BooleanCallback;
39 // Interface for setting up devices, services, and technologies for testing.
40 // Accessed through GetTestInterface(), only implemented in the Stub Impl.
41 class TestInterface {
42 public:
43 virtual void AddDevice(const std::string& device_path) = 0;
44 virtual void RemoveDevice(const std::string& device_path) = 0;
45 virtual void ClearDevices() = 0;
46 virtual void AddTechnology(const std::string& type, bool enabled) = 0;
47 virtual void RemoveTechnology(const std::string& type) = 0;
48 virtual void SetTechnologyInitializing(const std::string& type,
49 bool initializing) = 0;
50 virtual void AddGeoNetwork(const std::string& technology,
51 const base::DictionaryValue& network) = 0;
53 // Does not create an actual profile in the ProfileClient but update the
54 // profiles list and sends a notification to observers. This should only be
55 // called by the ProfileStub. In all other cases, use
56 // ShillProfileClient::TestInterface::AddProfile.
57 virtual void AddProfile(const std::string& profile_path) = 0;
59 // Used to reset all properties; does not notify observers.
60 virtual void ClearProperties() = 0;
62 // Set manager property.
63 virtual void SetManagerProperty(const std::string& key,
64 const base::Value& value) = 0;
66 // Modify services in the Manager's list.
67 virtual void AddManagerService(const std::string& service_path,
68 bool notify_observers) = 0;
69 virtual void RemoveManagerService(const std::string& service_path) = 0;
70 virtual void ClearManagerServices() = 0;
72 // Called by ShillServiceClient when a service's State property changes,
73 // before notifying observers. Sets the DefaultService property to empty
74 // if the state changes to a non-connected state.
75 virtual void ServiceStateChanged(const std::string& service_path,
76 const std::string& state) = 0;
78 // Called by ShillServiceClient when a service's State or Visibile
79 // property changes. If |notify| is true, notifies observers if a list
80 // changed. Services are sorted first by active, inactive, or disabled
81 // state, then by type.
82 virtual void SortManagerServices(bool notify) = 0;
84 // Sets up the default fake environment based on default initial states
85 // or states provided by the command line.
86 virtual void SetupDefaultEnvironment() = 0;
88 // Returns the interactive delay specified on the command line, 0 for none.
89 virtual int GetInteractiveDelay() const = 0;
91 // Sets the 'best' service to connect to on a ConnectToBestServices call.
92 virtual void SetBestServiceToConnect(const std::string& service_path) = 0;
94 protected:
95 virtual ~TestInterface() {}
98 // Properties used to verify the origin device.
99 struct VerificationProperties {
100 VerificationProperties();
101 ~VerificationProperties();
103 // A string containing a PEM-encoded X.509 certificate for use in verifying
104 // the signed data.
105 std::string certificate;
107 // A string containing a PEM-encoded RSA public key to be used to compare
108 // with the one in signedData
109 std::string public_key;
111 // A string containing a base64-encoded random binary data for use in
112 // verifying the signed data.
113 std::string nonce;
115 // A string containing the identifying data string signed by the device.
116 std::string signed_data;
118 // A string containing the serial number of the device.
119 std::string device_serial;
121 // A string containing the SSID of the device. Only set if the device has
122 // already been setup once.
123 std::string device_ssid;
125 // A string containing the BSSID of the device. Only set if the device has
126 // already been setup.
127 std::string device_bssid;
130 ~ShillManagerClient() override;
132 // Factory function, creates a new instance which is owned by the caller.
133 // For normal usage, access the singleton via DBusThreadManager::Get().
134 static ShillManagerClient* Create();
136 // Adds a property changed |observer|.
137 virtual void AddPropertyChangedObserver(
138 ShillPropertyChangedObserver* observer) = 0;
140 // Removes a property changed |observer|.
141 virtual void RemovePropertyChangedObserver(
142 ShillPropertyChangedObserver* observer) = 0;
144 // Calls GetProperties method.
145 // |callback| is called after the method call succeeds.
146 virtual void GetProperties(const DictionaryValueCallback& callback) = 0;
148 // Calls GetNetworksForGeolocation method.
149 // |callback| is called after the method call succeeds.
150 virtual void GetNetworksForGeolocation(
151 const DictionaryValueCallback& callback) = 0;
153 // Calls SetProperty method.
154 // |callback| is called after the method call succeeds.
155 virtual void SetProperty(const std::string& name,
156 const base::Value& value,
157 const base::Closure& callback,
158 const ErrorCallback& error_callback) = 0;
160 // Calls RequestScan method.
161 // |callback| is called after the method call succeeds.
162 virtual void RequestScan(const std::string& type,
163 const base::Closure& callback,
164 const ErrorCallback& error_callback) = 0;
166 // Calls EnableTechnology method.
167 // |callback| is called after the method call succeeds.
168 virtual void EnableTechnology(const std::string& type,
169 const base::Closure& callback,
170 const ErrorCallback& error_callback) = 0;
172 // Calls DisableTechnology method.
173 // |callback| is called after the method call succeeds.
174 virtual void DisableTechnology(const std::string& type,
175 const base::Closure& callback,
176 const ErrorCallback& error_callback) = 0;
178 // Calls ConfigureService method.
179 // |callback| is called after the method call succeeds.
180 virtual void ConfigureService(const base::DictionaryValue& properties,
181 const ObjectPathCallback& callback,
182 const ErrorCallback& error_callback) = 0;
184 // Calls ConfigureServiceForProfile method.
185 // |callback| is called with the created service if the method call succeeds.
186 virtual void ConfigureServiceForProfile(
187 const dbus::ObjectPath& profile_path,
188 const base::DictionaryValue& properties,
189 const ObjectPathCallback& callback,
190 const ErrorCallback& error_callback) = 0;
192 // Calls GetService method.
193 // |callback| is called after the method call succeeds.
194 virtual void GetService(const base::DictionaryValue& properties,
195 const ObjectPathCallback& callback,
196 const ErrorCallback& error_callback) = 0;
198 // Verifies that the given data corresponds to a trusted device, and returns
199 // true to the callback if it is.
200 virtual void VerifyDestination(const VerificationProperties& properties,
201 const BooleanCallback& callback,
202 const ErrorCallback& error_callback) = 0;
204 // Verifies that the given data corresponds to a trusted device, and if it is,
205 // returns the encrypted credentials for connecting to the network represented
206 // by the given |service_path|, encrypted using the |public_key| for the
207 // trusted device. If the device is not trusted, returns the empty string.
208 virtual void VerifyAndEncryptCredentials(
209 const VerificationProperties& properties,
210 const std::string& service_path,
211 const StringCallback& callback,
212 const ErrorCallback& error_callback) = 0;
214 // Verifies that the given data corresponds to a trusted device, and returns
215 // the |data| encrypted using the |public_key| for the trusted device. If the
216 // device is not trusted, returns the empty string.
217 virtual void VerifyAndEncryptData(const VerificationProperties& properties,
218 const std::string& data,
219 const StringCallback& callback,
220 const ErrorCallback& error_callback) = 0;
222 // For each technology present, connects to the "best" service available.
223 // Called once the user is logged in and certificates are loaded.
224 virtual void ConnectToBestServices(const base::Closure& callback,
225 const ErrorCallback& error_callback) = 0;
227 // Returns an interface for testing (stub only), or returns NULL.
228 virtual TestInterface* GetTestInterface() = 0;
230 protected:
231 friend class ShillManagerClientTest;
233 // Create() should be used instead.
234 ShillManagerClient();
236 private:
237 DISALLOW_COPY_AND_ASSIGN(ShillManagerClient);
240 } // namespace chromeos
242 #endif // CHROMEOS_DBUS_SHILL_MANAGER_CLIENT_H_