aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/file.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/file.rs')
-rw-r--r--components/script/dom/file.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs
index 9667182671a..4ece71a5ce3 100644
--- a/components/script/dom/file.rs
+++ b/components/script/dom/file.rs
@@ -10,6 +10,8 @@ use dom::bindings::global::GlobalRef;
use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object;
use dom::blob::{Blob, DataSlice, blob_parts_to_bytes};
+use dom::window::Window;
+use net_traits::filemanager_thread::SelectedFile;
use std::sync::Arc;
use time;
use util::str::DOMString;
@@ -45,6 +47,19 @@ impl File {
FileBinding::Wrap)
}
+ // Construct from selected file message from file manager thread
+ pub fn new_from_selected(window: &Window, selected: SelectedFile) -> Root<File> {
+ let name = DOMString::from(selected.filename.to_str().expect("File name encoding error"));
+
+ // FIXME: fix this after PR #11221 is landed
+ let id = selected.id;
+ let slice = DataSlice::empty();
+
+ let global = GlobalRef::Window(window);
+
+ File::new(global, slice, name, Some(selected.modified as i64), "")
+ }
+
// https://w3c.github.io/FileAPI/#file-constructor
pub fn Constructor(global: GlobalRef,
fileBits: Vec<BlobOrString>,
@@ -64,7 +79,6 @@ impl File {
pub fn name(&self) -> &DOMString {
&self.name
}
-
}
impl FileMethods for File {