Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: content/browser/bluetooth/bluetooth_allowed_devices_map.h

Issue 2459523002: bluetooth: Return specific error if getPrimaryServices() is called without requesting access to any… (Closed)
Patch Set: Use script-tests pattern Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(const url::Origin& origin,
55 const std::string& device_address); 55 const std::string& device_address);
56 56
57 // For |device_id| in |origin|, returns the Bluetooth device's address. If 57 // 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. 58 // there is no such |device_id| in |origin|, returns an empty string.
59 const std::string& GetDeviceAddress(const url::Origin& origin, 59 const std::string& GetDeviceAddress(const url::Origin& origin,
60 const WebBluetoothDeviceId& device_id); 60 const WebBluetoothDeviceId& device_id);
61 61
62 // Returns true if the origin has previously been granted access to at least
63 // one service.
64 bool IsOriginAllowedToAccessAtLeastOneService(
ortuno 2016/11/03 21:31:21 Ah sorry for not noticing earlier. Please add test
François Beaufort 2016/11/04 09:57:26 Done.
65 const url::Origin& origin,
66 const WebBluetoothDeviceId& device_id) const;
67
62 // Returns true if the origin has previously been granted access to 68 // Returns true if the origin has previously been granted access to
63 // the service. 69 // the service.
64 bool IsOriginAllowedToAccessService( 70 bool IsOriginAllowedToAccessService(
65 const url::Origin& origin, 71 const url::Origin& origin,
66 const WebBluetoothDeviceId& device_id, 72 const WebBluetoothDeviceId& device_id,
67 const device::BluetoothUUID& service_uuid) const; 73 const device::BluetoothUUID& service_uuid) const;
68 74
69 private: 75 private:
70 typedef std::unordered_map<std::string, WebBluetoothDeviceId> 76 typedef std::unordered_map<std::string, WebBluetoothDeviceId>
71 DeviceAddressToIdMap; 77 DeviceAddressToIdMap;
(...skipping 27 matching lines...) Expand all
99 origin_to_device_id_to_services_map_; 105 origin_to_device_id_to_services_map_;
100 106
101 // Keep track of all device_ids in the map. 107 // Keep track of all device_ids in the map.
102 std::unordered_set<WebBluetoothDeviceId, WebBluetoothDeviceIdHash> 108 std::unordered_set<WebBluetoothDeviceId, WebBluetoothDeviceIdHash>
103 device_id_set_; 109 device_id_set_;
104 }; 110 };
105 111
106 } // namespace content 112 } // namespace content
107 113
108 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_ 114 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_ALLOWED_DEVICES_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698