diff options
-rw-r--r-- | components/compositing/constellation.rs | 13 | ||||
-rw-r--r-- | components/compositing/pipeline.rs | 2 | ||||
-rw-r--r-- | components/net_traits/lib.rs | 6 | ||||
-rw-r--r-- | components/script/dom/htmliframeelement.rs | 13 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 2 |
5 files changed, 36 insertions, 0 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index b41f75c7b6e..b52a1a22395 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -1675,6 +1675,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 40b1a2baa6a..bb96e2a6518 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 f32576fcde5..819d0a80335 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; @@ -407,3 +408,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 4e7e6108785..beb3134698f 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -124,6 +124,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())); @@ -135,6 +136,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(); @@ -248,6 +250,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 e61c83b4e6b..ac3632c6a08 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -402,6 +402,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 |