WebBluetooth API classes

This commit is contained in:
Attila Dusnoki 2016-03-02 15:00:13 +01:00
parent 00628704ca
commit e7d70cfabf
28 changed files with 999 additions and 28 deletions

View file

@ -5,8 +5,9 @@
use dom::bindings::codegen::Bindings::NavigatorBinding;
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
use dom::bluetooth::Bluetooth;
use dom::navigatorinfo;
use dom::window::Window;
use util::str::DOMString;
@ -14,12 +15,14 @@ use util::str::DOMString;
#[dom_struct]
pub struct Navigator {
reflector_: Reflector,
bluetooth: MutNullableHeap<JS<Bluetooth>>,
}
impl Navigator {
fn new_inherited() -> Navigator {
Navigator {
reflector_: Reflector::new()
reflector_: Reflector::new(),
bluetooth: Default::default(),
}
}
@ -65,4 +68,9 @@ impl NavigatorMethods for Navigator {
fn AppVersion(&self) -> DOMString {
navigatorinfo::AppVersion()
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
fn Bluetooth(&self) -> Root<Bluetooth> {
self.bluetooth.or_init(|| Bluetooth::new(self.global().r()))
}
}