| 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" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 const auto& device_id_to_address_map = id_map_iter->second; | 110 const auto& device_id_to_address_map = id_map_iter->second; |
| 111 | 111 |
| 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::IsOriginAllowedToAccessAtLeastOneService( |
| 119 const url::Origin& origin, |
| 120 const WebBluetoothDeviceId& device_id) const { |
| 121 auto id_map_iter = origin_to_device_id_to_services_map_.find(origin); |
| 122 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { |
| 123 return false; |
| 124 } |
| 125 |
| 126 const auto& device_id_to_services_map = id_map_iter->second; |
| 127 |
| 128 auto id_iter = device_id_to_services_map.find(device_id); |
| 129 |
| 130 return id_iter == device_id_to_services_map.end() ? false |
| 131 : !id_iter->second.empty(); |
| 132 } |
| 133 |
| 118 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( | 134 bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService( |
| 119 const url::Origin& origin, | 135 const url::Origin& origin, |
| 120 const WebBluetoothDeviceId& device_id, | 136 const WebBluetoothDeviceId& device_id, |
| 121 const BluetoothUUID& service_uuid) const { | 137 const BluetoothUUID& service_uuid) const { |
| 122 if (BluetoothBlacklist::Get().IsExcluded(service_uuid)) { | 138 if (BluetoothBlacklist::Get().IsExcluded(service_uuid)) { |
| 123 return false; | 139 return false; |
| 124 } | 140 } |
| 125 | 141 |
| 126 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); |
| 127 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()) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 154 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { | 170 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { |
| 155 unionOfServices->insert(uuid.value()); | 171 unionOfServices->insert(uuid.value()); |
| 156 } | 172 } |
| 157 } | 173 } |
| 158 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { | 174 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { |
| 159 unionOfServices->insert(uuid.value()); | 175 unionOfServices->insert(uuid.value()); |
| 160 } | 176 } |
| 161 } | 177 } |
| 162 | 178 |
| 163 } // namespace content | 179 } // namespace content |
| OLD | NEW |