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 // This file provides utility functions for "file tasks". | 5 // This file provides utility functions for "file tasks". |
6 // | 6 // |
7 // WHAT ARE FILE TASKS? | 7 // WHAT ARE FILE TASKS? |
8 // | 8 // |
9 // File tasks are representation of actions that can be performed over the | 9 // File tasks are representation of actions that can be performed over the |
10 // currently selected files from Files.app. A task can be either of: | 10 // currently selected files from Files.app. A task can be either of: |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // without any handler. Browser will take care of handling the file (ex. PDF). | 97 // without any handler. Browser will take care of handling the file (ex. PDF). |
98 // | 98 // |
99 // chrome.fileManagerPrivate.executeTasks() is used to open a file with a | 99 // chrome.fileManagerPrivate.executeTasks() is used to open a file with a |
100 // handler (Chrome Extension/App or Drive App). | 100 // handler (Chrome Extension/App or Drive App). |
101 // | 101 // |
102 // Some built-in handlers such as "play" are handled internally in Files.app. | 102 // Some built-in handlers such as "play" are handled internally in Files.app. |
103 // "mount-archive" is handled very differently. The task execution business | 103 // "mount-archive" is handled very differently. The task execution business |
104 // should be simplified: crbug.com/267313 | 104 // should be simplified: crbug.com/267313 |
105 // | 105 // |
106 // See also: | 106 // See also: |
107 // ui/file_manager/file_manager/js/file_tasks.js | 107 // ui/file_manager/file_manager/foreground/js/file_tasks.js |
108 // | 108 // |
109 | 109 |
110 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 110 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
111 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 111 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
112 | 112 |
113 #include <set> | 113 #include <set> |
114 #include <string> | 114 #include <string> |
115 #include <vector> | 115 #include <vector> |
116 | 116 |
117 #include "base/basictypes.h" | 117 #include "base/basictypes.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 TaskType task_type; | 159 TaskType task_type; |
160 std::string action_id; | 160 std::string action_id; |
161 }; | 161 }; |
162 | 162 |
163 // Describes a task with extra information such as icon URL. | 163 // Describes a task with extra information such as icon URL. |
164 class FullTaskDescriptor { | 164 class FullTaskDescriptor { |
165 public: | 165 public: |
166 FullTaskDescriptor(const TaskDescriptor& task_descriptor, | 166 FullTaskDescriptor(const TaskDescriptor& task_descriptor, |
167 const std::string& task_title, | 167 const std::string& task_title, |
168 const GURL& icon_url, | 168 const GURL& icon_url, |
169 bool is_default); | 169 bool is_default, |
| 170 bool is_generic_file_handler); |
170 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } | 171 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } |
171 | 172 |
172 // The title of the task. | 173 // The title of the task. |
173 const std::string& task_title() const { return task_title_; } | 174 const std::string& task_title() const { return task_title_; } |
174 // The icon URL for the task (ex. app icon) | 175 // The icon URL for the task (ex. app icon) |
175 const GURL& icon_url() const { return icon_url_; } | 176 const GURL& icon_url() const { return icon_url_; } |
176 | 177 |
177 // True if this task is set as default. | 178 // True if this task is set as default. |
178 bool is_default() const { return is_default_; } | 179 bool is_default() const { return is_default_; } |
179 void set_is_default(bool is_default) { is_default_ = is_default; } | 180 void set_is_default(bool is_default) { is_default_ = is_default; } |
180 | 181 |
| 182 // True if this task is from generic file handler. Generic file handler is a |
| 183 // file handler which handles any type of files (e.g. extensions: ["*"], |
| 184 // types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not |
| 185 // generic file handler. |
| 186 bool is_generic_file_handler() const { return is_generic_file_handler_; } |
| 187 void set_is_generic_file_handler(bool is_generic_file_handler) { |
| 188 is_generic_file_handler_ = is_generic_file_handler; |
| 189 } |
| 190 |
181 private: | 191 private: |
182 TaskDescriptor task_descriptor_; | 192 TaskDescriptor task_descriptor_; |
183 std::string task_title_; | 193 std::string task_title_; |
184 GURL icon_url_; | 194 GURL icon_url_; |
185 bool is_default_; | 195 bool is_default_; |
| 196 bool is_generic_file_handler_; |
186 }; | 197 }; |
187 | 198 |
188 // Update the default file handler for the given sets of suffixes and MIME | 199 // Update the default file handler for the given sets of suffixes and MIME |
189 // types. | 200 // types. |
190 void UpdateDefaultTask(PrefService* pref_service, | 201 void UpdateDefaultTask(PrefService* pref_service, |
191 const std::string& task_id, | 202 const std::string& task_id, |
192 const std::set<std::string>& suffixes, | 203 const std::set<std::string>& suffixes, |
193 const std::set<std::string>& mime_types); | 204 const std::set<std::string>& mime_types); |
194 | 205 |
195 // Returns the task ID of the default task for the given |mime_type|/|suffix| | 206 // Returns the task ID of the default task for the given |mime_type|/|suffix| |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 typedef extensions::app_file_handler_util::PathAndMimeTypeSet | 258 typedef extensions::app_file_handler_util::PathAndMimeTypeSet |
248 PathAndMimeTypeSet; | 259 PathAndMimeTypeSet; |
249 | 260 |
250 // Finds the Drive app tasks that can be used with the given |path_mime_set| | 261 // Finds the Drive app tasks that can be used with the given |path_mime_set| |
251 // from |drive_app_registry|, and append them to the |result_list|. | 262 // from |drive_app_registry|, and append them to the |result_list|. |
252 // Drive app tasks will be found only if all of the files are on Drive. | 263 // Drive app tasks will be found only if all of the files are on Drive. |
253 void FindDriveAppTasks(const drive::DriveAppRegistry& drive_app_registry, | 264 void FindDriveAppTasks(const drive::DriveAppRegistry& drive_app_registry, |
254 const PathAndMimeTypeSet& path_mime_set, | 265 const PathAndMimeTypeSet& path_mime_set, |
255 std::vector<FullTaskDescriptor>* result_list); | 266 std::vector<FullTaskDescriptor>* result_list); |
256 | 267 |
| 268 // Returns whether a file handler info is a generic file handler or not. |
| 269 bool IsGenericFileHandler(const extensions::FileHandlerInfo& file_handler_info); |
| 270 |
257 // Finds the file handler tasks (apps declaring "file_handlers" in | 271 // Finds the file handler tasks (apps declaring "file_handlers" in |
258 // manifest.json) that can be used with the given files, appending them to | 272 // manifest.json) that can be used with the given files, appending them to |
259 // the |result_list|. | 273 // the |result_list|. |
260 void FindFileHandlerTasks(Profile* profile, | 274 void FindFileHandlerTasks(Profile* profile, |
261 const PathAndMimeTypeSet& path_mime_set, | 275 const PathAndMimeTypeSet& path_mime_set, |
262 std::vector<FullTaskDescriptor>* result_list); | 276 std::vector<FullTaskDescriptor>* result_list); |
263 | 277 |
264 // Finds the file browser handler tasks (app/extensions declaring | 278 // Finds the file browser handler tasks (app/extensions declaring |
265 // "file_browser_handlers" in manifest.json) that can be used with the | 279 // "file_browser_handlers" in manifest.json) that can be used with the |
266 // given files, appending them to the |result_list|. | 280 // given files, appending them to the |result_list|. |
(...skipping 24 matching lines...) Expand all Loading... |
291 // task is found (i.e. the default task may not exist in |tasks|). No tasks | 305 // task is found (i.e. the default task may not exist in |tasks|). No tasks |
292 // should be set as default before calling this function. | 306 // should be set as default before calling this function. |
293 void ChooseAndSetDefaultTask(const PrefService& pref_service, | 307 void ChooseAndSetDefaultTask(const PrefService& pref_service, |
294 const PathAndMimeTypeSet& path_mime_set, | 308 const PathAndMimeTypeSet& path_mime_set, |
295 std::vector<FullTaskDescriptor>* tasks); | 309 std::vector<FullTaskDescriptor>* tasks); |
296 | 310 |
297 } // namespace file_tasks | 311 } // namespace file_tasks |
298 } // namespace file_manager | 312 } // namespace file_manager |
299 | 313 |
300 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 314 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
OLD | NEW |