| Index: content/browser/bluetooth/bluetooth_allowed_devices_map.cc
|
| diff --git a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
|
| index cd2e78929a3d2edab26522c518ac40ea406967fd..1f9b2cfd755cc00b7b5685266369e9a2b4940b5d 100644
|
| --- a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
|
| +++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
|
| @@ -11,9 +11,7 @@
|
| #include "base/stl_util.h"
|
| #include "base/strings/string_util.h"
|
| #include "content/browser/bluetooth/bluetooth_blacklist.h"
|
| -#include "content/common/bluetooth/bluetooth_scan_filter.h"
|
| #include "crypto/random.h"
|
| -#include "device/bluetooth/bluetooth_uuid.h"
|
|
|
| using device::BluetoothUUID;
|
|
|
| @@ -42,18 +40,11 @@ BluetoothAllowedDevicesMap::~BluetoothAllowedDevicesMap() {}
|
| const std::string& BluetoothAllowedDevicesMap::AddDevice(
|
| const url::Origin& origin,
|
| const std::string& device_address,
|
| - const std::vector<BluetoothScanFilter>& filters,
|
| - const std::vector<BluetoothUUID>& optional_services) {
|
| + const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
|
| VLOG(1) << "Adding a device to Map of Allowed Devices.";
|
|
|
| - // "Unique" Origins generate the same key in maps. The set of "unique"
|
| - // Origins that generate the same key does not intersect the set of
|
| - // potentially trustworthy origins; since Bluetooth is only available for
|
| - // potntially trustworthy origins we should never receive a request from a
|
| - // "unique" Origin.
|
| - // See url::Origin for what constitutes a "unique" Origin and the
|
| - // Secure Contexts spec for what constitutes a Trusworthy Origin:
|
| - // https://w3c.github.io/webappsec-secure-contexts/
|
| + // "Unique" Origins generate the same key in maps, therefore are not
|
| + // supported.
|
| CHECK(!origin.unique());
|
|
|
| auto device_address_to_id_map = origin_to_device_address_to_id_map_[origin];
|
| @@ -63,8 +54,7 @@ const std::string& BluetoothAllowedDevicesMap::AddDevice(
|
| const auto& device_id = id_iter->second;
|
|
|
| AddUnionOfServicesTo(
|
| - filters, optional_services,
|
| - &origin_to_device_id_to_services_map_[origin][device_id]);
|
| + options, &origin_to_device_id_to_services_map_[origin][device_id]);
|
|
|
| return origin_to_device_address_to_id_map_[origin][device_address];
|
| }
|
| @@ -74,8 +64,7 @@ const std::string& BluetoothAllowedDevicesMap::AddDevice(
|
| origin_to_device_address_to_id_map_[origin][device_address] = device_id;
|
| origin_to_device_id_to_address_map_[origin][device_id] = device_address;
|
| AddUnionOfServicesTo(
|
| - filters, optional_services,
|
| - &origin_to_device_id_to_services_map_[origin][device_id]);
|
| + options, &origin_to_device_id_to_services_map_[origin][device_id]);
|
|
|
| CHECK(device_id_set_.insert(device_id).second);
|
|
|
| @@ -141,8 +130,9 @@ bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService(
|
| const url::Origin& origin,
|
| const std::string& device_id,
|
| const std::string& service_uuid) const {
|
| - if (BluetoothBlacklist::Get().IsExcluded(BluetoothUUID(service_uuid)))
|
| + if (BluetoothBlacklist::Get().IsExcluded(BluetoothUUID(service_uuid))) {
|
| return false;
|
| + }
|
|
|
| auto id_map_iter = origin_to_device_id_to_services_map_.find(origin);
|
| if (id_map_iter == origin_to_device_id_to_services_map_.end()) {
|
| @@ -168,16 +158,15 @@ std::string BluetoothAllowedDevicesMap::GenerateDeviceId() {
|
| }
|
|
|
| void BluetoothAllowedDevicesMap::AddUnionOfServicesTo(
|
| - const std::vector<BluetoothScanFilter>& filters,
|
| - const std::vector<device::BluetoothUUID>& optional_services,
|
| + const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options,
|
| std::set<std::string>* unionOfServices) {
|
| - for (const auto& filter : filters) {
|
| - for (const BluetoothUUID& uuid : filter.services) {
|
| - unionOfServices->insert(uuid.canonical_value());
|
| + for (const auto& filter : options->filters) {
|
| + for (const std::string& uuid : filter->services) {
|
| + unionOfServices->insert(uuid);
|
| }
|
| }
|
| - for (const BluetoothUUID& uuid : optional_services) {
|
| - unionOfServices->insert(uuid.canonical_value());
|
| + for (const std::string& uuid : options->optional_services) {
|
| + unionOfServices->insert(uuid);
|
| }
|
| }
|
|
|
|
|