| 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/base/dialogs/select_file_dialog.h" | 10 #include "ui/base/dialogs/select_file_dialog.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // This will finish the choose file process. This is either called directly | 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 | 40 // from FileSelected, or from CreateFileIfNecessary. It is called on the UI |
| 41 // thread. | 41 // thread. |
| 42 void RegisterFileSystemAndSendResponse(const FilePath& path, | 42 void RegisterFileSystemAndSendResponse(const FilePath& path, |
| 43 EntryType entry_type); | 43 EntryType entry_type); |
| 44 | 44 |
| 45 // called on the UI thread if there is a problem checking a writable file. | 45 // called on the UI thread if there is a problem checking a writable file. |
| 46 void HandleWritableFileError(); | 46 void HandleWritableFileError(); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 class FileSystemGetWritableFileEntryFunction : public FileSystemEntryFunction { | 49 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { |
| 50 public: | 50 public: |
| 51 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getWritableFileEntry"); | 51 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.getWritableEntry"); |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 virtual ~FileSystemGetWritableFileEntryFunction() {} | 54 virtual ~FileSystemGetWritableEntryFunction() {} |
| 55 virtual bool RunImpl() OVERRIDE; | 55 virtual bool RunImpl() OVERRIDE; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class FileSystemIsWritableFileEntryFunction : public SyncExtensionFunction { | 58 class FileSystemIsWritableEntryFunction : public SyncExtensionFunction { |
| 59 public: | 59 public: |
| 60 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.isWritableFileEntry"); | 60 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.isWritableEntry"); |
| 61 | 61 |
| 62 protected: | 62 protected: |
| 63 virtual ~FileSystemIsWritableFileEntryFunction() {} | 63 virtual ~FileSystemIsWritableEntryFunction() {} |
| 64 virtual bool RunImpl() OVERRIDE; | 64 virtual bool RunImpl() OVERRIDE; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class FileSystemChooseFileFunction : public FileSystemEntryFunction { | 67 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { |
| 68 public: | 68 public: |
| 69 // Allow picker UI to be skipped in testing. | 69 // Allow picker UI to be skipped in testing. |
| 70 static void SkipPickerAndAlwaysSelectPathForTest(FilePath* path); | 70 static void SkipPickerAndAlwaysSelectPathForTest(FilePath* path); |
| 71 static void SkipPickerAndAlwaysCancelForTest(); | 71 static void SkipPickerAndAlwaysCancelForTest(); |
| 72 static void StopSkippingPickerForTest(); | 72 static void StopSkippingPickerForTest(); |
| 73 | 73 |
| 74 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseFile"); | 74 DECLARE_EXTENSION_FUNCTION_NAME("fileSystem.chooseEntry"); |
| 75 | 75 |
| 76 typedef std::vector<linked_ptr<extensions::api::file_system::AcceptOption> > | 76 typedef std::vector<linked_ptr<extensions::api::file_system::AcceptOption> > |
| 77 AcceptOptions; | 77 AcceptOptions; |
| 78 | 78 |
| 79 static void BuildFileTypeInfo( | 79 static void BuildFileTypeInfo( |
| 80 ui::SelectFileDialog::FileTypeInfo* file_type_info, | 80 ui::SelectFileDialog::FileTypeInfo* file_type_info, |
| 81 const FilePath::StringType& suggested_extension, | 81 const FilePath::StringType& suggested_extension, |
| 82 const AcceptOptions* accepts, | 82 const AcceptOptions* accepts, |
| 83 const bool* acceptsAllTypes); | 83 const bool* acceptsAllTypes); |
| 84 static void BuildSuggestion(const std::string* opt_name, | 84 static void BuildSuggestion(const std::string* opt_name, |
| 85 FilePath* suggested_name, | 85 FilePath* suggested_name, |
| 86 FilePath::StringType* suggested_extension); | 86 FilePath::StringType* suggested_extension); |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 class FilePicker; | 89 class FilePicker; |
| 90 | 90 |
| 91 virtual ~FileSystemChooseFileFunction() {} | 91 virtual ~FileSystemChooseEntryFunction() {} |
| 92 virtual bool RunImpl() OVERRIDE; | 92 virtual bool RunImpl() OVERRIDE; |
| 93 bool ShowPicker(const FilePath& suggested_path, | 93 bool ShowPicker(const FilePath& suggested_path, |
| 94 const ui::SelectFileDialog::FileTypeInfo& file_type_info, | 94 const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
| 95 ui::SelectFileDialog::Type picker_type, | 95 ui::SelectFileDialog::Type picker_type, |
| 96 EntryType entry_type); | 96 EntryType entry_type); |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 // FileSelected and FileSelectionCanceled are called by the file picker. | 99 // FileSelected and FileSelectionCanceled are called by the file picker. |
| 100 void FileSelected(const FilePath& path, EntryType entry_type); | 100 void FileSelected(const FilePath& path, EntryType entry_type); |
| 101 void FileSelectionCanceled(); | 101 void FileSelectionCanceled(); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 } // namespace extensions | 104 } // namespace extensions |
| 105 | 105 |
| 106 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 106 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |