| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 auto id_iter = device_id_to_address_map.find(device_id); | 112 auto id_iter = device_id_to_address_map.find(device_id); |
| 113 | 113 |
| 114 return id_iter == device_id_to_address_map.end() ? base::EmptyString() | 114 return id_iter == device_id_to_address_map.end() ? base::EmptyString() |
| 115 : id_iter->second; | 115 : id_iter->second; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( | 118 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( |
| 119 const url::Origin& origin, | 119 const url::Origin& origin, |
| 120 const WebBluetoothDeviceId& device_id, | 120 const WebBluetoothDeviceId& device_id, |
| 121 const BluetoothUUID& service_uuid) const { | 121 const BluetoothUUID& service_uuid) const { |
| 122 if (BluetoothBlacklist::Get().IsExcluded(service_uuid)) { | 122 if (BluetoothBlocklist::Get().IsExcluded(service_uuid)) { |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); | 126 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); |
| 127 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { | 127 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 | 130 |
| 131 const auto& device_id_to_services_map = id_map_iter->second; | 131 const auto& device_id_to_services_map = id_map_iter->second; |
| 132 | 132 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 154 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { | 154 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { |
| 155 unionOfServices->insert(uuid.value()); | 155 unionOfServices->insert(uuid.value()); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { | 158 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { |
| 159 unionOfServices->insert(uuid.value()); | 159 unionOfServices->insert(uuid.value()); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace content | 163 } // namespace content |
| OLD | NEW |