mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fix BluetoothPermissionResult return state
This commit is contained in:
parent
f7e86d2d0e
commit
b1d388a991
2 changed files with 4 additions and 3 deletions
|
@ -215,12 +215,12 @@ impl Bluetooth {
|
||||||
let option = RequestDeviceoptions::new(BluetoothScanfilterSequence::new(uuid_filters),
|
let option = RequestDeviceoptions::new(BluetoothScanfilterSequence::new(uuid_filters),
|
||||||
ServiceUUIDSequence::new(optional_services_uuids));
|
ServiceUUIDSequence::new(optional_services_uuids));
|
||||||
|
|
||||||
// Step 3 - 5
|
// Step 4 - 5.
|
||||||
if let PermissionState::Denied = get_descriptor_permission_state(PermissionName::Bluetooth, None) {
|
if let PermissionState::Denied = get_descriptor_permission_state(PermissionName::Bluetooth, None) {
|
||||||
return p.reject_error(p.global().get_cx(), Error::NotFound);
|
return p.reject_error(p.global().get_cx(), Error::NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Steps 6 - 8 are implemented in
|
// Note: Step 3, 6 - 8 are implemented in
|
||||||
// components/net/bluetooth_thread.rs in request_device function.
|
// components/net/bluetooth_thread.rs in request_device function.
|
||||||
self.get_bluetooth_thread().send(BluetoothRequest::RequestDevice(option, sender)).unwrap();
|
self.get_bluetooth_thread().send(BluetoothRequest::RequestDevice(option, sender)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,9 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
|
||||||
fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
|
fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
|
||||||
match response {
|
match response {
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
|
||||||
// Step 11, 13 - 14.
|
// Step 3, 11, 13 - 14.
|
||||||
BluetoothResponse::RequestDevice(device) => {
|
BluetoothResponse::RequestDevice(device) => {
|
||||||
|
self.set_state(PermissionState::Granted);
|
||||||
let bluetooth = self.get_bluetooth();
|
let bluetooth = self.get_bluetooth();
|
||||||
let mut device_instance_map = bluetooth.get_device_map().borrow_mut();
|
let mut device_instance_map = bluetooth.get_device_map().borrow_mut();
|
||||||
if let Some(ref existing_device) = device_instance_map.get(&device.id) {
|
if let Some(ref existing_device) = device_instance_map.get(&device.id) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue