Rewrite determine_request_referrer() to explicitly limit it to the checks it can do.

Checks for the Client value should reside in the script thread.

I also noted some other issues in this code.
This commit is contained in:
Ms2ger 2016-12-08 11:46:57 -10:00
parent 1e3d4d272d
commit 12aa4694cb
3 changed files with 40 additions and 42 deletions

View file

@ -9,7 +9,6 @@ use msg::constellation_msg::PipelineId;
use servo_url::ServoUrl;
use std::cell::{Cell, RefCell};
use std::default::Default;
use std::mem::swap;
use url::{Origin as UrlOrigin};
/// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator)
@ -308,19 +307,4 @@ impl Referrer {
Referrer::ReferrerUrl(ref url) => Some(url)
}
}
pub fn from_url(url: Option<ServoUrl>) -> Self {
if let Some(url) = url {
Referrer::ReferrerUrl(url)
} else {
Referrer::NoReferrer
}
}
pub fn take(&mut self) -> Option<ServoUrl> {
let mut new = Referrer::Client;
swap(self, &mut new);
match new {
Referrer::NoReferrer | Referrer::Client => None,
Referrer::ReferrerUrl(url) => Some(url)
}
}
}