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

Unified Diff: content/browser/bluetooth/bluetooth_allowed_devices_map.cc

Issue 2459523002: bluetooth: Return specific error if getPrimaryServices() is called without requesting access to any… (Closed)
Patch Set: s/foo/TestName/ 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/bluetooth_allowed_devices_map.cc
diff --git a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
index a340edcc08403824698a00bceb21d6e7b1a4933c..7fd80f93a3d7b10662e499dca4addbd1c23ed0b6 100644
--- a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
+++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
@@ -115,6 +115,22 @@ const std::string& BluetoothAllowedDevicesMap::GetDeviceAddress(
: id_iter->second;
}
+bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessAtLeastOneService(
+ const url::Origin& origin,
+ const WebBluetoothDeviceId& device_id) const {
+ auto id_map_iter = origin_to_device_id_to_services_map_.find(origin);
+ if (id_map_iter == origin_to_device_id_to_services_map_.end()) {
+ return false;
+ }
+
+ const auto& device_id_to_services_map = id_map_iter->second;
+
+ auto id_iter = device_id_to_services_map.find(device_id);
+
+ return id_iter == device_id_to_services_map.end() ? false
+ : !id_iter->second.empty();
+}
+
bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService(
const url::Origin& origin,
const WebBluetoothDeviceId& device_id,

Powered by Google App Engine
This is Rietveld 408576698