| 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_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
| 13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
| 14 #include "extensions/common/url_pattern_set.h" | 14 #include "extensions/common/url_pattern_set.h" |
| 15 | 15 |
| 16 class Browser; | 16 class Browser; |
| 17 class FileBrowserHandler; | 17 class FileBrowserHandler; |
| 18 class GURL; | 18 class GURL; |
| 19 class Profile; | 19 class Profile; |
| 20 | 20 |
| 21 namespace extensions { | 21 namespace extensions { |
| 22 class Extension; | 22 class Extension; |
| 23 } // namespace extensions | 23 } // namespace extensions |
| 24 | 24 |
| 25 namespace fileapi { |
| 26 class FileSystemURL; |
| 27 } |
| 28 |
| 25 namespace file_handler_util { | 29 namespace file_handler_util { |
| 26 | 30 |
| 27 // Specifies the task type for a task id that represents some file action, Drive | 31 // Specifies the task type for a task id that represents some file action, Drive |
| 28 // action, or Web Intent action. | 32 // action, or Web Intent action. |
| 29 extern const char kTaskFile[]; | 33 extern const char kTaskFile[]; |
| 30 extern const char kTaskDrive[]; | 34 extern const char kTaskDrive[]; |
| 31 extern const char kTaskWebIntent[]; | 35 extern const char kTaskWebIntent[]; |
| 32 extern const char kTaskApp[]; | 36 extern const char kTaskApp[]; |
| 33 | 37 |
| 34 void UpdateFileHandlerUsageStats(Profile* profile, const std::string& task_id); | 38 void UpdateFileHandlerUsageStats(Profile* profile, const std::string& task_id); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Creates the appropriate FileTaskExecutor for the given |extension_id|. | 100 // Creates the appropriate FileTaskExecutor for the given |extension_id|. |
| 97 static FileTaskExecutor* Create(Profile* profile, | 101 static FileTaskExecutor* Create(Profile* profile, |
| 98 const GURL& source_url, | 102 const GURL& source_url, |
| 99 const std::string& file_browser_id, | 103 const std::string& file_browser_id, |
| 100 int32 tab_id, | 104 int32 tab_id, |
| 101 const std::string& extension_id, | 105 const std::string& extension_id, |
| 102 const std::string& task_type, | 106 const std::string& task_type, |
| 103 const std::string& action_id); | 107 const std::string& action_id); |
| 104 | 108 |
| 105 // Same as ExecuteAndNotify, but no notification is performed. | 109 // Same as ExecuteAndNotify, but no notification is performed. |
| 106 virtual bool Execute(const std::vector<GURL>& file_urls); | 110 virtual bool Execute(const std::vector<fileapi::FileSystemURL>& file_urls); |
| 107 | 111 |
| 108 // Initiates execution of file handler task for each element of |file_urls|. | 112 // Initiates execution of file handler task for each element of |file_urls|. |
| 109 // Return |false| if the execution cannot be initiated. Otherwise returns | 113 // Return |false| if the execution cannot be initiated. Otherwise returns |
| 110 // |true| and then eventually calls |done| when all the files have | 114 // |true| and then eventually calls |done| when all the files have |
| 111 // been handled. If there is an error during processing the list of files, the | 115 // been handled. If there is an error during processing the list of files, the |
| 112 // caller will be informed of the failure via |done|, and the rest of | 116 // caller will be informed of the failure via |done|, and the rest of |
| 113 // the files will not be processed. | 117 // the files will not be processed. |
| 114 virtual bool ExecuteAndNotify(const std::vector<GURL>& file_urls, | 118 virtual bool ExecuteAndNotify( |
| 115 const FileTaskFinishedCallback& done) = 0; | 119 const std::vector<fileapi::FileSystemURL>& file_urls, |
| 120 const FileTaskFinishedCallback& done) = 0; |
| 116 | 121 |
| 117 protected: | 122 protected: |
| 118 explicit FileTaskExecutor(Profile* profile, | 123 explicit FileTaskExecutor(Profile* profile, |
| 119 const GURL& source_url, | 124 const GURL& source_url, |
| 120 const std::string& file_browser_id, | 125 const std::string& file_browser_id, |
| 121 const std::string& extension_id); | 126 const std::string& extension_id); |
| 122 virtual ~FileTaskExecutor(); | 127 virtual ~FileTaskExecutor(); |
| 123 | 128 |
| 124 // Checks if the file browser extension had file access permissions for the | 129 // Checks if the file browser extension had file access permissions for the |
| 125 // list of files. | 130 // list of files. |
| 126 bool FileBrowserHasAccessPermissionForFiles(const std::vector<GURL>& files); | 131 bool FileBrowserHasAccessPermissionForFiles( |
| 132 const std::vector<fileapi::FileSystemURL>& files); |
| 127 | 133 |
| 128 // Returns the profile that this task was created with. | 134 // Returns the profile that this task was created with. |
| 129 Profile* profile() { return profile_; } | 135 Profile* profile() { return profile_; } |
| 130 | 136 |
| 131 // Returns a browser to use for the current browser. | 137 // Returns a browser to use for the current browser. |
| 132 Browser* GetBrowser() const; | 138 Browser* GetBrowser() const; |
| 133 | 139 |
| 134 // Returns the extension for this profile. | 140 // Returns the extension for this profile. |
| 135 const extensions::Extension* GetExtension(); | 141 const extensions::Extension* GetExtension(); |
| 136 | 142 |
| 137 // Returns the extension ID set for this FileTaskExecutor. | 143 // Returns the extension ID set for this FileTaskExecutor. |
| 138 const std::string& extension_id() { return extension_id_; } | 144 const std::string& extension_id() { return extension_id_; } |
| 139 | 145 |
| 140 private: | 146 private: |
| 141 friend class base::RefCountedThreadSafe<FileTaskExecutor>; | 147 friend class base::RefCountedThreadSafe<FileTaskExecutor>; |
| 142 | 148 |
| 143 Profile* profile_; | 149 Profile* profile_; |
| 144 const GURL source_url_; | 150 const GURL source_url_; |
| 145 const std::string file_browser_id_; | 151 const std::string file_browser_id_; |
| 146 const std::string extension_id_; | 152 const std::string extension_id_; |
| 147 }; | 153 }; |
| 148 | 154 |
| 149 } // namespace file_handler_util | 155 } // namespace file_handler_util |
| 150 | 156 |
| 151 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ | 157 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_HANDLER_UTIL_H_ |
| OLD | NEW |