| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 } // namespace file_system_api | 34 } // namespace file_system_api |
| 35 | 35 |
| 36 class FileSystemGetDisplayPathFunction : public ChromeSyncExtensionFunction { | 36 class FileSystemGetDisplayPathFunction : public ChromeSyncExtensionFunction { |
| 37 public: | 37 public: |
| 38 DECLARE_EXTENSION_FUNCTION("fileSystem.getDisplayPath", | 38 DECLARE_EXTENSION_FUNCTION("fileSystem.getDisplayPath", |
| 39 FILESYSTEM_GETDISPLAYPATH) | 39 FILESYSTEM_GETDISPLAYPATH) |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 virtual ~FileSystemGetDisplayPathFunction() {} | 42 virtual ~FileSystemGetDisplayPathFunction() {} |
| 43 virtual bool RunImpl() OVERRIDE; | 43 virtual bool RunSync() OVERRIDE; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 class FileSystemEntryFunction : public ChromeAsyncExtensionFunction { | 46 class FileSystemEntryFunction : public ChromeAsyncExtensionFunction { |
| 47 protected: | 47 protected: |
| 48 FileSystemEntryFunction(); | 48 FileSystemEntryFunction(); |
| 49 | 49 |
| 50 virtual ~FileSystemEntryFunction() {} | 50 virtual ~FileSystemEntryFunction() {} |
| 51 | 51 |
| 52 // This is called when writable file entries are being returned. The function | 52 // This is called when writable file entries are being returned. The function |
| 53 // will ensure the files exist, creating them if necessary, and also check | 53 // will ensure the files exist, creating them if necessary, and also check |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 base::DictionaryValue* response_; | 81 base::DictionaryValue* response_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { | 84 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { |
| 85 public: | 85 public: |
| 86 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", | 86 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", |
| 87 FILESYSTEM_GETWRITABLEENTRY) | 87 FILESYSTEM_GETWRITABLEENTRY) |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 virtual ~FileSystemGetWritableEntryFunction() {} | 90 virtual ~FileSystemGetWritableEntryFunction() {} |
| 91 virtual bool RunImpl() OVERRIDE; | 91 virtual bool RunSync() OVERRIDE; |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 void CheckPermissionAndSendResponse(); | 94 void CheckPermissionAndSendResponse(); |
| 95 void SetIsDirectoryOnFileThread(); | 95 void SetIsDirectoryOnFileThread(); |
| 96 | 96 |
| 97 // The path to the file for which a writable entry has been requested. | 97 // The path to the file for which a writable entry has been requested. |
| 98 base::FilePath path_; | 98 base::FilePath path_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 class FileSystemIsWritableEntryFunction : public ChromeSyncExtensionFunction { | 101 class FileSystemIsWritableEntryFunction : public ChromeSyncExtensionFunction { |
| 102 public: | 102 public: |
| 103 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", | 103 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", |
| 104 FILESYSTEM_ISWRITABLEENTRY) | 104 FILESYSTEM_ISWRITABLEENTRY) |
| 105 | 105 |
| 106 protected: | 106 protected: |
| 107 virtual ~FileSystemIsWritableEntryFunction() {} | 107 virtual ~FileSystemIsWritableEntryFunction() {} |
| 108 virtual bool RunImpl() OVERRIDE; | 108 virtual bool RunSync() OVERRIDE; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { | 111 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { |
| 112 public: | 112 public: |
| 113 // Allow picker UI to be skipped in testing. | 113 // Allow picker UI to be skipped in testing. |
| 114 static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path); | 114 static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path); |
| 115 static void SkipPickerAndAlwaysSelectPathsForTest( | 115 static void SkipPickerAndAlwaysSelectPathsForTest( |
| 116 std::vector<base::FilePath>* paths); | 116 std::vector<base::FilePath>* paths); |
| 117 static void SkipPickerAndSelectSuggestedPathForTest(); | 117 static void SkipPickerAndSelectSuggestedPathForTest(); |
| 118 static void SkipPickerAndAlwaysCancelForTest(); | 118 static void SkipPickerAndAlwaysCancelForTest(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 138 const AcceptOptions* accepts, | 138 const AcceptOptions* accepts, |
| 139 const bool* acceptsAllTypes); | 139 const bool* acceptsAllTypes); |
| 140 static void BuildSuggestion(const std::string* opt_name, | 140 static void BuildSuggestion(const std::string* opt_name, |
| 141 base::FilePath* suggested_name, | 141 base::FilePath* suggested_name, |
| 142 base::FilePath::StringType* suggested_extension); | 142 base::FilePath::StringType* suggested_extension); |
| 143 | 143 |
| 144 protected: | 144 protected: |
| 145 class FilePicker; | 145 class FilePicker; |
| 146 | 146 |
| 147 virtual ~FileSystemChooseEntryFunction() {} | 147 virtual ~FileSystemChooseEntryFunction() {} |
| 148 virtual bool RunImpl() OVERRIDE; | 148 virtual bool RunSync() OVERRIDE; |
| 149 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, | 149 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
| 150 ui::SelectFileDialog::Type picker_type); | 150 ui::SelectFileDialog::Type picker_type); |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, | 153 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, |
| 154 const base::FilePath& previous_path); | 154 const base::FilePath& previous_path); |
| 155 | 155 |
| 156 // FilesSelected and FileSelectionCanceled are called by the file picker. | 156 // FilesSelected and FileSelectionCanceled are called by the file picker. |
| 157 void FilesSelected(const std::vector<base::FilePath>& path); | 157 void FilesSelected(const std::vector<base::FilePath>& path); |
| 158 void FileSelectionCanceled(); | 158 void FileSelectionCanceled(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 169 | 169 |
| 170 base::FilePath initial_path_; | 170 base::FilePath initial_path_; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 class FileSystemRetainEntryFunction : public ChromeAsyncExtensionFunction { | 173 class FileSystemRetainEntryFunction : public ChromeAsyncExtensionFunction { |
| 174 public: | 174 public: |
| 175 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) | 175 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) |
| 176 | 176 |
| 177 protected: | 177 protected: |
| 178 virtual ~FileSystemRetainEntryFunction() {} | 178 virtual ~FileSystemRetainEntryFunction() {} |
| 179 virtual bool RunImpl() OVERRIDE; | 179 virtual bool RunSync() OVERRIDE; |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 // Retains the file entry referenced by |entry_id| in apps::SavedFilesService. | 182 // Retains the file entry referenced by |entry_id| in apps::SavedFilesService. |
| 183 // |entry_id| must refer to an entry in an isolated file system. | 183 // |entry_id| must refer to an entry in an isolated file system. |
| 184 void RetainFileEntry(const std::string& entry_id); | 184 void RetainFileEntry(const std::string& entry_id); |
| 185 | 185 |
| 186 void SetIsDirectoryOnFileThread(); | 186 void SetIsDirectoryOnFileThread(); |
| 187 | 187 |
| 188 // Whether the file being retained is a directory. | 188 // Whether the file being retained is a directory. |
| 189 bool is_directory_; | 189 bool is_directory_; |
| 190 | 190 |
| 191 // The path to the file to retain. | 191 // The path to the file to retain. |
| 192 base::FilePath path_; | 192 base::FilePath path_; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 class FileSystemIsRestorableFunction : public ChromeSyncExtensionFunction { | 195 class FileSystemIsRestorableFunction : public ChromeSyncExtensionFunction { |
| 196 public: | 196 public: |
| 197 DECLARE_EXTENSION_FUNCTION("fileSystem.isRestorable", FILESYSTEM_ISRESTORABLE) | 197 DECLARE_EXTENSION_FUNCTION("fileSystem.isRestorable", FILESYSTEM_ISRESTORABLE) |
| 198 | 198 |
| 199 protected: | 199 protected: |
| 200 virtual ~FileSystemIsRestorableFunction() {} | 200 virtual ~FileSystemIsRestorableFunction() {} |
| 201 virtual bool RunImpl() OVERRIDE; | 201 virtual bool RunSync() OVERRIDE; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 class FileSystemRestoreEntryFunction : public FileSystemEntryFunction { | 204 class FileSystemRestoreEntryFunction : public FileSystemEntryFunction { |
| 205 public: | 205 public: |
| 206 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) | 206 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) |
| 207 | 207 |
| 208 protected: | 208 protected: |
| 209 virtual ~FileSystemRestoreEntryFunction() {} | 209 virtual ~FileSystemRestoreEntryFunction() {} |
| 210 virtual bool RunImpl() OVERRIDE; | 210 virtual bool RunSync() OVERRIDE; |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 } // namespace extensions | 213 } // namespace extensions |
| 214 | 214 |
| 215 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 215 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |