mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Bluetooth Permission API integration
This commit is contained in:
parent
f3ddee5dbc
commit
5287cd3bea
17 changed files with 550 additions and 45 deletions
|
@ -7,6 +7,8 @@ use dom::bindings::codegen::Bindings::PermissionsBinding::{self, PermissionsMeth
|
|||
use dom::bindings::error::Error;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||
use dom::bluetooth::Bluetooth;
|
||||
use dom::bluetoothpermissionresult::BluetoothPermissionResult;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::permissionstatus::PermissionStatus;
|
||||
use dom::promise::Promise;
|
||||
|
@ -79,6 +81,20 @@ impl PermissionsMethods for Permissions {
|
|||
|
||||
// Step 2.
|
||||
match root_desc.name {
|
||||
PermissionName::Bluetooth => {
|
||||
let bluetooth_desc = match Bluetooth::create_descriptor(cx, permissionDesc) {
|
||||
Ok(descriptor) => descriptor,
|
||||
Err(error) => {
|
||||
p.reject_error(cx, error);
|
||||
return p;
|
||||
},
|
||||
};
|
||||
// Step 5.
|
||||
let result = BluetoothPermissionResult::new(&self.global(), &status);
|
||||
// Step 6.
|
||||
Bluetooth::permission_query(cx, &p, &bluetooth_desc, &result);
|
||||
// Step 7. in permission_query
|
||||
},
|
||||
_ => {
|
||||
// Step 6.
|
||||
Permissions::permission_query(cx, &p, &root_desc, &status);
|
||||
|
@ -113,6 +129,20 @@ impl PermissionsMethods for Permissions {
|
|||
|
||||
// Step 2.
|
||||
match root_desc.name {
|
||||
PermissionName::Bluetooth => {
|
||||
let bluetooth_desc = match Bluetooth::create_descriptor(cx, permissionDesc) {
|
||||
Ok(descriptor) => descriptor,
|
||||
Err(error) => {
|
||||
p.reject_error(cx, error);
|
||||
return p;
|
||||
},
|
||||
};
|
||||
// Step 5.
|
||||
let result = BluetoothPermissionResult::new(&self.global(), &status);
|
||||
// Step 6.
|
||||
Bluetooth::permission_request(cx, &p, &bluetooth_desc, &result);
|
||||
// Step 7 - 8. in permission_request
|
||||
},
|
||||
_ => {
|
||||
// Step 6.
|
||||
Permissions::permission_request(cx, &p, &root_desc, &status);
|
||||
|
@ -145,6 +175,19 @@ impl PermissionsMethods for Permissions {
|
|||
|
||||
// Step 2.
|
||||
match root_desc.name {
|
||||
PermissionName::Bluetooth => {
|
||||
let bluetooth_desc = match Bluetooth::create_descriptor(cx, permissionDesc) {
|
||||
Ok(descriptor) => descriptor,
|
||||
Err(error) => {
|
||||
let p = Promise::new(&self.global());
|
||||
p.reject_error(cx, error);
|
||||
return p;
|
||||
},
|
||||
};
|
||||
let result = BluetoothPermissionResult::new(&self.global(), &status);
|
||||
// Step 3 - 4. in permission_revoke
|
||||
Bluetooth::permission_revoke(&bluetooth_desc, &result);
|
||||
},
|
||||
_ => {
|
||||
Permissions::permission_revoke(&root_desc, &status);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue