servo/components/script/dom/navigator.rs
bors-servo f350879574 auto merge of #3666 : ttaubert/servo/issue/3644-privatize-dom, r=Manishearth
This PR removes public fields from all (hope I didn't miss any) DOM structs. Should |Page| be privatized as well? This PR additionally introduces a #[privatize] lint to ensure nobody accidentally re-introduces a public field.

All changesets compile separately if applied in the same order. Hope that helps reviewing but I can of course squash them before merging.
2014-10-13 22:00:37 -06:00

65 lines
1.7 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 dom::bindings::codegen::Bindings::NavigatorBinding;
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
use dom::bindings::global;
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::navigatorinfo::NavigatorInfo;
use dom::window::Window;
use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct Navigator {
reflector_: Reflector //XXXjdm cycle: window->navigator->window
}
impl Navigator {
fn new_inherited() -> Navigator {
Navigator {
reflector_: Reflector::new()
}
}
pub fn new(window: JSRef<Window>) -> Temporary<Navigator> {
reflect_dom_object(box Navigator::new_inherited(),
&global::Window(window),
NavigatorBinding::Wrap)
}
}
impl<'a> NavigatorMethods for JSRef<'a, Navigator> {
fn Product(self) -> DOMString {
NavigatorInfo::Product()
}
fn TaintEnabled(self) -> bool {
NavigatorInfo::TaintEnabled()
}
fn AppName(self) -> DOMString {
NavigatorInfo::AppName()
}
fn AppCodeName(self) -> DOMString {
NavigatorInfo::AppCodeName()
}
fn Platform(self) -> DOMString {
NavigatorInfo::Platform()
}
fn UserAgent(self) -> DOMString {
NavigatorInfo::UserAgent()
}
}
impl Reflectable for Navigator {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}