diff --git a/libcef/browser_file_system.cc b/libcef/browser_file_system.cc index 1425bfab4..0bd440f1f 100644 --- a/libcef/browser_file_system.cc +++ b/libcef/browser_file_system.cc @@ -4,6 +4,7 @@ #include "browser_file_system.h" #include "browser_file_writer.h" +#include "cef_thread.h" #include "base/file_path.h" #include "base/memory/scoped_callback_factory.h" @@ -122,10 +123,19 @@ class BrowserFileSystemCallbackDispatcher } // namespace BrowserFileSystem::BrowserFileSystem() { +} + +BrowserFileSystem::~BrowserFileSystem() { +} + +void BrowserFileSystem::CreateContext() { + if (file_system_context_.get()) + return; + if (file_system_dir_.CreateUniqueTempDir()) { file_system_context_ = new FileSystemContext( - base::MessageLoopProxy::current(), - base::MessageLoopProxy::current(), + CefThread::GetMessageLoopProxyForThread(CefThread::FILE), + CefThread::GetMessageLoopProxyForThread(CefThread::IO), NULL /* special storage policy */, NULL /* quota manager */, file_system_dir_.path(), @@ -138,9 +148,6 @@ BrowserFileSystem::BrowserFileSystem() { } } -BrowserFileSystem::~BrowserFileSystem() { -} - void BrowserFileSystem::OpenFileSystem( WebFrame* frame, WebFileSystem::Type web_filesystem_type, long long, bool create, diff --git a/libcef/browser_file_system.h b/libcef/browser_file_system.h index c237988fd..eff3080cd 100644 --- a/libcef/browser_file_system.h +++ b/libcef/browser_file_system.h @@ -31,6 +31,8 @@ class BrowserFileSystem BrowserFileSystem(); virtual ~BrowserFileSystem(); + void CreateContext(); + void OpenFileSystem(WebKit::WebFrame* frame, WebKit::WebFileSystem::Type type, long long size, diff --git a/libcef/browser_request_context.cc b/libcef/browser_request_context.cc index 150aaf0e8..b83a42459 100644 --- a/libcef/browser_request_context.cc +++ b/libcef/browser_request_context.cc @@ -250,21 +250,26 @@ void BrowserRequestContext::Init( storage_.set_ftp_transaction_factory( new net::FtpNetworkLayer(host_resolver())); - blob_storage_controller_.reset(new webkit_blob::BlobStorageController()); - file_system_context_ = static_cast( - WebKit::webKitPlatformSupport()->fileSystem())->file_system_context(); - net::URLRequestJobFactory* job_factory = new net::URLRequestJobFactory; + + blob_storage_controller_.reset(new webkit_blob::BlobStorageController()); job_factory->SetProtocolHandler( "blob", new webkit_blob::BlobProtocolHandler( blob_storage_controller_.get(), CefThread::GetMessageLoopProxyForThread(CefThread::FILE))); - job_factory->SetProtocolHandler( - "filesystem", - fileapi::CreateFileSystemProtocolHandler( - file_system_context_.get(), - CefThread::GetMessageLoopProxyForThread(CefThread::FILE))); + + BrowserFileSystem* file_system = _Context->file_system(); + // Create the context if it doesn't already exist. + file_system->CreateContext(); + if (file_system->file_system_context()) { + job_factory->SetProtocolHandler( + "filesystem", + fileapi::CreateFileSystemProtocolHandler( + file_system->file_system_context(), + CefThread::GetMessageLoopProxyForThread(CefThread::FILE))); + } + storage_.set_job_factory(job_factory); } diff --git a/libcef/browser_request_context.h b/libcef/browser_request_context.h index cf075998a..8b1152322 100644 --- a/libcef/browser_request_context.h +++ b/libcef/browser_request_context.h @@ -13,10 +13,6 @@ class FilePath; -namespace fileapi { -class FileSystemContext; -} - namespace webkit_blob { class BlobStorageController; } @@ -48,17 +44,12 @@ class BrowserRequestContext : public net::URLRequestContext { return blob_storage_controller_.get(); } - fileapi::FileSystemContext* file_system_context() const { - return file_system_context_.get(); - } - private: void Init(const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy); net::URLRequestContextStorage storage_; scoped_ptr blob_storage_controller_; - scoped_refptr file_system_context_; scoped_ptr url_security_manager_; FilePath cookie_store_path_; bool accept_all_cookies_; diff --git a/libcef/browser_webkit_init.cc b/libcef/browser_webkit_init.cc index 99a1d0287..d4abd7ddb 100644 --- a/libcef/browser_webkit_init.cc +++ b/libcef/browser_webkit_init.cc @@ -95,7 +95,10 @@ WebKit::WebCookieJar* BrowserWebKitInit::cookieJar() { } WebKit::WebFileSystem* BrowserWebKitInit::fileSystem() { - return &file_system_; + BrowserFileSystem* file_system = _Context->file_system(); + // Create the context if it doesn't already exist. + file_system->CreateContext(); + return file_system; } bool BrowserWebKitInit::sandboxEnabled() { diff --git a/libcef/browser_webkit_init.h b/libcef/browser_webkit_init.h index 3d782ffec..1a2d6fde7 100644 --- a/libcef/browser_webkit_init.h +++ b/libcef/browser_webkit_init.h @@ -95,7 +95,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitPlatformSupportImpl { BrowserDatabaseSystem database_system_; BrowserWebCookieJarImpl cookie_jar_; scoped_refptr blob_registry_; - BrowserFileSystem file_system_; }; #endif // _BROWSER_WEBKIT_INIT_H diff --git a/libcef/cef_context.h b/libcef/cef_context.h index ae4535f91..1f01356c7 100644 --- a/libcef/cef_context.h +++ b/libcef/cef_context.h @@ -6,6 +6,7 @@ #define _CEF_CONTEXT_H #include "include/cef.h" +#include "browser_file_system.h" #include "browser_request_context.h" #include "cef_process.h" #include "dom_storage_context.h" @@ -68,6 +69,8 @@ public: { storage_context_.reset(storage_context); } DOMStorageContext* storage_context() { return storage_context_.get(); } + BrowserFileSystem* file_system() { return &file_system_; } + // Used to keep track of the web view host we're dragging over. WARNING: // this pointer should never be dereferenced. Use it only for comparing // pointers. @@ -99,6 +102,7 @@ private: FilePath cache_path_; scoped_refptr request_context_; scoped_ptr storage_context_; + BrowserFileSystem file_system_; // Map of browsers that currently exist. BrowserList browserlist_;