| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "chrome/browser/extensions/extension_function.h" | 14 #include "chrome/browser/extensions/extension_function.h" |
| 15 #include "chrome/browser/ui/shell_dialogs.h" | 15 #include "chrome/browser/ui/shell_dialogs.h" |
| 16 #include "googleurl/src/url_util.h" |
| 16 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 17 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 17 | 18 |
| 18 // Implements the Chrome Extension local File API. | 19 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. |
| 19 class RequestLocalFileSystemFunction | 20 class RequestLocalFileSystemFunction : public AsyncExtensionFunction { |
| 20 : public AsyncExtensionFunction { | 21 protected: |
| 21 public: | 22 friend class LocalFileSystemCallbackDispatcher; |
| 22 RequestLocalFileSystemFunction(); | 23 // AsyncExtensionFunction overrides. |
| 24 virtual bool RunImpl() OVERRIDE; |
| 25 void RespondSuccessOnUIThread(const std::string& name, |
| 26 const FilePath& root_path); |
| 27 void RespondFailedOnUIThread(base::PlatformFileError error_code); |
| 28 void RequestOnFileThread(const GURL& source_url); |
| 29 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); |
| 30 }; |
| 23 | 31 |
| 32 // Implements the chrome.fileBrowserPrivate.getFileTasks method. |
| 33 class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction { |
| 24 protected: | 34 protected: |
| 25 virtual ~RequestLocalFileSystemFunction(); | |
| 26 | |
| 27 // AsyncExtensionFunction overrides. | 35 // AsyncExtensionFunction overrides. |
| 28 virtual bool RunImpl() OVERRIDE; | 36 virtual bool RunImpl() OVERRIDE; |
| 29 | 37 |
| 30 private: | 38 private: |
| 31 friend class LocalFileSystemCallbackDispatcher; | 39 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTasks"); |
| 32 void RespondSuccessOnUIThread(const std::string& name, | 40 }; |
| 33 const FilePath& path); | 41 |
| 42 |
| 43 // Implements the chrome.fileBrowserPrivate.executeTask method. |
| 44 class ExecuteTasksFileBrowserFunction : public AsyncExtensionFunction { |
| 45 protected: |
| 46 // AsyncExtensionFunction overrides. |
| 47 virtual bool RunImpl() OVERRIDE; |
| 48 |
| 49 private: |
| 50 struct FileDefinition { |
| 51 GURL target_file_url; |
| 52 FilePath virtual_path; |
| 53 bool is_directory; |
| 54 }; |
| 55 typedef std::vector<FileDefinition> FileDefinitionList; |
| 56 friend class ExecuteTasksFileSystemCallbackDispatcher; |
| 57 // Initates execution of context menu tasks identified with |task_id| for |
| 58 // each element of |files_list|. |
| 59 bool InitiateFileTaskExecution(const std::string& task_id, |
| 60 ListValue* files_list); |
| 61 void RequestFileEntryOnFileThread(const GURL& source_url, |
| 62 const std::string& task_id, |
| 63 const std::vector<FilePath>& file_urls); |
| 34 void RespondFailedOnUIThread(base::PlatformFileError error_code); | 64 void RespondFailedOnUIThread(base::PlatformFileError error_code); |
| 35 | 65 void ExecuteFileActionsOnUIThread(const std::string& task_id, |
| 36 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); | 66 const std::string& file_system_name, |
| 67 const FilePath& file_system_root, |
| 68 const FileDefinitionList& file_list); |
| 69 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.executeTask"); |
| 37 }; | 70 }; |
| 38 | 71 |
| 39 // Parent class for the chromium extension APIs for the file dialog. | 72 // Parent class for the chromium extension APIs for the file dialog. |
| 40 class FileDialogFunction | 73 class FileDialogFunction |
| 41 : public AsyncExtensionFunction { | 74 : public AsyncExtensionFunction { |
| 42 public: | 75 public: |
| 43 typedef std::vector<std::string> VirtualPathVec; | 76 typedef std::vector<std::string> VirtualPathVec; |
| 44 typedef std::vector<FilePath> FilePathVec; | 77 typedef std::vector<FilePath> FilePathVec; |
| 45 | 78 |
| 46 FileDialogFunction(); | 79 FileDialogFunction(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 virtual ~FileDialogStringsFunction() {} | 171 virtual ~FileDialogStringsFunction() {} |
| 139 | 172 |
| 140 // AsyncExtensionFunction overrides. | 173 // AsyncExtensionFunction overrides. |
| 141 virtual bool RunImpl() OVERRIDE; | 174 virtual bool RunImpl() OVERRIDE; |
| 142 | 175 |
| 143 private: | 176 private: |
| 144 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getStrings"); | 177 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getStrings"); |
| 145 }; | 178 }; |
| 146 | 179 |
| 147 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 180 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
| OLD | NEW |