| 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/shell_dialogs/select_file_dialog.h" | 10 #include "ui/shell_dialogs/select_file_dialog.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Adds an entry to the response dictionary. | 67 // Adds an entry to the response dictionary. |
| 68 void AddEntryToResponse(const base::FilePath& path, | 68 void AddEntryToResponse(const base::FilePath& path, |
| 69 const std::string& id_override); | 69 const std::string& id_override); |
| 70 | 70 |
| 71 // called on the UI thread if there is a problem checking a writable file. | 71 // called on the UI thread if there is a problem checking a writable file. |
| 72 void HandleWritableFileError(const base::FilePath& error_path); | 72 void HandleWritableFileError(const base::FilePath& error_path); |
| 73 | 73 |
| 74 // Whether multiple entries have been requested. | 74 // Whether multiple entries have been requested. |
| 75 bool multiple_; | 75 bool multiple_; |
| 76 | 76 |
| 77 // Whether a directory has been requested. |
| 78 bool is_directory_; |
| 79 |
| 77 // The dictionary to send as the response. | 80 // The dictionary to send as the response. |
| 78 base::DictionaryValue* response_; | 81 base::DictionaryValue* response_; |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { | 84 class FileSystemGetWritableEntryFunction : public FileSystemEntryFunction { |
| 82 public: | 85 public: |
| 83 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", | 86 DECLARE_EXTENSION_FUNCTION("fileSystem.getWritableEntry", |
| 84 FILESYSTEM_GETWRITABLEENTRY) | 87 FILESYSTEM_GETWRITABLEENTRY) |
| 85 | 88 |
| 86 protected: | 89 protected: |
| 87 virtual ~FileSystemGetWritableEntryFunction() {} | 90 virtual ~FileSystemGetWritableEntryFunction() {} |
| 88 virtual bool RunImpl() OVERRIDE; | 91 virtual bool RunImpl() OVERRIDE; |
| 92 |
| 93 private: |
| 94 void CheckPermissionAndSendResponse(); |
| 95 void SetIsDirectoryOnFileThread(); |
| 96 |
| 97 // The path to the file for which a writable entry has been requested. |
| 98 base::FilePath path_; |
| 89 }; | 99 }; |
| 90 | 100 |
| 91 class FileSystemIsWritableEntryFunction : public SyncExtensionFunction { | 101 class FileSystemIsWritableEntryFunction : public SyncExtensionFunction { |
| 92 public: | 102 public: |
| 93 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", | 103 DECLARE_EXTENSION_FUNCTION("fileSystem.isWritableEntry", |
| 94 FILESYSTEM_ISWRITABLEENTRY) | 104 FILESYSTEM_ISWRITABLEENTRY) |
| 95 | 105 |
| 96 protected: | 106 protected: |
| 97 virtual ~FileSystemIsWritableEntryFunction() {} | 107 virtual ~FileSystemIsWritableEntryFunction() {} |
| 98 virtual bool RunImpl() OVERRIDE; | 108 virtual bool RunImpl() OVERRIDE; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, | 149 void SetInitialPathOnFileThread(const base::FilePath& suggested_name, |
| 140 const base::FilePath& previous_path); | 150 const base::FilePath& previous_path); |
| 141 | 151 |
| 142 // FilesSelected and FileSelectionCanceled are called by the file picker. | 152 // FilesSelected and FileSelectionCanceled are called by the file picker. |
| 143 void FilesSelected(const std::vector<base::FilePath>& path); | 153 void FilesSelected(const std::vector<base::FilePath>& path); |
| 144 void FileSelectionCanceled(); | 154 void FileSelectionCanceled(); |
| 145 | 155 |
| 146 base::FilePath initial_path_; | 156 base::FilePath initial_path_; |
| 147 }; | 157 }; |
| 148 | 158 |
| 149 class FileSystemRetainEntryFunction : public SyncExtensionFunction { | 159 class FileSystemRetainEntryFunction : public AsyncExtensionFunction { |
| 150 public: | 160 public: |
| 151 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) | 161 DECLARE_EXTENSION_FUNCTION("fileSystem.retainEntry", FILESYSTEM_RETAINENTRY) |
| 152 | 162 |
| 153 protected: | 163 protected: |
| 154 virtual ~FileSystemRetainEntryFunction() {} | 164 virtual ~FileSystemRetainEntryFunction() {} |
| 155 virtual bool RunImpl() OVERRIDE; | 165 virtual bool RunImpl() OVERRIDE; |
| 156 | 166 |
| 157 private: | 167 private: |
| 158 // Retains the file entry referenced by |entry_id| in apps::SavedFilesService. | 168 // Retains the file entry referenced by |entry_id| in apps::SavedFilesService. |
| 159 // |entry_id| must refer to an entry in an isolated file system. | 169 // |entry_id| must refer to an entry in an isolated file system. |
| 160 bool RetainFileEntry(const std::string& entry_id); | 170 void RetainFileEntry(const std::string& entry_id); |
| 171 |
| 172 void SetIsDirectoryOnFileThread(); |
| 173 |
| 174 // Whether the file being retained is a directory. |
| 175 bool is_directory_; |
| 176 |
| 177 // The path to the file to retain. |
| 178 base::FilePath path_; |
| 161 }; | 179 }; |
| 162 | 180 |
| 163 class FileSystemIsRestorableFunction : public SyncExtensionFunction { | 181 class FileSystemIsRestorableFunction : public SyncExtensionFunction { |
| 164 public: | 182 public: |
| 165 DECLARE_EXTENSION_FUNCTION("fileSystem.isRestorable", FILESYSTEM_ISRESTORABLE) | 183 DECLARE_EXTENSION_FUNCTION("fileSystem.isRestorable", FILESYSTEM_ISRESTORABLE) |
| 166 | 184 |
| 167 protected: | 185 protected: |
| 168 virtual ~FileSystemIsRestorableFunction() {} | 186 virtual ~FileSystemIsRestorableFunction() {} |
| 169 virtual bool RunImpl() OVERRIDE; | 187 virtual bool RunImpl() OVERRIDE; |
| 170 }; | 188 }; |
| 171 | 189 |
| 172 class FileSystemRestoreEntryFunction : public FileSystemEntryFunction { | 190 class FileSystemRestoreEntryFunction : public FileSystemEntryFunction { |
| 173 public: | 191 public: |
| 174 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) | 192 DECLARE_EXTENSION_FUNCTION("fileSystem.restoreEntry", FILESYSTEM_RESTOREENTRY) |
| 175 | 193 |
| 176 protected: | 194 protected: |
| 177 virtual ~FileSystemRestoreEntryFunction() {} | 195 virtual ~FileSystemRestoreEntryFunction() {} |
| 178 virtual bool RunImpl() OVERRIDE; | 196 virtual bool RunImpl() OVERRIDE; |
| 179 }; | 197 }; |
| 180 | 198 |
| 181 } // namespace extensions | 199 } // namespace extensions |
| 182 | 200 |
| 183 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ | 201 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_API_H_ |
| OLD | NEW |