mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Auto merge of #10399 - jdm:pb, r=jdm
Private browsing - Initial steps Rebase of #10160. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10399) <!-- Reviewable:end -->
This commit is contained in:
commit
d1e8b79583
5 changed files with 36 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>),
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue