| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" | 5 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/optional.h" | 11 #include "base/optional.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "content/browser/bluetooth/bluetooth_blacklist.h" | 14 #include "content/browser/bluetooth/bluetooth_blocklist.h" |
| 15 #include "content/common/bluetooth/web_bluetooth_device_id.h" | 15 #include "content/common/bluetooth/web_bluetooth_device_id.h" |
| 16 | 16 |
| 17 using device::BluetoothUUID; | 17 using device::BluetoothUUID; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 BluetoothAllowedDevicesMap::BluetoothAllowedDevicesMap() {} | 21 BluetoothAllowedDevicesMap::BluetoothAllowedDevicesMap() {} |
| 22 BluetoothAllowedDevicesMap::~BluetoothAllowedDevicesMap() {} | 22 BluetoothAllowedDevicesMap::~BluetoothAllowedDevicesMap() {} |
| 23 | 23 |
| 24 const WebBluetoothDeviceId& BluetoothAllowedDevicesMap::AddDevice( | 24 const WebBluetoothDeviceId& BluetoothAllowedDevicesMap::AddDevice( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 auto id_iter = device_id_to_services_map.find(device_id); | 128 auto id_iter = device_id_to_services_map.find(device_id); |
| 129 | 129 |
| 130 return id_iter == device_id_to_services_map.end() ? false | 130 return id_iter == device_id_to_services_map.end() ? false |
| 131 : !id_iter->second.empty(); | 131 : !id_iter->second.empty(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( | 134 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( |
| 135 const url::Origin& origin, | 135 const url::Origin& origin, |
| 136 const WebBluetoothDeviceId& device_id, | 136 const WebBluetoothDeviceId& device_id, |
| 137 const BluetoothUUID& service_uuid) const { | 137 const BluetoothUUID& service_uuid) const { |
| 138 if (BluetoothBlacklist::Get().IsExcluded(service_uuid)) { | 138 if (BluetoothBlocklist::Get().IsExcluded(service_uuid)) { |
| 139 return false; | 139 return false; |
| 140 } | 140 } |
| 141 | 141 |
| 142 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); | 142 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); |
| 143 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { | 143 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 | 146 |
| 147 const auto& device_id_to_services_map = id_map_iter->second; | 147 const auto& device_id_to_services_map = id_map_iter->second; |
| 148 | 148 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 170 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { | 170 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { |
| 171 unionOfServices->insert(uuid.value()); | 171 unionOfServices->insert(uuid.value()); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { | 174 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { |
| 175 unionOfServices->insert(uuid.value()); | 175 unionOfServices->insert(uuid.value()); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace content | 179 } // namespace content |
| OLD | NEW |