| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 std::vector<base::FilePath> GetGrayListedDirectories(); | 33 std::vector<base::FilePath> GetGrayListedDirectories(); |
| 34 | 34 |
| 35 } // namespace file_system_api | 35 } // namespace file_system_api |
| 36 | 36 |
| 37 class FileSystemGetDisplayPathFunction : public ChromeSyncExtensionFunction { | 37 class FileSystemGetDisplayPathFunction : public ChromeSyncExtensionFunction { |
| 38 public: | 38 public: |
| 39 DECLARE_EXTENSION_FUNCTION("fileSystem.getDisplayPath", | 39 DECLARE_EXTENSION_FUNCTION("fileSystem.getDisplayPath", |
| 40 FILESYSTEM_GETDISPLAYPATH) | 40 FILESYSTEM_GETDISPLAYPATH) |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 virtual ~FileSystemGetDisplayPathFunction() {} | 43 ~FileSystemGetDisplayPathFunction() override {} |
| 44 virtual bool RunSync() override; | 44 bool RunSync() override; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class FileSystemEntryFunction : public ChromeAsyncExtensionFunction { | 47 class FileSystemEntryFunction : public ChromeAsyncExtensionFunction { |
| 48 protected: | 48 protected: |
| 49 FileSystemEntryFunction(); | 49 FileSystemEntryFunction(); |
| 50 | 50 |
| 51 virtual ~FileSystemEntryFunction() {} | 51 ~FileSystemEntryFunction() override {} |
| 52 | 52 |
| 53 // This is called when writable file entries are being returned. The function | 53 // This is called when writable file entries are being returned. The function |
| 54 // will ensure the files exist, creating them if necessary, and also check | 54 // will ensure the files exist, creating them if necessary, and also check |
| 55 // that none of the files are links. If it succeeds it proceeds to | 55 // that none of the files are links. If it succeeds it proceeds to |
| 56 // RegisterFileSystemsAndSendResponse, otherwise to HandleWritableFileError. | 56 // RegisterFileSystemsAndSendResponse, otherwise to HandleWritableFileError. |
| 57 void PrepareFilesForWritableApp(const std::vector<base::FilePath>& path); | 57 void PrepareFilesForWritableApp(const std::vector<base::FilePath>& path); |
| 58 | 58 |
| 59 // This will finish the choose file process. This is either called directly | 59 // This will finish the choose file process. This is either called directly |
| 60 // from FilesSelected, or from WritableFileChecker. It is called on the UI | 60 // from FilesSelected, or from WritableFileChecker. It is called on the UI |
| 61 // thread. | 61 // thread. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 81 // The dictionary to send as the response. | 81 // The dictionary to send as the response. |
| 82 base::DictionaryValue* response_; | 82 base::DictionaryValue* response_; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { | 85 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { |
| 86 public: | 86 public: |
| 87 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", | 87 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", |
| 88 FILESYSTEM_GETWRITABLEENTRY) | 88 FILESYSTEM_GETWRITABLEENTRY) |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 virtual ~FileSystemGetWritableEntryFunction() {} | 91 ~FileSystemGetWritableEntryFunction() override {} |
| 92 virtual bool RunAsync() override; | 92 bool RunAsync() override; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 void CheckPermissionAndSendResponse(); | 95 void CheckPermissionAndSendResponse(); |
| 96 void SetIsDirectoryOnFileThread(); | 96 void SetIsDirectoryOnFileThread(); |
| 97 | 97 |
| 98 // The path to the file for which a writable entry has been requested. | 98 // The path to the file for which a writable entry has been requested. |
| 99 base::FilePath path_; | 99 base::FilePath path_; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 class FileSystemIsWritableEntryFunction : public ChromeSyncExtensionFunction { | 102 class FileSystemIsWritableEntryFunction : public ChromeSyncExtensionFunction { |
| 103 public: | 103 public: |
| 104 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", | 104 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", |
| 105 FILESYSTEM_ISWRITABLEENTRY) | 105 FILESYSTEM_ISWRITABLEENTRY) |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 virtual ~FileSystemIsWritableEntryFunction() {} | 108 ~FileSystemIsWritableEntryFunction() override {} |
| 109 virtual bool RunSync() override; | 109 bool RunSync() override; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { | 112 class FileSystemChooseEntryFunction : public FileSystemEntryFunction { |
| 113 public: | 113 public: |
| 114 // Allow picker UI to be skipped in testing. | 114 // Allow picker UI to be skipped in testing. |
| 115 static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path); | 115 static void SkipPickerAndAlwaysSelectPathForTest(base::FilePath* path); |
| 116 static void SkipPickerAndAlwaysSelectPathsForTest( | 116 static void SkipPickerAndAlwaysSelectPathsForTest( |
| 117 std::vector<base::FilePath>* paths); | 117 std::vector<base::FilePath>* paths); |
| 118 static void SkipPickerAndSelectSuggestedPathForTest(); | 118 static void SkipPickerAndSelectSuggestedPathForTest(); |
| 119 static void SkipPickerAndAlwaysCancelForTest(); | 119 static void SkipPickerAndAlwaysCancelForTest(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 138 const base::FilePath::StringType& suggested_extension, | 138 const base::FilePath::StringType& suggested_extension, |
| 139 const AcceptOptions* accepts, | 139 const AcceptOptions* accepts, |
| 140 const bool* acceptsAllTypes); | 140 const bool* acceptsAllTypes); |
| 141 static void BuildSuggestion(const std::string* opt_name, | 141 static void BuildSuggestion(const std::string* opt_name, |
| 142 base::FilePath* suggested_name, | 142 base::FilePath* suggested_name, |
| 143 base::FilePath::StringType* suggested_extension); | 143 base::FilePath::StringType* suggested_extension); |
| 144 | 144 |
| 145 protected: | 145 protected: |
| 146 class FilePicker; | 146 class FilePicker; |
| 147 | 147 |
| 148 virtual ~FileSystemChooseEntryFunction() {} | 148 ~FileSystemChooseEntryFunction() override {} |
| 149 virtual bool RunAsync() override; | 149 bool RunAsync() override; |
| 150 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, | 150 void ShowPicker(const ui::SelectFileDialog::FileTypeInfo& file_type_info, |
| 151 ui::SelectFileDialog::Type picker_type); | 151 ui::SelectFileDialog::Type picker_type); |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, | 154 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, |
| 155 const base::FilePath& previous_path); | 155 const base::FilePath& previous_path); |
| 156 | 156 |
| 157 // FilesSelected and FileSelectionCanceled are called by the file picker. | 157 // FilesSelected and FileSelectionCanceled are called by the file picker. |
| 158 void FilesSelected(const std::vector<base::FilePath>& path); | 158 void FilesSelected(const std::vector<base::FilePath>& path); |
| 159 void FileSelectionCanceled(); | 159 void FileSelectionCanceled(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 170 void OnDirectoryAccessConfirmed(const std::vector<base::FilePath>& paths); | 170 void OnDirectoryAccessConfirmed(const std::vector<base::FilePath>& paths); |
| 171 | 171 |
| 172 base::FilePath initial_path_; | 172 base::FilePath initial_path_; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 class FileSystemRetainEntryFunction : public ChromeAsyncExtensionFunction { | 175 class FileSystemRetainEntryFunction : public ChromeAsyncExtensionFunction { |
| 176 public: | 176 public: |
| 177 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) | 177 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) |
| 178 | 178 |
| 179 protected: | 179 protected: |
| 180 virtual ~FileSystemRetainEntryFunction() {} | 180 ~FileSystemRetainEntryFunction() override {} |
| 181 virtual bool RunAsync() override; | 181 bool RunAsync() override; |
| 182 | 182 |
| 183 private: | 183 private: |
| 184 // Retains the file entry referenced by |entry_id| in apps::SavedFilesService. | 184 // Retains the file entry referenced by |entry_id| in apps::SavedFilesService. |
| 185 // |entry_id| must refer to an entry in an isolated file system. |path| is a | 185 // |entry_id| must refer to an entry in an isolated file system. |path| is a |
| 186 // path of the entry. |file_info| is base::File::Info of the entry if it can | 186 // path of the entry. |file_info| is base::File::Info of the entry if it can |
| 187 // be obtained. | 187 // be obtained. |
| 188 void RetainFileEntry(const std::string& entry_id, | 188 void RetainFileEntry(const std::string& entry_id, |
| 189 const base::FilePath& path, | 189 const base::FilePath& path, |
| 190 scoped_ptr<base::File::Info> file_info); | 190 scoped_ptr<base::File::Info> file_info); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 class FileSystemIsRestorableFunction : public ChromeSyncExtensionFunction { | 193 class FileSystemIsRestorableFunction : public ChromeSyncExtensionFunction { |
| 194 public: | 194 public: |
| 195 DECLARE_EXTENSION_FUNCTION("fileSystem.isRestorable", FILESYSTEM_ISRESTORABLE) | 195 DECLARE_EXTENSION_FUNCTION("fileSystem.isRestorable", FILESYSTEM_ISRESTORABLE) |
| 196 | 196 |
| 197 protected: | 197 protected: |
| 198 virtual ~FileSystemIsRestorableFunction() {} | 198 ~FileSystemIsRestorableFunction() override {} |
| 199 virtual bool RunSync() override; | 199 bool RunSync() override; |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 class FileSystemRestoreEntryFunction : public FileSystemEntryFunction { | 202 class FileSystemRestoreEntryFunction : public FileSystemEntryFunction { |
| 203 public: | 203 public: |
| 204 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) | 204 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) |
| 205 | 205 |
| 206 protected: | 206 protected: |
| 207 virtual ~FileSystemRestoreEntryFunction() {} | 207 ~FileSystemRestoreEntryFunction() override {} |
| 208 virtual bool RunAsync() override; | 208 bool RunAsync() override; |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 class FileSystemObserveDirectoryFunction : public ChromeSyncExtensionFunction { | 211 class FileSystemObserveDirectoryFunction : public ChromeSyncExtensionFunction { |
| 212 public: | 212 public: |
| 213 DECLARE_EXTENSION_FUNCTION("fileSystem.observeDirectory", | 213 DECLARE_EXTENSION_FUNCTION("fileSystem.observeDirectory", |
| 214 FILESYSTEM_OBSERVEDIRECTORY) | 214 FILESYSTEM_OBSERVEDIRECTORY) |
| 215 | 215 |
| 216 protected: | 216 protected: |
| 217 virtual ~FileSystemObserveDirectoryFunction() {} | 217 ~FileSystemObserveDirectoryFunction() override {} |
| 218 virtual bool RunSync() override; | 218 bool RunSync() override; |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 class FileSystemUnobserveEntryFunction : public ChromeSyncExtensionFunction { | 221 class FileSystemUnobserveEntryFunction : public ChromeSyncExtensionFunction { |
| 222 public: | 222 public: |
| 223 DECLARE_EXTENSION_FUNCTION("fileSystem.unobserveEntry", | 223 DECLARE_EXTENSION_FUNCTION("fileSystem.unobserveEntry", |
| 224 FILESYSTEM_UNOBSERVEENTRY) | 224 FILESYSTEM_UNOBSERVEENTRY) |
| 225 | 225 |
| 226 protected: | 226 protected: |
| 227 virtual ~FileSystemUnobserveEntryFunction() {} | 227 ~FileSystemUnobserveEntryFunction() override {} |
| 228 virtual bool RunSync() override; | 228 bool RunSync() override; |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 class FileSystemGetObservedEntriesFunction | 231 class FileSystemGetObservedEntriesFunction |
| 232 : public ChromeSyncExtensionFunction { | 232 : public ChromeSyncExtensionFunction { |
| 233 public: | 233 public: |
| 234 DECLARE_EXTENSION_FUNCTION("fileSystem.getObservedEntries", | 234 DECLARE_EXTENSION_FUNCTION("fileSystem.getObservedEntries", |
| 235 FILESYSTEM_GETOBSERVEDENTRIES); | 235 FILESYSTEM_GETOBSERVEDENTRIES); |
| 236 | 236 |
| 237 protected: | 237 protected: |
| 238 virtual ~FileSystemGetObservedEntriesFunction() {} | 238 ~FileSystemGetObservedEntriesFunction() override {} |
| 239 virtual bool RunSync() override; | 239 bool RunSync() override; |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 } // namespace extensions | 242 } // namespace extensions |
| 243 | 243 |
| 244 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 244 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |