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

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

Issue 14081036: DevTools: Replace .allow-devtools-edit file check with confirmation infobar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/string16.h"
16 17
17 class Profile; 18 class Profile;
18 19
19 namespace base { 20 namespace base {
20 class FilePath; 21 class FilePath;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 class WebContents; 25 class WebContents;
25 } 26 }
(...skipping 12 matching lines...) Expand all
38 }; 39 };
39 40
40 DevToolsFileHelper(content::WebContents* web_contents, Profile* profile); 41 DevToolsFileHelper(content::WebContents* web_contents, Profile* profile);
41 ~DevToolsFileHelper(); 42 ~DevToolsFileHelper();
42 43
43 typedef base::Callback<void(void)> SaveCallback; 44 typedef base::Callback<void(void)> SaveCallback;
44 typedef base::Callback<void(void)> AppendCallback; 45 typedef base::Callback<void(void)> AppendCallback;
45 typedef base::Callback< 46 typedef base::Callback<
46 void(const std::vector<DevToolsFileHelper::FileSystem>&)> 47 void(const std::vector<DevToolsFileHelper::FileSystem>&)>
47 RequestFileSystemsCallback; 48 RequestFileSystemsCallback;
48 typedef base::Callback< 49 typedef base::Callback<void(const DevToolsFileHelper::FileSystem&)>
49 void(std::string, const DevToolsFileHelper::FileSystem&)>
50 AddFileSystemCallback; 50 AddFileSystemCallback;
51 typedef base::Callback<void(const string16&,
52 const base::Callback<void(bool)>&)>
53 ShowInfoBarCallback;
51 54
52 // Saves |content| to the file and associates its path with given |url|. 55 // Saves |content| to the file and associates its path with given |url|.
53 // If client is calling this method with given |url| for the first time 56 // If client is calling this method with given |url| for the first time
54 // or |save_as| is true, confirmation dialog is shown to the user. 57 // or |save_as| is true, confirmation dialog is shown to the user.
55 void Save(const std::string& url, 58 void Save(const std::string& url,
56 const std::string& content, 59 const std::string& content,
57 bool save_as, 60 bool save_as,
58 const SaveCallback& callback); 61 const SaveCallback& callback);
59 62
60 // Append |content| to the file that has been associated with given |url|. 63 // Append |content| to the file that has been associated with given |url|.
61 // The |url| can be associated with a file via calling Save method. 64 // The |url| can be associated with a file via calling Save method.
62 // If the Save method has not been called for this |url|, then 65 // If the Save method has not been called for this |url|, then
63 // Append method does nothing. 66 // Append method does nothing.
64 void Append(const std::string& url, 67 void Append(const std::string& url,
65 const std::string& content, 68 const std::string& content,
66 const AppendCallback& callback); 69 const AppendCallback& callback);
67 70
68 // Shows select folder dialog. 71 // Shows select folder dialog.
69 // If user cancels folder selection, passes empty FileSystem struct to 72 // If user cancels folder selection, passes empty FileSystem struct to
70 // |callback|. 73 // |callback|.
71 // If selected folder contains magic file, grants renderer read/write 74 // If selected folder contains magic file, grants renderer read/write
72 // permissions, registers isolated file system for it and passes FileSystem 75 // permissions, registers isolated file system for it and passes FileSystem
73 // struct to |callback|. Saves file system path to prefs. 76 // struct to |callback|. Saves file system path to prefs.
74 // If selected folder does not contain magic file, passes error string to 77 // If selected folder does not contain magic file, passes error string to
75 // |callback|. 78 // |callback|.
76 void AddFileSystem(const AddFileSystemCallback& callback); 79 void AddFileSystem(const AddFileSystemCallback& callback,
80 const ShowInfoBarCallback& show_info_bar_callback);
77 81
78 // Loads file system paths from prefs, grants permissions and registers 82 // Loads file system paths from prefs, grants permissions and registers
79 // isolated file system for those of them that contain magic file and passes 83 // isolated file system for those of them that contain magic file and passes
80 // FileSystem structs for registered file systems to |callback|. 84 // FileSystem structs for registered file systems to |callback|.
81 void RequestFileSystems(const RequestFileSystemsCallback& callback); 85 void RequestFileSystems(const RequestFileSystemsCallback& callback);
82 86
83 // Removes isolated file system for given |file_system_path|. 87 // Removes isolated file system for given |file_system_path|.
84 void RemoveFileSystem(const std::string& file_system_path); 88 void RemoveFileSystem(const std::string& file_system_path);
85 89
86 private: 90 private:
87 void SaveAsFileSelected(const std::string& url, 91 void SaveAsFileSelected(const std::string& url,
88 const std::string& content, 92 const std::string& content,
89 const SaveCallback& callback, 93 const SaveCallback& callback,
90 const base::FilePath& path); 94 const base::FilePath& path);
91 void SaveAsFileSelectionCanceled(); 95 void SaveAsFileSelectionCanceled();
92 void InnerAddFileSystem(const AddFileSystemCallback& callback, 96 void InnerAddFileSystem(
93 const base::FilePath& path);
94 void AddValidatedFileSystem(
95 const AddFileSystemCallback& callback, 97 const AddFileSystemCallback& callback,
96 const std::vector<base::FilePath>& permitted_paths); 98 const ShowInfoBarCallback& show_info_bar_callback,
99 const base::FilePath& path);
100 void AddUserConfirmedFileSystem(
101 const AddFileSystemCallback& callback,
102 const base::FilePath& path,
103 bool allowed);
97 void RestoreValidatedFileSystems( 104 void RestoreValidatedFileSystems(
98 const RequestFileSystemsCallback& callback, 105 const RequestFileSystemsCallback& callback,
99 const std::vector<base::FilePath>& file_paths); 106 const std::vector<base::FilePath>& file_paths);
100 107
101 content::WebContents* web_contents_; 108 content::WebContents* web_contents_;
102 Profile* profile_; 109 Profile* profile_;
103 base::WeakPtrFactory<DevToolsFileHelper> weak_factory_; 110 base::WeakPtrFactory<DevToolsFileHelper> weak_factory_;
104 typedef std::map<std::string, base::FilePath> PathsMap; 111 typedef std::map<std::string, base::FilePath> PathsMap;
105 PathsMap saved_files_; 112 PathsMap saved_files_;
106 DISALLOW_COPY_AND_ASSIGN(DevToolsFileHelper); 113 DISALLOW_COPY_AND_ASSIGN(DevToolsFileHelper);
107 }; 114 };
108 115
109 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_FILE_HELPER_H_ 116 #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