Chromium Code Reviews| 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..70f922f0299f83880e034e918d4208f1fdb793d7 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,39 @@ 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|. |
|
kinuko
2013/01/04 14:20:55
nit: \filesystem_path| -> |filesystem_path| ?
vsevik
2013/01/09 11:54:40
Done.
|
| + void RemoveFilesystem(const std::string& filesystem_path); |
| + |
| private: |
| void SaveAsFileSelected(const std::string& url, |
| - const std::string& content, |
| - const SaveCallback& callback, |
| - const FilePath& path); |
| + const std::string& content, |
| + const SaveCallback& callback, |
| + const FilePath& path); |
| void SaveAsFileSelectionCanceled(); |
| + void InnerAddFilesystem(const AddFilesystemCallback& callback, |
| + const FilePath& path); |
| + void CancelFilesystemAdding(const AddFilesystemCallback& callback); |
| + void AddValidatedFilesystem(const AddFilesystemCallback& callback, |
| + const std::vector<FilePath>& permitted_paths); |
| + void RestoreValidatedFilesystems(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; |