Put Blob URL online

This commit is contained in:
Zhen Zhang 2016-07-15 01:02:21 +08:00
parent 4b78b9adab
commit fdc3a8e3ac
17 changed files with 260 additions and 191 deletions

View file

@ -15,8 +15,8 @@ use dom::urlhelper::UrlHelper;
use dom::urlsearchparams::URLSearchParams;
use ipc_channel::ipc;
use net_traits::IpcSend;
use net_traits::blob_url_store::parse_blob_url;
use net_traits::filemanager_thread::{FileOrigin, SelectedFileId, FileManagerThreadMsg};
use net_traits::blob_url_store::{get_blob_origin, parse_blob_url};
use net_traits::filemanager_thread::{SelectedFileId, FileManagerThreadMsg};
use std::borrow::ToOwned;
use std::default::Default;
use url::quirks::domain_to_unicode;
@ -117,7 +117,7 @@ impl URL {
pub fn CreateObjectURL(global: GlobalRef, blob: &Blob) -> DOMString {
/// XXX: Second field is an unicode-serialized Origin, it is a temporary workaround
/// and should not be trusted. See issue https://github.com/servo/servo/issues/11722
let origin = URL::get_blob_origin(&global.get_url());
let origin = get_blob_origin(&global.get_url());
if blob.IsClosed() {
// Generate a dummy id
@ -141,10 +141,10 @@ impl URL {
NOTE: The first step is unnecessary, since closed blobs do not exist in the store
*/
let origin = global.get_url().origin().unicode_serialization();
let origin = get_blob_origin(&global.get_url());
if let Ok(url) = Url::parse(&url) {
if let Some((id, _)) = parse_blob_url(&url) {
if let Ok((id, _, _)) = parse_blob_url(&url) {
let filemanager = global.resource_threads().sender();
let id = SelectedFileId(id.simple().to_string());
let (tx, rx) = ipc::channel().unwrap();
@ -172,18 +172,6 @@ impl URL {
result
}
/* NOTE(izgzhen): WebKit will return things like blob:file:///XXX
while Chrome will return blob:null/XXX
This is not well-specified, and I prefer the WebKit way here
*/
fn get_blob_origin(url: &Url) -> FileOrigin {
if url.scheme() == "file" {
"file://".to_string()
} else {
url.origin().unicode_serialization()
}
}
}
impl URLMethods for URL {