aboutsummaryrefslogtreecommitdiffstats
path: root/components/net
diff options
context:
space:
mode:
Diffstat (limited to 'components/net')
-rw-r--r--components/net/filemanager_thread.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs
index 6cc47adf060..56cf0ca62c8 100644
--- a/components/net/filemanager_thread.rs
+++ b/components/net/filemanager_thread.rs
@@ -6,7 +6,7 @@ use blob_loader;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use mime_classifier::MIMEClassifier;
use mime_guess::guess_mime_type_opt;
-use net_traits::blob_url_store::{BlobURLStoreEntry, BlobURLStoreError};
+use net_traits::blob_url_store::{BlobURLStoreEntry, BlobURLStoreError, BlobURLStoreMsg};
use net_traits::filemanager_thread::{FileManagerThreadMsg, FileManagerResult, FilterPattern};
use net_traits::filemanager_thread::{SelectedFile, FileManagerThreadError, SelectedFileId};
use std::collections::HashMap;
@@ -16,7 +16,7 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
#[cfg(any(target_os = "macos", target_os = "linux"))]
use tinyfiledialogs;
-use url::Origin;
+use url::{Url, Origin};
use util::thread::spawn_named;
use uuid::Uuid;
@@ -105,6 +105,7 @@ impl<UI: 'static + UIProvider> FileManager<UI> {
}
}
FileManagerThreadMsg::DeleteFileID(id) => self.delete_fileid(id),
+ FileManagerThreadMsg::BlobURLStoreMsg(msg) => self.blob_url_store.write().unwrap().process(msg),
FileManagerThreadMsg::LoadBlob(load_data, consumer) => {
blob_loader::load(load_data, consumer,
self.blob_url_store.clone(),
@@ -232,6 +233,29 @@ impl BlobURLStore {
}
}
+ fn process(&mut self, msg: BlobURLStoreMsg) {
+ match msg {
+ BlobURLStoreMsg::AddEntry(entry, origin_str, sender) => {
+ match Url::parse(&origin_str) {
+ Ok(base_url) => {
+ let id = Uuid::new_v4();
+ self.add_entry(id, base_url.origin(), entry);
+
+ let _ = sender.send(Ok(id.simple().to_string()));
+ }
+ Err(_) => {
+ let _ = sender.send(Err(BlobURLStoreError::InvalidOrigin));
+ }
+ }
+ }
+ BlobURLStoreMsg::DeleteEntry(id) => {
+ if let Ok(id) = Uuid::parse_str(&id) {
+ self.delete_entry(id);
+ }
+ },
+ }
+ }
+
pub fn request(&self, id: Uuid, origin: &Origin) -> Result<&BlobURLStoreEntry, BlobURLStoreError> {
match self.entries.get(&id) {
Some(ref pair) => {