From c25264113f41892f29df4fb4622759bfd79cee76 Mon Sep 17 00:00:00 2001 From: Robo Date: Tue, 15 Mar 2016 07:53:40 +0530 Subject: [PATCH] fix devtools filesystem api and allow delegate to request stored filesystem paths --- .../browser/devtools_embedder_message_dispatcher.h | 2 +- brightray/browser/inspectable_web_contents_delegate.h | 1 + brightray/browser/inspectable_web_contents_impl.cc | 10 ++++++---- brightray/browser/inspectable_web_contents_impl.h | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/brightray/browser/devtools_embedder_message_dispatcher.h b/brightray/browser/devtools_embedder_message_dispatcher.h index eb3dc389786b..4401bd5ab85e 100644 --- a/brightray/browser/devtools_embedder_message_dispatcher.h +++ b/brightray/browser/devtools_embedder_message_dispatcher.h @@ -49,7 +49,7 @@ class DevToolsEmbedderMessageDispatcher { virtual void AppendToFile(const std::string& url, const std::string& content) = 0; virtual void RequestFileSystems() = 0; - virtual void AddFileSystem() = 0; + virtual void AddFileSystem(const std::string& file_system_path) = 0; virtual void RemoveFileSystem(const std::string& file_system_path) = 0; virtual void UpgradeDraggedFileSystemPermissions( const std::string& file_system_url) = 0; diff --git a/brightray/browser/inspectable_web_contents_delegate.h b/brightray/browser/inspectable_web_contents_delegate.h index 9c4ee722c2a3..e9f071cb4d0a 100644 --- a/brightray/browser/inspectable_web_contents_delegate.h +++ b/brightray/browser/inspectable_web_contents_delegate.h @@ -14,6 +14,7 @@ class InspectableWebContentsDelegate { const std::string& url, const std::string& content, bool save_as) {} virtual void DevToolsAppendToFile( const std::string& url, const std::string& content) {} + virtual void DevToolsRequestFileSystems() {} virtual void DevToolsAddFileSystem( const base::FilePath& file_system_path) {} virtual void DevToolsRemoveFileSystem( diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 8217812b58c7..9484593de47f 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -420,13 +420,15 @@ void InspectableWebContentsImpl::AppendToFile( } void InspectableWebContentsImpl::RequestFileSystems() { - GetDevToolsWebContents()->GetMainFrame()->ExecuteJavaScript( - base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([])")); + if (delegate_) + delegate_->DevToolsRequestFileSystems(); } -void InspectableWebContentsImpl::AddFileSystem() { +void InspectableWebContentsImpl::AddFileSystem( + const std::string& file_system_path) { if (delegate_) - delegate_->DevToolsAddFileSystem(base::FilePath()); + delegate_->DevToolsAddFileSystem( + base::FilePath::FromUTF8Unsafe(file_system_path)); } void InspectableWebContentsImpl::RemoveFileSystem( diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 1e2bab8a26c5..518fc853cb1e 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -89,7 +89,7 @@ class InspectableWebContentsImpl : void AppendToFile(const std::string& url, const std::string& content) override; void RequestFileSystems() override; - void AddFileSystem() override; + void AddFileSystem(const std::string& file_system_path) override; void RemoveFileSystem(const std::string& file_system_path) override; void UpgradeDraggedFileSystemPermissions( const std::string& file_system_url) override;