| 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 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ | 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ |
| 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ | 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const std::string& device_address, | 44 const std::string& device_address, |
| 45 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options); | 45 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options); |
| 46 | 46 |
| 47 // Removes the Bluetooth Device with |device_address| from the map of allowed | 47 // Removes the Bluetooth Device with |device_address| from the map of allowed |
| 48 // devices for |origin|. | 48 // devices for |origin|. |
| 49 void RemoveDevice(const url::Origin& origin, | 49 void RemoveDevice(const url::Origin& origin, |
| 50 const std::string& device_address); | 50 const std::string& device_address); |
| 51 | 51 |
| 52 // Returns the Bluetooth Device's id for |origin| if |origin| is allowed to | 52 // Returns the Bluetooth Device's id for |origin| if |origin| is allowed to |
| 53 // access the device. | 53 // access the device. |
| 54 const WebBluetoothDeviceId* GetDeviceId(const url::Origin& origin, | 54 const WebBluetoothDeviceId* GetDeviceId( |
| 55 const std::string& device_address); | 55 const url::Origin& origin, |
| 56 const std::string& device_address) const; |
| 56 | 57 |
| 57 // For |device_id| in |origin|, returns the Bluetooth device's address. If | 58 // For |device_id| in |origin|, returns the Bluetooth device's address. If |
| 58 // there is no such |device_id| in |origin|, returns an empty string. | 59 // there is no such |device_id| in |origin|, returns an empty string. |
| 59 const std::string& GetDeviceAddress(const url::Origin& origin, | 60 const std::string& GetDeviceAddress(const url::Origin& origin, |
| 60 const WebBluetoothDeviceId& device_id); | 61 const WebBluetoothDeviceId& device_id); |
| 61 | 62 |
| 62 // Returns true if the origin has previously been granted access to | 63 // Returns true if the origin has previously been granted access to |
| 63 // the service. | 64 // the service. |
| 64 bool IsOriginAllowedToAccessService( | 65 bool IsOriginAllowedToAccessService( |
| 65 const url::Origin& origin, | 66 const url::Origin& origin, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 origin_to_device_id_to_services_map_; | 100 origin_to_device_id_to_services_map_; |
| 100 | 101 |
| 101 // Keep track of all device_ids in the map. | 102 // Keep track of all device_ids in the map. |
| 102 std::unordered_set<WebBluetoothDeviceId, WebBluetoothDeviceIdHash> | 103 std::unordered_set<WebBluetoothDeviceId, WebBluetoothDeviceIdHash> |
| 103 device_id_set_; | 104 device_id_set_; |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 } // namespace content | 107 } // namespace content |
| 107 | 108 |
| 108 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ | 109 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ |
| OLD | NEW |