aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhaval0603 <dhaval0603@gmail.com>2016-03-23 15:28:49 -0400
committerJosh Matthews <josh@joshmatthews.net>2016-04-04 15:22:38 -0400
commitaf64a888e6e1f1b1aacf03dc44cec773f9e2c05d (patch)
tree7f6962445786bbcc73bbf80d0645e292d8f5d31b
parentafa5ae4c72563eb8d3d25fdacb8cb2825517da46 (diff)
downloadservo-af64a888e6e1f1b1aacf03dc44cec773f9e2c05d.tar.gz
servo-af64a888e6e1f1b1aacf03dc44cec773f9e2c05d.zip
Private browsing - Initial steps
-rw-r--r--components/compositing/constellation.rs13
-rw-r--r--components/compositing/pipeline.rs2
-rw-r--r--components/net_traits/lib.rs6
-rw-r--r--components/script/dom/htmliframeelement.rs13
-rw-r--r--components/script_traits/lib.rs2
5 files changed, 36 insertions, 0 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index a7a958e3101..78e50217e52 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -1501,6 +1501,19 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
ReadyToSave::Ready
}
+ /// Checks whether the pipeline or its ancestors are private
+ #[allow(dead_code)]
+ fn check_is_pipeline_private(&self, pipeline_id: PipelineId) -> bool {
+ let mut pipeline_id = Some(pipeline_id);
+ while let Some(pipeline) = pipeline_id.and_then(|id| self.pipelines.get(&id)) {
+ if pipeline.is_private {
+ return true;
+ }
+ pipeline_id = pipeline.parent_info.map(|(parent_pipeline_id, _)| parent_pipeline_id);
+ }
+ false
+ }
+
// Close a frame (and all children)
fn close_frame(&mut self, frame_id: FrameId, exit_mode: ExitPipelineMode) {
// Store information about the pipelines to be closed. Then close the
diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs
index bbf892048c8..fa99fbc1d04 100644
--- a/components/compositing/pipeline.rs
+++ b/components/compositing/pipeline.rs
@@ -58,6 +58,7 @@ pub struct Pipeline {
/// animations cause composites to be continually scheduled.
pub running_animations: bool,
pub children: Vec<FrameId>,
+ pub is_private: bool,
}
/// The subset of the pipeline that is needed for layer composition.
@@ -275,6 +276,7 @@ impl Pipeline {
children: vec!(),
size: size,
running_animations: false,
+ is_private: false,
}
}
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index a741bec034c..4ff3aa957b7 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -34,6 +34,7 @@ use hyper::mime::{Attr, Mime};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::{PipelineId};
use serde::{Deserializer, Serializer};
+use std::sync::mpsc::Sender;
use std::thread;
use url::Url;
use websocket::header;
@@ -398,3 +399,8 @@ pub fn unwrap_websocket_protocol(wsp: Option<&header::WebSocketProtocol>) -> Opt
/// An unique identifier to keep track of each load message in the resource handler
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
pub struct ResourceId(pub u32);
+
+pub enum ConstellationMsg {
+ /// Queries whether a pipeline or its ancestors are private
+ IsPrivate(PipelineId, Sender<bool>),
+}
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index a4ccafd2d4c..84db4ddf39f 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -123,6 +123,7 @@ impl HTMLIFrameElement {
let window = window.r();
let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id();
let new_pipeline_id = self.pipeline_id.get().unwrap();
+ let private_iframe = self.privatebrowsing();
self.containing_page_pipeline_id.set(Some(window.pipeline()));
@@ -134,6 +135,7 @@ impl HTMLIFrameElement {
old_subpage_id: old_subpage_id,
new_pipeline_id: new_pipeline_id,
sandbox: sandboxed,
+ is_private: private_iframe,
};
chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info)).unwrap();
@@ -247,6 +249,17 @@ impl HTMLIFrameElement {
ReflowQueryType::NoQuery,
ReflowReason::IFrameLoadEvent);
}
+
+ /// Check whether the iframe has the mozprivatebrowsing attribute set
+ pub fn privatebrowsing(&self) -> bool {
+ if self.Mozbrowser() {
+ let element = self.upcast::<Element>();
+ element.has_attribute(&Atom::from("mozprivatebrowsing"))
+ } else {
+ false
+ }
+ }
+
}
pub trait HTMLIFrameElementLayoutMethods {
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 6aeca4068ec..4fcaff3c2ec 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -400,6 +400,8 @@ pub struct IFrameLoadInfo {
pub new_pipeline_id: PipelineId,
/// Sandbox type of this iframe
pub sandbox: IFrameSandboxState,
+ /// Whether this iframe should be considered private
+ pub is_private: bool,
}
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events