[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_manager_client.h
blob1d0cde9b4317045a09d3a5b084c7a4073b3c967e
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_BLUETOOTH_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/observer_list.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/bluetooth_property.h"
15 #include "chromeos/dbus/dbus_client_implementation_type.h"
16 #include "dbus/object_path.h"
18 namespace dbus {
19 class Bus;
20 } // namespace dbus
22 namespace chromeos {
24 // BluetoothManagerClient is used to communicate with the bluetooth
25 // daemon's Manager interface.
26 class CHROMEOS_EXPORT BluetoothManagerClient {
27 public:
28 // Structure of properties associated with the bluetooth manager.
29 struct Properties : public BluetoothPropertySet {
30 // List of object paths of local Bluetooth adapters. Read-only.
31 dbus::Property<std::vector<dbus::ObjectPath> > adapters;
33 Properties(dbus::ObjectProxy* object_proxy,
34 const PropertyChangedCallback& callback);
35 virtual ~Properties();
38 // Interface for observing changes from the bluetooth manager.
39 class Observer {
40 public:
41 virtual ~Observer() {}
43 // Called when the manager has a change in value of the property
44 // named |property_name|.
45 virtual void ManagerPropertyChanged(const std::string& property_name) {}
47 // Called when a local bluetooth adapter is added.
48 // |object_path| is the dbus object path of the adapter.
49 virtual void AdapterAdded(const dbus::ObjectPath& object_path) {}
51 // Called when a local bluetooth adapter is removed.
52 // |object_path| is the dbus object path of the adapter.
53 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {}
55 // Called when the default local bluetooth adapter changes.
56 // |object_path| is the dbus object path of the new default adapter.
57 // Not called if all adapters are removed.
58 virtual void DefaultAdapterChanged(const dbus::ObjectPath& object_path) {}
61 virtual ~BluetoothManagerClient();
63 // Adds and removes observers.
64 virtual void AddObserver(Observer* observer) = 0;
65 virtual void RemoveObserver(Observer* observer) = 0;
67 // Obtain the properties for the manager, any values should be copied
68 // if needed.
69 virtual Properties* GetProperties() = 0;
71 // The AdapterCallback is used for both the DefaultAdapter() and
72 // FindAdapter() methods. It receives two arguments, the |object_path|
73 // of the adapter and |success| which indicates whether or not the request
74 // succeeded.
75 typedef base::Callback<void(const dbus::ObjectPath&, bool)> AdapterCallback;
77 // Retrieves the dbus object path for the default adapter.
78 // The default adapter is the preferred local bluetooth interface when a
79 // client does not specify a particular interface.
80 virtual void DefaultAdapter(const AdapterCallback& callback) = 0;
82 // Retrieves the dbus object path for the adapter with the address |address|,
83 // which may also be an interface name.
84 virtual void FindAdapter(const std::string& address,
85 const AdapterCallback& callback) = 0;
87 // Creates the instance.
88 static BluetoothManagerClient* Create(DBusClientImplementationType type,
89 dbus::Bus* bus);
91 protected:
92 BluetoothManagerClient();
94 private:
95 DISALLOW_COPY_AND_ASSIGN(BluetoothManagerClient);
98 } // namespace chromeos
100 #endif // CHROMEOS_DBUS_BLUETOOTH_MANAGER_CLIENT_H_