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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/values.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "chrome/browser/extensions/chrome_extension_function.h" | 18 #include "chrome/browser/extensions/chrome_extension_function.h" |
18 #include "chrome/browser/extensions/chrome_extension_function_details.h" | 19 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
19 #include "chrome/common/extensions/api/file_system.h" | 20 #include "chrome/common/extensions/api/file_system.h" |
20 #include "extensions/browser/extension_function.h" | 21 #include "extensions/browser/extension_function.h" |
21 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
22 #include "ui/shell_dialogs/select_file_dialog.h" | 23 #include "ui/shell_dialogs/select_file_dialog.h" |
23 | 24 |
24 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
25 namespace file_manager { | 26 namespace file_manager { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // that none of the files are links. If it succeeds it proceeds to | 164 // that none of the files are links. If it succeeds it proceeds to |
164 // RegisterFileSystemsAndSendResponse, otherwise to HandleWritableFileError. | 165 // RegisterFileSystemsAndSendResponse, otherwise to HandleWritableFileError. |
165 void PrepareFilesForWritableApp(const std::vector<base::FilePath>& path); | 166 void PrepareFilesForWritableApp(const std::vector<base::FilePath>& path); |
166 | 167 |
167 // This will finish the choose file process. This is either called directly | 168 // This will finish the choose file process. This is either called directly |
168 // from FilesSelected, or from WritableFileChecker. It is called on the UI | 169 // from FilesSelected, or from WritableFileChecker. It is called on the UI |
169 // thread. | 170 // thread. |
170 void RegisterFileSystemsAndSendResponse( | 171 void RegisterFileSystemsAndSendResponse( |
171 const std::vector<base::FilePath>& path); | 172 const std::vector<base::FilePath>& path); |
172 | 173 |
173 // Creates a response dictionary and sets it as the response to be sent. | 174 // Creates a result dictionary. |
174 void CreateResponse(); | 175 std::unique_ptr<base::DictionaryValue> CreateResult(); |
175 | 176 |
176 // Adds an entry to the response dictionary. | 177 // Adds an entry to the result dictionary. |
177 void AddEntryToResponse(const base::FilePath& path, | 178 void AddEntryToResult(const base::FilePath& path, |
178 const std::string& id_override); | 179 const std::string& id_override, |
| 180 base::DictionaryValue* result); |
179 | 181 |
180 // called on the UI thread if there is a problem checking a writable file. | 182 // called on the UI thread if there is a problem checking a writable file. |
181 void HandleWritableFileError(const base::FilePath& error_path); | 183 void HandleWritableFileError(const base::FilePath& error_path); |
182 | 184 |
183 // Whether multiple entries have been requested. | 185 // Whether multiple entries have been requested. |
184 bool multiple_; | 186 bool multiple_; |
185 | 187 |
186 // Whether a directory has been requested. | 188 // Whether a directory has been requested. |
187 bool is_directory_; | 189 bool is_directory_; |
188 | |
189 // The dictionary to send as the response. | |
190 base::DictionaryValue* response_; | |
191 }; | 190 }; |
192 | 191 |
193 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { | 192 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { |
194 public: | 193 public: |
195 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", | 194 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", |
196 FILESYSTEM_GETWRITABLEENTRY) | 195 FILESYSTEM_GETWRITABLEENTRY) |
197 | 196 |
198 protected: | 197 protected: |
199 ~FileSystemGetWritableEntryFunction() override {} | 198 ~FileSystemGetWritableEntryFunction() override {} |
200 bool RunAsync() override; | 199 bool RunAsync() override; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 ExtensionFunction::ResponseAction Run() override; | 413 ExtensionFunction::ResponseAction Run() override; |
415 | 414 |
416 private: | 415 private: |
417 ChromeExtensionFunctionDetails chrome_details_; | 416 ChromeExtensionFunctionDetails chrome_details_; |
418 }; | 417 }; |
419 #endif | 418 #endif |
420 | 419 |
421 } // namespace extensions | 420 } // namespace extensions |
422 | 421 |
423 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 422 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
OLD | NEW |