Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/devtools/devtools_file_helper.h

Issue 11570081: Support file system access in DevTools with isolated file system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added fs name / root url generation in browser process as recommended by kinuko@ and addressed tsep… Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/devtools/devtools_file_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_ 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 16
16 class FilePath; 17 class FilePath;
17 class Profile; 18 class Profile;
18 19
20 namespace content {
21 class WebContents;
22 }
23
19 class DevToolsFileHelper { 24 class DevToolsFileHelper {
20 public: 25 public:
21 explicit DevToolsFileHelper(Profile* profile); 26 struct FileSystem {
27 FileSystem();
28 FileSystem(const std::string& file_system_name,
29 const std::string& root_url,
30 const std::string& file_system_path);
31
32 std::string file_system_name;
33 std::string root_url;
34 std::string file_system_path;
35 };
36
37 DevToolsFileHelper(content::WebContents* web_contents, Profile* profile);
22 ~DevToolsFileHelper(); 38 ~DevToolsFileHelper();
23 39
24 typedef base::Callback<void(void)> SaveCallback; 40 typedef base::Callback<void(void)> SaveCallback;
25 typedef base::Callback<void(void)> AppendCallback; 41 typedef base::Callback<void(void)> AppendCallback;
42 typedef base::Callback<
43 void(const std::vector<DevToolsFileHelper::FileSystem>&)>
44 RequestFileSystemsCallback;
45 typedef base::Callback<
46 void(std::string, const DevToolsFileHelper::FileSystem&)>
47 AddFileSystemCallback;
26 48
27 // Saves |content| to the file and associates its path with given |url|. 49 // Saves |content| to the file and associates its path with given |url|.
28 // If client is calling this method with given |url| for the first time 50 // If client is calling this method with given |url| for the first time
29 // or |save_as| is true, confirmation dialog is shown to the user. 51 // or |save_as| is true, confirmation dialog is shown to the user.
30 void Save(const std::string& url, 52 void Save(const std::string& url,
31 const std::string& content, 53 const std::string& content,
32 bool save_as, 54 bool save_as,
33 const SaveCallback& callback); 55 const SaveCallback& callback);
34 56
35 // Append |content| to the file that has been associated with given |url|. 57 // Append |content| to the file that has been associated with given |url|.
36 // The |url| can be associated with a file via calling Save method. 58 // The |url| can be associated with a file via calling Save method.
37 // If the Save method has not been called for this |url|, then 59 // If the Save method has not been called for this |url|, then
38 // Append method does nothing. 60 // Append method does nothing.
39 void Append(const std::string& url, 61 void Append(const std::string& url,
40 const std::string& content, 62 const std::string& content,
41 const AppendCallback& callback); 63 const AppendCallback& callback);
42 64
65 // Shows select folder dialog.
66 // If user cancels folder selection, passes empty FileSystem struct to
67 // |callback|.
68 // If selected folder contains magic file, grants renderer read/write
69 // permissions, registers isolated file system for it and passes FileSystem
70 // struct to |callback|. Saves file system path to prefs.
71 // If selected folder does not contain magic file, passes error string to
72 // |callback|.
73 void AddFileSystem(const AddFileSystemCallback& callback);
74
75 // Loads file system paths from prefs, grants permissions and registers
76 // isolated file system for those of them that contain magic file and passes
77 // FileSystem structs for registered file systems to |callback|.
78 void RequestFileSystems(const RequestFileSystemsCallback& callback);
79
80 // Removes isolated file system for given |file_system_path|.
81 void RemoveFileSystem(const std::string& file_system_path);
82
43 private: 83 private:
44 void SaveAsFileSelected(const std::string& url, 84 void SaveAsFileSelected(const std::string& url,
45 const std::string& content, 85 const std::string& content,
46 const SaveCallback& callback, 86 const SaveCallback& callback,
47 const FilePath& path); 87 const FilePath& path);
48 void SaveAsFileSelectionCanceled(); 88 void SaveAsFileSelectionCanceled();
89 void InnerAddFileSystem(const AddFileSystemCallback& callback,
90 const FilePath& path);
91 void AddValidatedFileSystem(const AddFileSystemCallback& callback,
92 const std::vector<FilePath>& permitted_paths);
93 void RestoreValidatedFileSystems(const RequestFileSystemsCallback& callback,
94 const std::vector<FilePath>& file_paths);
49 95
96 content::WebContents* web_contents_;
50 Profile* profile_; 97 Profile* profile_;
51 base::WeakPtrFactory<DevToolsFileHelper> weak_factory_; 98 base::WeakPtrFactory<DevToolsFileHelper> weak_factory_;
52 typedef std::map<std::string, FilePath> PathsMap; 99 typedef std::map<std::string, FilePath> PathsMap;
53 PathsMap saved_files_; 100 PathsMap saved_files_;
54 DISALLOW_COPY_AND_ASSIGN(DevToolsFileHelper); 101 DISALLOW_COPY_AND_ASSIGN(DevToolsFileHelper);
55 }; 102 };
56 103
57 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_ 104 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/devtools/devtools_file_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698