#ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_PRIVATE_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_PRIVATE_API_H_
#include "base/callback_forward.h"
#include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
namespace device {
class BluetoothAdapter;
}
namespace extensions {
class BluetoothApiPairingDelegate;
class BluetoothPrivateAPI : public BrowserContextKeyedAPI,
public EventRouter::Observer {
public:
static BrowserContextKeyedAPIFactory<BluetoothPrivateAPI>*
GetFactoryInstance();
explicit BluetoothPrivateAPI(content::BrowserContext* context);
virtual ~BluetoothPrivateAPI();
virtual void Shutdown() OVERRIDE;
virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
static const char* service_name() { return "BluetoothPrivateAPI"; }
static const bool kServiceRedirectedInIncognito = true;
static const bool kServiceIsNULLWhileTesting = true;
private:
friend class BrowserContextKeyedAPIFactory<BluetoothPrivateAPI>;
content::BrowserContext* browser_context_;
};
namespace api {
class BluetoothPrivateSetAdapterStateFunction
: public BluetoothExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothPrivate.setAdapterState",
BLUETOOTHPRIVATE_SETADAPTERSTATE)
BluetoothPrivateSetAdapterStateFunction();
private:
virtual ~BluetoothPrivateSetAdapterStateFunction();
base::Closure CreatePropertySetCallback(const std::string& property_name);
base::Closure CreatePropertyErrorCallback(const std::string& property_name);
void OnAdapterPropertySet(const std::string& property);
void OnAdapterPropertyError(const std::string& property);
void SendError();
virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
std::set<std::string> pending_properties_;
std::set<std::string> failed_properties_;
DISALLOW_COPY_AND_ASSIGN(BluetoothPrivateSetAdapterStateFunction);
};
class BluetoothPrivateEnablePairingFunction
: public BluetoothExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothPrivate.enablePairing",
BLUETOOTHPRIVATE_ENABLEPAIRING)
BluetoothPrivateEnablePairingFunction();
virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
private:
virtual ~BluetoothPrivateEnablePairingFunction();
DISALLOW_COPY_AND_ASSIGN(BluetoothPrivateEnablePairingFunction);
};
class BluetoothPrivateDisablePairingFunction
: public BluetoothExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothPrivate.disablePairing",
BLUETOOTHPRIVATE_DISABLEPAIRING)
BluetoothPrivateDisablePairingFunction();
virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
private:
virtual ~BluetoothPrivateDisablePairingFunction();
DISALLOW_COPY_AND_ASSIGN(BluetoothPrivateDisablePairingFunction);
};
class BluetoothPrivateSetPairingResponseFunction
: public BluetoothExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothPrivate.setPairingResponse",
BLUETOOTHPRIVATE_SETPAIRINGRESPONSE)
BluetoothPrivateSetPairingResponseFunction();
virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
private:
virtual ~BluetoothPrivateSetPairingResponseFunction();
DISALLOW_COPY_AND_ASSIGN(BluetoothPrivateSetPairingResponseFunction);
};
}
}
#endif