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 3 // found in the LICENSE file. 4 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ 7 8 #include "base/bind.h" 9 #include "base/callback.h" 10 #include "base/observer_list.h" 11 #include "chromeos/chromeos_export.h" 12 #include "chromeos/dbus/bluetooth_agent_service_provider.h" 13 #include "chromeos/dbus/dbus_client_implementation_type.h" 14 #include "dbus/object_path.h" 15 #include "dbus/property.h" 16 17 namespace chromeos { 18 19 class FakeBluetoothAgentManagerClient; 20 21 // FakeBluetoothAgentServiceProvider simulates the behavior of a local 22 // Bluetooth agent object and is used both in test cases in place of a 23 // mock and on the Linux desktop. 24 class CHROMEOS_EXPORT FakeBluetoothAgentServiceProvider 25 : public BluetoothAgentServiceProvider { 26 public: 27 FakeBluetoothAgentServiceProvider(const dbus::ObjectPath& object_path, 28 Delegate *delegate); 29 virtual ~FakeBluetoothAgentServiceProvider(); 30 31 // Each of these calls the equivalent BluetoothAgentServiceProvider::Delegate 32 // method on the object passed on construction. 33 virtual void Release(); 34 virtual void RequestPinCode(const dbus::ObjectPath& device_path, 35 const Delegate::PinCodeCallback& callback); 36 virtual void DisplayPinCode(const dbus::ObjectPath& device_path, 37 const std::string& pincode); 38 virtual void RequestPasskey(const dbus::ObjectPath& device_path, 39 const Delegate::PasskeyCallback& callback); 40 virtual void DisplayPasskey(const dbus::ObjectPath& device_path, 41 uint32 passkey, int16 entered); 42 virtual void RequestConfirmation( 43 const dbus::ObjectPath& device_path, 44 uint32 passkey, 45 const Delegate::ConfirmationCallback& callback); 46 virtual void RequestAuthorization( 47 const dbus::ObjectPath& device_path, 48 const Delegate::ConfirmationCallback& callback); 49 virtual void AuthorizeService( 50 const dbus::ObjectPath& device_path, 51 const std::string& uuid, 52 const Delegate::ConfirmationCallback& callback); 53 virtual void Cancel(); 54 55 private: 56 friend class FakeBluetoothAgentManagerClient; 57 58 // D-Bus object path we are faking. 59 dbus::ObjectPath object_path_; 60 61 // All incoming method calls are passed on to the Delegate and a callback 62 // passed to generate the reply. |delegate_| is generally the object that 63 // owns this one, and must outlive it. 64 Delegate* delegate_; 65 }; 66 67 } // namespace chromeos 68 69 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ 70