Private browsing - Initial steps

This commit is contained in:
dhaval0603 2016-03-23 15:28:49 -04:00 committed by Josh Matthews
parent afa5ae4c72
commit af64a888e6
5 changed files with 36 additions and 0 deletions

View file

@ -1501,6 +1501,19 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
ReadyToSave::Ready 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) // Close a frame (and all children)
fn close_frame(&mut self, frame_id: FrameId, exit_mode: ExitPipelineMode) { fn close_frame(&mut self, frame_id: FrameId, exit_mode: ExitPipelineMode) {
// Store information about the pipelines to be closed. Then close the // Store information about the pipelines to be closed. Then close the

View file

@ -58,6 +58,7 @@ pub struct Pipeline {
/// animations cause composites to be continually scheduled. /// animations cause composites to be continually scheduled.
pub running_animations: bool, pub running_animations: bool,
pub children: Vec<FrameId>, pub children: Vec<FrameId>,
pub is_private: bool,
} }
/// The subset of the pipeline that is needed for layer composition. /// The subset of the pipeline that is needed for layer composition.
@ -275,6 +276,7 @@ impl Pipeline {
children: vec!(), children: vec!(),
size: size, size: size,
running_animations: false, running_animations: false,
is_private: false,
} }
} }

View file

@ -34,6 +34,7 @@ use hyper::mime::{Attr, Mime};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::{PipelineId}; use msg::constellation_msg::{PipelineId};
use serde::{Deserializer, Serializer}; use serde::{Deserializer, Serializer};
use std::sync::mpsc::Sender;
use std::thread; use std::thread;
use url::Url; use url::Url;
use websocket::header; 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 /// An unique identifier to keep track of each load message in the resource handler
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)] #[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
pub struct ResourceId(pub u32); pub struct ResourceId(pub u32);
pub enum ConstellationMsg {
/// Queries whether a pipeline or its ancestors are private
IsPrivate(PipelineId, Sender<bool>),
}

View file

@ -123,6 +123,7 @@ impl HTMLIFrameElement {
let window = window.r(); let window = window.r();
let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id(); let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id();
let new_pipeline_id = self.pipeline_id.get().unwrap(); let new_pipeline_id = self.pipeline_id.get().unwrap();
let private_iframe = self.privatebrowsing();
self.containing_page_pipeline_id.set(Some(window.pipeline())); self.containing_page_pipeline_id.set(Some(window.pipeline()));
@ -134,6 +135,7 @@ impl HTMLIFrameElement {
old_subpage_id: old_subpage_id, old_subpage_id: old_subpage_id,
new_pipeline_id: new_pipeline_id, new_pipeline_id: new_pipeline_id,
sandbox: sandboxed, sandbox: sandboxed,
is_private: private_iframe,
}; };
chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info)).unwrap(); chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info)).unwrap();
@ -247,6 +249,17 @@ impl HTMLIFrameElement {
ReflowQueryType::NoQuery, ReflowQueryType::NoQuery,
ReflowReason::IFrameLoadEvent); 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 { pub trait HTMLIFrameElementLayoutMethods {

View file

@ -400,6 +400,8 @@ pub struct IFrameLoadInfo {
pub new_pipeline_id: PipelineId, pub new_pipeline_id: PipelineId,
/// Sandbox type of this iframe /// Sandbox type of this iframe
pub sandbox: IFrameSandboxState, 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 // https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events