Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the embedder decide if servo should follow a link or not #15795

Merged
merged 1 commit into from Mar 14, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Let the embedder decide if servo should follow a link or not

  • Loading branch information
paulrouget committed Mar 2, 2017
commit 79a5bf0cbf74035682bb18686405b56e7a4811b1
@@ -554,6 +554,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.window.load_end(back, forward, root);
}

(Msg::AllowNavigation(url, response_chan), ShutdownState::NotShuttingDown) => {
let allow = self.window.allow_navigation(url);
if let Err(e) = response_chan.send(allow) {
warn!("Failed to send allow_navigation result ({}).", e);
}
}

(Msg::DelayedCompositionTimeout(timestamp), ShutdownState::NotShuttingDown) => {
if let CompositionRequest::DelayedComposite(this_timestamp) =
self.composition_request {
@@ -86,6 +86,8 @@ pub enum Msg {
LoadStart(bool, bool),
/// The load of a page has completed: (can go back, can go forward, is root frame).
LoadComplete(bool, bool, bool),
/// Wether or not to follow a link
AllowNavigation(ServoUrl, IpcSender<bool>),
/// We hit the delayed composition timeout. (See `delayed_composition.rs`.)
DelayedCompositionTimeout(u64),
/// Composite.
@@ -144,6 +146,7 @@ impl Debug for Msg {
Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"),
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
Msg::LoadComplete(..) => write!(f, "LoadComplete"),
Msg::AllowNavigation(..) => write!(f, "AllowNavigation"),
Msg::LoadStart(..) => write!(f, "LoadStart"),
Msg::DelayedCompositionTimeout(..) => write!(f, "DelayedCompositionTimeout"),
Msg::Recomposite(..) => write!(f, "Recomposite"),
@@ -134,6 +134,8 @@ pub trait WindowMethods {
fn load_end(&self, back: bool, forward: bool, root: bool);
/// Called when the browser encounters an error while loading a URL
fn load_error(&self, code: NetError, url: String);
/// Wether or not to follow a link
fn allow_navigation(&self, url: ServoUrl) -> bool;
/// Called when the <head> tag has finished parsing
fn head_parsed(&self);

@@ -1575,6 +1575,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}

fn load_url(&mut self, source_id: PipelineId, load_data: LoadData, replace: bool) -> Option<PipelineId> {
// Allow the embedder to handle the url itself
let (chan, port) = ipc::channel().expect("Failed to create IPC channel!");
self.compositor_proxy.send(ToCompositorMsg::AllowNavigation(load_data.url.clone(), chan));
if let Ok(false) = port.recv() {
return None;
}

debug!("Loading {} in pipeline {}.", load_data.url, source_id);
// If this load targets an iframe, its framing element may exist
// in a separate script thread than the framed document that initiated
@@ -477,6 +477,10 @@ impl WindowMethods for Window {
}
}

fn allow_navigation(&self, _: ServoUrl) -> bool {
true
}

fn supports_clipboard(&self) -> bool {
false
}
@@ -1100,6 +1100,10 @@ impl WindowMethods for Window {
}
}

fn allow_navigation(&self, _: ServoUrl) -> bool {
true
}

fn supports_clipboard(&self) -> bool {
false
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.