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/platform_file.h" | 13 #include "base/platform_file.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 class GURL; | 19 class GURL; |
19 | 20 |
20 // Implements the Chrome Extension local File API. | 21 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. |
21 class RequestLocalFileSystemFunction | 22 class RequestLocalFileSystemFunction : public AsyncExtensionFunction { |
22 : public AsyncExtensionFunction { | 23 protected: |
23 public: | 24 friend class LocalFileSystemCallbackDispatcher; |
24 RequestLocalFileSystemFunction(); | 25 // AsyncExtensionFunction overrides. |
| 26 virtual bool RunImpl() OVERRIDE; |
| 27 void RespondSuccessOnUIThread(const std::string& name, |
| 28 const GURL& root_path); |
| 29 void RespondFailedOnUIThread(base::PlatformFileError error_code); |
| 30 void RequestOnFileThread(const GURL& source_url); |
| 31 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); |
| 32 }; |
25 | 33 |
| 34 // Implements the chrome.fileBrowserPrivate.getFileTasks method. |
| 35 class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction { |
26 protected: | 36 protected: |
27 virtual ~RequestLocalFileSystemFunction(); | |
28 | |
29 // AsyncExtensionFunction overrides. | 37 // AsyncExtensionFunction overrides. |
30 virtual bool RunImpl() OVERRIDE; | 38 virtual bool RunImpl() OVERRIDE; |
31 | 39 |
32 private: | 40 private: |
33 friend class LocalFileSystemCallbackDispatcher; | 41 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTasks"); |
34 void RespondSuccessOnUIThread(const std::string& name, | 42 }; |
35 const GURL& root); | 43 |
| 44 |
| 45 // Implements the chrome.fileBrowserPrivate.executeTask method. |
| 46 class ExecuteTasksFileBrowserFunction : public AsyncExtensionFunction { |
| 47 protected: |
| 48 // AsyncExtensionFunction overrides. |
| 49 virtual bool RunImpl() OVERRIDE; |
| 50 |
| 51 private: |
| 52 struct FileDefinition { |
| 53 GURL target_file_url; |
| 54 FilePath virtual_path; |
| 55 bool is_directory; |
| 56 }; |
| 57 typedef std::vector<FileDefinition> FileDefinitionList; |
| 58 friend class ExecuteTasksFileSystemCallbackDispatcher; |
| 59 // Initates execution of context menu tasks identified with |task_id| for |
| 60 // each element of |files_list|. |
| 61 bool InitiateFileTaskExecution(const std::string& task_id, |
| 62 ListValue* files_list); |
| 63 void RequestFileEntryOnFileThread(const GURL& source_url, |
| 64 const std::string& task_id, |
| 65 const std::vector<GURL>& file_urls); |
36 void RespondFailedOnUIThread(base::PlatformFileError error_code); | 66 void RespondFailedOnUIThread(base::PlatformFileError error_code); |
37 | 67 void ExecuteFileActionsOnUIThread(const std::string& task_id, |
38 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); | 68 const std::string& file_system_name, |
| 69 const GURL& file_system_root, |
| 70 const FileDefinitionList& file_list); |
| 71 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.executeTask"); |
39 }; | 72 }; |
40 | 73 |
41 // Parent class for the chromium extension APIs for the file dialog. | 74 // Parent class for the chromium extension APIs for the file dialog. |
42 class FileDialogFunction | 75 class FileDialogFunction |
43 : public AsyncExtensionFunction { | 76 : public AsyncExtensionFunction { |
44 public: | 77 public: |
45 typedef std::vector<std::string> VirtualPathVec; | 78 typedef std::vector<std::string> VirtualPathVec; |
46 typedef std::vector<FilePath> FilePathVec; | 79 typedef std::vector<FilePath> FilePathVec; |
47 | 80 |
48 FileDialogFunction(); | 81 FileDialogFunction(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 virtual ~FileDialogStringsFunction() {} | 195 virtual ~FileDialogStringsFunction() {} |
163 | 196 |
164 // AsyncExtensionFunction overrides. | 197 // AsyncExtensionFunction overrides. |
165 virtual bool RunImpl() OVERRIDE; | 198 virtual bool RunImpl() OVERRIDE; |
166 | 199 |
167 private: | 200 private: |
168 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getStrings"); | 201 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getStrings"); |
169 }; | 202 }; |
170 | 203 |
171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 204 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
OLD | NEW |