Index: content/browser/bluetooth/web_bluetooth_service_impl.h |
diff --git a/content/browser/bluetooth/web_bluetooth_service_impl.h b/content/browser/bluetooth/web_bluetooth_service_impl.h |
index 44e1858594e1486fefd0dc2ec68506b72c5a9fc5..803779f33e71d2154b3b9d338f5b7f7150ee102c 100644 |
--- a/content/browser/bluetooth/web_bluetooth_service_impl.h |
+++ b/content/browser/bluetooth/web_bluetooth_service_impl.h |
@@ -11,6 +11,7 @@ |
#include "base/macros.h" |
#include "content/browser/bad_message.h" |
+#include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" |
#include "content/browser/bluetooth/cache_query_result.h" |
#include "content/common/content_export.h" |
#include "content/public/browser/web_contents_observer.h" |
@@ -28,7 +29,8 @@ class Origin; |
namespace content { |
-class BluetoothDispatcherHost; |
+class BluetoothDeviceProvider; |
+class BluetoothAdapterFactoryWrapper; |
class FrameConnectedBluetoothDevices; |
class RenderFrameHost; |
class RenderProcessHost; |
@@ -66,8 +68,10 @@ class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, |
void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
// BluetoothAdapter::Observer: |
- void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
- bool present) override; |
+ void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
+ bool powered) override; |
+ void DeviceAdded(device::BluetoothAdapter* adapter, |
+ device::BluetoothDevice* device) override; |
void DeviceChanged(device::BluetoothAdapter* adapter, |
device::BluetoothDevice* device) override; |
void GattServicesDiscovered(device::BluetoothAdapter* adapter, |
@@ -87,6 +91,8 @@ class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, |
// WebBluetoothService methods: |
void SetClient( |
blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) override; |
+ void RequestDevice(blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
+ const RequestDeviceCallback& callback) override; |
void RemoteServerConnect( |
const mojo::String& device_id, |
const RemoteServerConnectCallback& callback) override; |
@@ -114,6 +120,12 @@ class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, |
const mojo::String& characteristic_instance_id, |
const RemoteCharacteristicStopNotificationsCallback& callback) override; |
+ // Should only be run after we've acquired an adapter from |
+ // BluetoothAdapterFactoryWrapper. |
+ void RequestDeviceImpl( |
+ blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
+ const RequestDeviceCallback& callback); |
+ |
// Should only be run after the services have been discovered for |
// |device_address|. |
void RemoteServerGetPrimaryServiceImpl( |
@@ -121,6 +133,14 @@ class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, |
const RemoteServerGetPrimaryServiceCallback& callback, |
device::BluetoothDevice* device); |
+ // Callbacks for BluetoothDeviceProvider::GetDevice. |
+ void OnGetDeviceSuccess( |
+ blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
+ const RequestDeviceCallback& callback, |
+ const std::string& device_id); |
+ void OnGetDeviceFailed(const RequestDeviceCallback& callback, |
+ blink::mojom::WebBluetoothError error); |
+ |
// Callbacks for BluetoothDevice::CreateGattConnection. |
void OnCreateGATTConnectionSuccess( |
const std::string& device_id, |
@@ -168,6 +188,8 @@ class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, |
// renderer, record the reason and close the pipe, so it's safe to drop |
// any callbacks. |
+ CacheQueryResult QueryCacheForDevice(const std::string& device_id); |
Jeffrey Yasskin
2016/05/13 04:41:59
Comment this function like the other two.
ortuno
2016/05/13 20:11:18
Done.
|
+ |
// Queries the platform cache for a Service with |service_instance_id|. Fills |
// in the |outcome| field, and |device| and |service| fields if successful. |
CacheQueryResult QueryCacheForService(const std::string& service_instance_id); |
@@ -179,13 +201,19 @@ class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, |
const std::string& characteristic_instance_id); |
RenderProcessHost* GetRenderProcessHost(); |
- BluetoothDispatcherHost* GetBluetoothDispatcherHost(); |
+ BluetoothAdapterFactoryWrapper* GetBluetoothAdapterFactoryWrapper(); |
void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); |
url::Origin GetOrigin(); |
// Clears all state (maps, sets, etc). |
void ClearState(); |
+ // Used to open a BluetoothChooser and start a device discovery session. |
+ std::unique_ptr<BluetoothDeviceProvider> device_provider_; |
+ |
+ // Keeps track of which devices the frame's origin is allowed to access. |
+ BluetoothAllowedDevicesMap allowed_devices_map_; |
+ |
// Maps to get the object's parent based on its instanceID. |
std::unordered_map<std::string, std::string> service_id_to_device_address_; |
std::unordered_map<std::string, std::string> characteristic_id_to_service_id_; |