| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 | 10 |
| 11 namespace extensions { | 11 namespace extensions { |
| 12 | 12 |
| 13 class FileSystemGetDisplayPathFunction : public SyncExtensionFunction { | 13 class FileSystemGetDisplayPathFunction : public SyncExtensionFunction { |
| 14 public: | 14 public: |
| 15 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getDisplayPath"); | 15 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getDisplayPath"); |
| 16 | 16 |
| 17 protected: | 17 protected: |
| 18 virtual ~FileSystemGetDisplayPathFunction() {} | 18 virtual ~FileSystemGetDisplayPathFunction() {} |
| 19 virtual bool RunImpl() OVERRIDE; | 19 virtual bool RunImpl() OVERRIDE; |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 class FileSystemGetWritableFileEntryFunction : public AsyncExtensionFunction { | 22 class FileSystemPickerFunction : public AsyncExtensionFunction { |
| 23 protected: |
| 24 class FilePicker; |
| 25 |
| 26 virtual ~FileSystemPickerFunction() {} |
| 27 bool ShowPicker(const FilePath& suggested_path, bool for_save); |
| 28 |
| 29 private: |
| 30 // FileSelected and FileSelectionCanceled are called by the file picker. |
| 31 void FileSelected(const FilePath& path, bool for_save); |
| 32 void FileSelectionCanceled(); |
| 33 |
| 34 // called on the FILE thread. This is only called when a file is being chosen |
| 35 // to save. The function will ensure the file exists, creating it if |
| 36 // necessary, and also check that the file is not a link. |
| 37 void CheckWritableFile(const FilePath& path); |
| 38 |
| 39 // This will finish the choose file process. This is either called directly |
| 40 // from FileSelected, or from CreateFileIfNecessary. It is called on the UI |
| 41 // thread. |
| 42 void RegisterFileSystemAndSendResponse(const FilePath& path, bool for_save); |
| 43 |
| 44 // called on the UI thread if there is a problem checking a writable file. |
| 45 void HandleWritableFileError(); |
| 46 }; |
| 47 |
| 48 class FileSystemGetWritableFileEntryFunction : public FileSystemPickerFunction { |
| 23 public: | 49 public: |
| 24 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getWritableFileEntry"); | 50 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getWritableFileEntry"); |
| 25 | 51 |
| 26 protected: | 52 protected: |
| 27 virtual ~FileSystemGetWritableFileEntryFunction() {} | 53 virtual ~FileSystemGetWritableFileEntryFunction() {} |
| 28 virtual bool RunImpl() OVERRIDE; | 54 virtual bool RunImpl() OVERRIDE; |
| 55 }; |
| 29 | 56 |
| 30 private: | 57 class FileSystemChooseFileFunction : public FileSystemPickerFunction { |
| 31 class FilePicker; | 58 public: |
| 59 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseFile"); |
| 32 | 60 |
| 33 void FileSelected(const FilePath& path); | 61 protected: |
| 34 void FileSelectionCanceled(); | 62 virtual ~FileSystemChooseFileFunction() {} |
| 63 virtual bool RunImpl() OVERRIDE; |
| 35 }; | 64 }; |
| 36 | 65 |
| 37 } // namespace extensions | 66 } // namespace extensions |
| 38 | 67 |
| 39 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |