OLD | NEW |
---|---|
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_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/extension_function.h" | 8 #include "chrome/browser/extensions/extension_function.h" |
9 #include "chrome/common/extensions/api/file_system.h" | 9 #include "chrome/common/extensions/api/file_system.h" |
10 #include "ui/shell_dialogs/select_file_dialog.h" | 10 #include "ui/shell_dialogs/select_file_dialog.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 WRITABLE | 50 WRITABLE |
51 }; | 51 }; |
52 | 52 |
53 virtual ~FileSystemEntryFunction() {} | 53 virtual ~FileSystemEntryFunction() {} |
54 | 54 |
55 bool HasFileSystemWritePermission(); | 55 bool HasFileSystemWritePermission(); |
56 | 56 |
57 // This is called when a writable file entry is being returned. The function | 57 // This is called when a writable file entry is being returned. The function |
58 // will ensure the file exists, creating it if necessary, and also check that | 58 // will ensure the file exists, creating it if necessary, and also check that |
59 // the file is not a link. If it succeeds it proceeds to | 59 // the file is not a link. If it succeeds it proceeds to |
60 // RegisterFileSystemAndSendResponse, otherwise to HandleWritableFileError. | 60 // RegisterFileSystemsAndSendResponse, otherwise to HandleWritableFileError. |
61 void CheckWritableFile(const base::FilePath& path); | 61 void CheckWritableFile(const base::FilePath& path); |
62 void CheckWritableFiles(const std::vector<base::FilePath>& path, | |
63 bool multiple); | |
62 | 64 |
63 // This will finish the choose file process. This is either called directly | 65 // This will finish the choose file process. This is either called directly |
64 // from FileSelected, or from CreateFileIfNecessary. It is called on the UI | 66 // from FilesSelected, or from WritableFileCheckHelper. It is called on the UI |
65 // thread. | 67 // thread. |
Matt Giuca
2013/07/19 02:28:11
Describe |multiple|.
Sam McNally
2013/07/19 04:22:14
Done.
| |
66 void RegisterFileSystemAndSendResponse(const base::FilePath& path, | 68 void RegisterFileSystemsAndSendResponse( |
67 EntryType entry_type); | 69 const std::vector<base::FilePath>& path, |
70 EntryType entry_type, | |
71 bool multiple); | |
68 | 72 |
69 // This will finish the choose file process. This is either called directly | 73 // This will finish the choose file process. This is called from |
70 // from FileSelected, or from CreateFileIfNecessary. It is called on the UI | 74 // FileSystemIsRestorableFunction::RunImpl. |id_override| specifies the id to |
71 // thread. |id_override| specifies the id to send in the response instead of | 75 // send in the response instead of the generated id. This can be useful for |
72 // the generated id. This can be useful for creating a file entry with an id | 76 // creating a file entry with an id matching another file entry, e.g. for |
73 // matching another file entry, e.g. for restoreEntry. | 77 // restoreEntry. |
74 void RegisterFileSystemAndSendResponseWithIdOverride( | 78 void RegisterFileSystemAndSendResponseWithIdOverride( |
75 const base::FilePath& path, | 79 const base::FilePath& path, |
76 EntryType entry_type, | 80 EntryType entry_type, |
77 const std::string& id_override); | 81 const std::string& id_override); |
78 | 82 |
83 base::DictionaryValue* BuildEntryDictWithIdOverride( | |
84 const base::FilePath& path, EntryType entry_type, const std::string& id); | |
85 | |
86 base::DictionaryValue* BuildEntryDict(const base::FilePath& path, | |
87 EntryType entry_type); | |
88 | |
79 // called on the UI thread if there is a problem checking a writable file. | 89 // called on the UI thread if there is a problem checking a writable file. |
80 void HandleWritableFileError(); | 90 void HandleWritableFileError(const std::string& error); |
81 }; | 91 }; |
82 | 92 |
83 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { | 93 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { |
84 public: | 94 public: |
85 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", | 95 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", |
86 FILESYSTEM_GETWRITABLEENTRY) | 96 FILESYSTEM_GETWRITABLEENTRY) |
87 | 97 |
88 protected: | 98 protected: |
89 virtual ~FileSystemGetWritableEntryFunction() {} | 99 virtual ~FileSystemGetWritableEntryFunction() {} |
90 virtual bool RunImpl() OVERRIDE; | 100 virtual bool RunImpl() OVERRIDE; |
91 }; | 101 }; |
92 | 102 |
93 class FileSystemIsWritableEntryFunction : public SyncExtensionFunction { | 103 class FileSystemIsWritableEntryFunction : public SyncExtensionFunction { |
94 public: | 104 public: |
95 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", | 105 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", |
96 FILESYSTEM_ISWRITABLEENTRY) | 106 FILESYSTEM_ISWRITABLEENTRY) |
97 | 107 |
98 protected: | 108 protected: |
99 virtual ~FileSystemIsWritableEntryFunction() {} | 109 virtual ~FileSystemIsWritableEntryFunction() {} |
100 virtual bool RunImpl() OVERRIDE; | 110 virtual bool RunImpl() OVERRIDE; |
101 }; | 111 }; |
102 | 112 |
103 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { | 113 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { |
104 public: | 114 public: |
105 // Allow picker UI to be skipped in testing. | 115 // Allow picker UI to be skipped in testing. |
106 static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path); | 116 static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path); |
117 static void SkipPickerAndAlwaysSelectPathsForTest( | |
118 std::vector<base::FilePath>* paths); | |
107 static void SkipPickerAndSelectSuggestedPathForTest(); | 119 static void SkipPickerAndSelectSuggestedPathForTest(); |
108 static void SkipPickerAndAlwaysCancelForTest(); | 120 static void SkipPickerAndAlwaysCancelForTest(); |
109 static void StopSkippingPickerForTest(); | 121 static void StopSkippingPickerForTest(); |
110 // Call this with the directory for test file paths. On Chrome OS, accessed | 122 // Call this with the directory for test file paths. On Chrome OS, accessed |
111 // path needs to be explicitly registered for smooth integration with Google | 123 // path needs to be explicitly registered for smooth integration with Google |
112 // Drive support. | 124 // Drive support. |
113 static void RegisterTempExternalFileSystemForTest(const std::string& name, | 125 static void RegisterTempExternalFileSystemForTest(const std::string& name, |
114 const base::FilePath& path); | 126 const base::FilePath& path); |
115 | 127 |
116 DECLARE_EXTENSION_FUNCTION("fileSystem.chooseEntry", FILESYSTEM_CHOOSEENTRY) | 128 DECLARE_EXTENSION_FUNCTION("fileSystem.chooseEntry", FILESYSTEM_CHOOSEENTRY) |
(...skipping 10 matching lines...) Expand all Loading... | |
127 base::FilePath* suggested_name, | 139 base::FilePath* suggested_name, |
128 base::FilePath::StringType* suggested_extension); | 140 base::FilePath::StringType* suggested_extension); |
129 | 141 |
130 protected: | 142 protected: |
131 class FilePicker; | 143 class FilePicker; |
132 | 144 |
133 virtual ~FileSystemChooseEntryFunction() {} | 145 virtual ~FileSystemChooseEntryFunction() {} |
134 virtual bool RunImpl() OVERRIDE; | 146 virtual bool RunImpl() OVERRIDE; |
135 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, | 147 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
136 ui::SelectFileDialog::Type picker_type, | 148 ui::SelectFileDialog::Type picker_type, |
137 EntryType entry_type); | 149 EntryType entry_type, |
150 bool multiple); | |
138 | 151 |
139 private: | 152 private: |
140 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, | 153 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, |
141 const base::FilePath& previous_path); | 154 const base::FilePath& previous_path); |
142 | 155 |
143 // FileSelected and FileSelectionCanceled are called by the file picker. | 156 // FilesSelected and FileSelectionCanceled are called by the file picker. |
144 void FileSelected(const base::FilePath& path, EntryType entry_type); | 157 void FilesSelected(const std::vector<base::FilePath>& path, |
158 EntryType entry_type, | |
159 bool multiple); | |
145 void FileSelectionCanceled(); | 160 void FileSelectionCanceled(); |
146 | 161 |
147 base::FilePath initial_path_; | 162 base::FilePath initial_path_; |
148 }; | 163 }; |
149 | 164 |
150 class FileSystemRetainEntryFunction : public SyncExtensionFunction { | 165 class FileSystemRetainEntryFunction : public SyncExtensionFunction { |
151 public: | 166 public: |
152 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) | 167 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) |
153 | 168 |
154 protected: | 169 protected: |
(...skipping 20 matching lines...) Expand all Loading... | |
175 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) | 190 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) |
176 | 191 |
177 protected: | 192 protected: |
178 virtual ~FileSystemRestoreEntryFunction() {} | 193 virtual ~FileSystemRestoreEntryFunction() {} |
179 virtual bool RunImpl() OVERRIDE; | 194 virtual bool RunImpl() OVERRIDE; |
180 }; | 195 }; |
181 | 196 |
182 } // namespace extensions | 197 } // namespace extensions |
183 | 198 |
184 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 199 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
OLD | NEW |