| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "content/browser/bluetooth/bluetooth_blacklist.h" |
| 13 #include "content/common/bluetooth/bluetooth_scan_filter.h" | 14 #include "content/common/bluetooth/bluetooth_scan_filter.h" |
| 14 #include "crypto/random.h" | 15 #include "crypto/random.h" |
| 15 #include "device/bluetooth/bluetooth_uuid.h" | 16 #include "device/bluetooth/bluetooth_uuid.h" |
| 16 | 17 |
| 17 using device::BluetoothUUID; | 18 using device::BluetoothUUID; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 const size_t kIdLength = 16 /* 128bits */; | 23 const size_t kIdLength = 16 /* 128bits */; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 auto id_iter = device_id_to_address_map.find(device_id); | 134 auto id_iter = device_id_to_address_map.find(device_id); |
| 134 | 135 |
| 135 return id_iter == device_id_to_address_map.end() ? base::EmptyString() | 136 return id_iter == device_id_to_address_map.end() ? base::EmptyString() |
| 136 : id_iter->second; | 137 : id_iter->second; |
| 137 } | 138 } |
| 138 | 139 |
| 139 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( | 140 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( |
| 140 const url::Origin& origin, | 141 const url::Origin& origin, |
| 141 const std::string& device_id, | 142 const std::string& device_id, |
| 142 const std::string& service_uuid) const { | 143 const std::string& service_uuid) const { |
| 144 if (BluetoothBlacklist::Get().IsExcluded(BluetoothUUID(service_uuid))) |
| 145 return false; |
| 146 |
| 143 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); | 147 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); |
| 144 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { | 148 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { |
| 145 return false; | 149 return false; |
| 146 } | 150 } |
| 147 | 151 |
| 148 const auto& device_id_to_services_map = id_map_iter->second; | 152 const auto& device_id_to_services_map = id_map_iter->second; |
| 149 | 153 |
| 150 auto id_iter = device_id_to_services_map.find(device_id); | 154 auto id_iter = device_id_to_services_map.find(device_id); |
| 151 | 155 |
| 152 return id_iter == device_id_to_services_map.end() | 156 return id_iter == device_id_to_services_map.end() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 171 for (const BluetoothUUID& uuid : filter.services) { | 175 for (const BluetoothUUID& uuid : filter.services) { |
| 172 unionOfServices->insert(uuid.canonical_value()); | 176 unionOfServices->insert(uuid.canonical_value()); |
| 173 } | 177 } |
| 174 } | 178 } |
| 175 for (const BluetoothUUID& uuid : optional_services) { | 179 for (const BluetoothUUID& uuid : optional_services) { |
| 176 unionOfServices->insert(uuid.canonical_value()); | 180 unionOfServices->insert(uuid.canonical_value()); |
| 177 } | 181 } |
| 178 } | 182 } |
| 179 | 183 |
| 180 } // namespace content | 184 } // namespace content |
| OLD | NEW |