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. |
| 20 class RequestLocalFileSystemFunctionBase : public AsyncExtensionFunction { |
| 21 protected: |
| 22 friend class LocalFileSystemCallbackDispatcher; |
| 23 // AsyncExtensionFunction overrides. |
| 24 virtual bool RunImpl() OVERRIDE; |
| 25 void RespondSuccessOnUIThread(const std::string& name, |
| 26 const FilePath& root_path, |
| 27 const GURL& file_url); |
| 28 void RespondFailedOnUIThread(base::PlatformFileError error_code); |
| 29 void RequestOnFileThread(const GURL& source_url, const GURL& file_url); |
| 30 }; |
| 31 |
| 32 // Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. |
19 class RequestLocalFileSystemFunction | 33 class RequestLocalFileSystemFunction |
20 : public AsyncExtensionFunction { | 34 : public RequestLocalFileSystemFunctionBase { |
21 public: | 35 private: |
22 RequestLocalFileSystemFunction(); | 36 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); |
| 37 }; |
23 | 38 |
| 39 // Implements the chrome.fileBrowserPrivate.getFileTasks method. |
| 40 class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction { |
24 protected: | 41 protected: |
25 virtual ~RequestLocalFileSystemFunction(); | |
26 | |
27 // AsyncExtensionFunction overrides. | 42 // AsyncExtensionFunction overrides. |
28 virtual bool RunImpl() OVERRIDE; | 43 virtual bool RunImpl() OVERRIDE; |
29 | 44 |
30 private: | 45 private: |
31 friend class LocalFileSystemCallbackDispatcher; | |
32 void RespondSuccessOnUIThread(const std::string& name, | |
33 const FilePath& path); | |
34 void RespondFailedOnUIThread(base::PlatformFileError error_code); | |
35 | 46 |
36 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.requestLocalFileSystem"); | 47 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getFileTasks"); |
| 48 }; |
| 49 |
| 50 |
| 51 // Implements the chrome.fileBrowserPrivate.executeTask method. |
| 52 class ExecuteTasksFileBrowserFunction : public AsyncExtensionFunction { |
| 53 protected: |
| 54 // AsyncExtensionFunction overrides. |
| 55 virtual bool RunImpl() OVERRIDE; |
| 56 |
| 57 private: |
| 58 // Grants access for local file system element represented by |
| 59 // |origin_file_url| from handler extension identified by |
| 60 // |handler_extension_id|. It also modifies |origin_file_url| to make it |
| 61 // usable within handler extension - replaces origin extension id with |
| 62 // handlers's. |
| 63 bool GrantLocalFileSystemAccess(const GURL& origin_file_url, |
| 64 const std::string& handler_extension_id, |
| 65 GURL* handler_file_url); |
| 66 |
| 67 // Executes context menu tasks for each element of |files_list|. |
| 68 bool ExecuteContextMenuTasks(const std::string& handler_extension_id, |
| 69 const std::string& action_id, |
| 70 ListValue* files_list); |
| 71 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.executeTask"); |
37 }; | 72 }; |
38 | 73 |
39 // Parent class for the chromium extension APIs for the file dialog. | 74 // Parent class for the chromium extension APIs for the file dialog. |
40 class FileDialogFunction | 75 class FileDialogFunction |
41 : public AsyncExtensionFunction { | 76 : public AsyncExtensionFunction { |
42 public: | 77 public: |
43 typedef std::vector<std::string> VirtualPathVec; | 78 typedef std::vector<std::string> VirtualPathVec; |
44 typedef std::vector<FilePath> FilePathVec; | 79 typedef std::vector<FilePath> FilePathVec; |
45 | 80 |
46 FileDialogFunction(); | 81 FileDialogFunction(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 virtual ~FileDialogStringsFunction() {} | 173 virtual ~FileDialogStringsFunction() {} |
139 | 174 |
140 // AsyncExtensionFunction overrides. | 175 // AsyncExtensionFunction overrides. |
141 virtual bool RunImpl() OVERRIDE; | 176 virtual bool RunImpl() OVERRIDE; |
142 | 177 |
143 private: | 178 private: |
144 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getStrings"); | 179 DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getStrings"); |
145 }; | 180 }; |
146 | 181 |
147 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ | 182 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_BROWSER_PRIVATE_API_H_ |
OLD | NEW |