Index: chrome/browser/devtools/devtools_file_helper.h |
diff --git a/chrome/browser/devtools/devtools_file_helper.h b/chrome/browser/devtools/devtools_file_helper.h |
index b894a73c0953bba782f4453f7c3564140e4d8e61..7f9d4512407e5da5b6d7a44b81f044b6f2693e5c 100644 |
--- a/chrome/browser/devtools/devtools_file_helper.h |
+++ b/chrome/browser/devtools/devtools_file_helper.h |
@@ -7,6 +7,7 @@ |
#include <map> |
#include <string> |
+#include <vector> |
#include "base/basictypes.h" |
#include "base/callback.h" |
@@ -16,13 +17,34 @@ |
class FilePath; |
class Profile; |
+namespace content { |
+class WebContents; |
+} |
+ |
class DevToolsFileHelper { |
public: |
- explicit DevToolsFileHelper(Profile* profile); |
+ struct Filesystem { |
+ Filesystem(); |
+ Filesystem(const std::string& filesystem_id, |
+ const std::string& registered_name, |
+ const std::string& filesystem_path); |
+ |
+ std::string filesystem_id; |
+ std::string registered_name; |
+ std::string filesystem_path; |
+ }; |
+ |
+ DevToolsFileHelper(content::WebContents* web_contents, Profile* profile); |
~DevToolsFileHelper(); |
typedef base::Callback<void(void)> SaveCallback; |
typedef base::Callback<void(void)> AppendCallback; |
+ typedef base::Callback< |
+ void(const std::vector<DevToolsFileHelper::Filesystem>&)> |
+ RequestFilesystemsCallback; |
+ typedef base::Callback< |
+ void(std::string, const DevToolsFileHelper::Filesystem&)> |
+ AddFilesystemCallback; |
// Saves |content| to the file and associates its path with given |url|. |
// If client is calling this method with given |url| for the first time |
@@ -40,13 +62,40 @@ class DevToolsFileHelper { |
const std::string& content, |
const AppendCallback& callback); |
+ // Shows select folder dialog. |
+ // If user cancels folder selection, passes empty Filesystem struct to |
+ // |callback|. |
+ // If selected folder contains magic file, grants renderer read/write |
+ // permissions, registers isolated file system for it and passes Filesystem |
+ // struct to |callback|. Saves file system path to prefs. |
+ // If selected folder does not contain magic file, passes error string to |
+ // |callback|. |
+ void AddFilesystem(const AddFilesystemCallback& callback); |
+ |
+ // Loads file system paths from prefs, grants permissions and registers |
+ // isolated file system for those of them that contain magic file and passes |
+ // Filesystem structs for registered file systems to |callback|. |
+ void RequestFilesystems(const RequestFilesystemsCallback& callback); |
+ |
+ // Removes isolated file system for given \filesystem_path|. |
+ void RemoveFilesystem(const std::string& filesystem_path); |
+ |
private: |
void SaveAsFileSelected(const std::string& url, |
const std::string& content, |
const SaveCallback& callback, |
const FilePath& path); |
void SaveAsFileSelectionCanceled(); |
+ void FolderSelected(const AddFilesystemCallback& callback, |
+ const FilePath& path); |
+ void FolderSelectionCanceled(const AddFilesystemCallback& callback); |
+ void SelectedFilesystemChecked(const AddFilesystemCallback& callback, |
+ const FilePath& path, |
+ bool permitted); |
+ void RegisterPermittedFilesystems(const RequestFilesystemsCallback& callback, |
+ const std::vector<FilePath>& file_paths); |
+ content::WebContents* web_contents_; |
Profile* profile_; |
base::WeakPtrFactory<DevToolsFileHelper> weak_factory_; |
typedef std::map<std::string, FilePath> PathsMap; |