aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetoothremotegattservice.rs
diff options
context:
space:
mode:
authorfokinv <fokinv@inf.u-szeged.hu>2016-05-20 13:19:58 +0200
committerAttila Dusnoki <dati91@gmail.com>2016-05-31 17:05:45 +0200
commita920e6d54e4e75e06ac8ac5029f9aa69fdf31ae8 (patch)
tree473b5d5892ace996d2afccdcbc7fbfe61f7ef13a /components/script/dom/bluetoothremotegattservice.rs
parentb11648903bb07a31ec93f3030058ed41b3472b17 (diff)
downloadservo-a920e6d54e4e75e06ac8ac5029f9aa69fdf31ae8.tar.gz
servo-a920e6d54e4e75e06ac8ac5029f9aa69fdf31ae8.zip
Add WebBluetooth Blacklist support
Diffstat (limited to 'components/script/dom/bluetoothremotegattservice.rs')
-rw-r--r--components/script/dom/bluetoothremotegattservice.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs
index 78427f7f6de..48cf9be6361 100644
--- a/components/script/dom/bluetoothremotegattservice.rs
+++ b/components/script/dom/bluetoothremotegattservice.rs
@@ -2,9 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
-use dom::bindings::error::Error::Type;
+use dom::bindings::error::Error::{Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, MutHeap, Root};
@@ -88,6 +89,9 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
characteristic: BluetoothCharacteristicUUID)
-> Fallible<Root<BluetoothRemoteGATTCharacteristic>> {
let uuid = try!(BluetoothUUID::GetCharacteristic(self.global().r(), characteristic)).to_string();
+ if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
+ return Err(Security)
+ }
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::GetCharacteristic(self.get_instance_id(), uuid, sender)).unwrap();
@@ -122,7 +126,12 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
-> Fallible<Vec<Root<BluetoothRemoteGATTCharacteristic>>> {
let mut uuid: Option<String> = None;
if let Some(c) = characteristic {
- uuid = Some(try!(BluetoothUUID::GetCharacteristic(self.global().r(), c)).to_string())
+ uuid = Some(try!(BluetoothUUID::GetCharacteristic(self.global().r(), c)).to_string());
+ if let Some(ref uuid) = uuid {
+ if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
+ return Err(Security)
+ }
+ }
};
let mut characteristics = vec!();
let (sender, receiver) = ipc::channel().unwrap();