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 representatiosn of actions that can be performed over the | 9 // File tasks are representatiosn 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ | 110 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ |
111 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ | 111 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_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" |
118 #include "base/callback_forward.h" | 118 #include "base/callback_forward.h" |
| 119 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
119 | 120 |
120 class GURL; | 121 class GURL; |
121 class PrefService; | 122 class PrefService; |
122 class Profile; | 123 class Profile; |
123 | 124 |
| 125 namespace drive { |
| 126 class DriveAppRegistry; |
| 127 } |
| 128 |
124 namespace fileapi { | 129 namespace fileapi { |
125 class FileSystemURL; | 130 class FileSystemURL; |
126 } | 131 } |
127 | 132 |
128 namespace file_manager { | 133 namespace file_manager { |
129 namespace file_tasks { | 134 namespace file_tasks { |
130 | 135 |
131 // Task types as explained in the comment above. Search for <task-type>. | 136 // Task types as explained in the comment above. Search for <task-type>. |
132 enum TaskType { | 137 enum TaskType { |
133 TASK_TYPE_FILE_BROWSER_HANDLER, | 138 TASK_TYPE_FILE_BROWSER_HANDLER, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // The callback won't be called if the function returns | 217 // The callback won't be called if the function returns |
213 // false. | 218 // false. |
214 bool ExecuteFileTask(Profile* profile, | 219 bool ExecuteFileTask(Profile* profile, |
215 const GURL& source_url, | 220 const GURL& source_url, |
216 const std::string& app_id, | 221 const std::string& app_id, |
217 int32 tab_id, | 222 int32 tab_id, |
218 const TaskDescriptor& task, | 223 const TaskDescriptor& task, |
219 const std::vector<fileapi::FileSystemURL>& file_urls, | 224 const std::vector<fileapi::FileSystemURL>& file_urls, |
220 const FileTaskFinishedCallback& done); | 225 const FileTaskFinishedCallback& done); |
221 | 226 |
| 227 typedef extensions::app_file_handler_util::PathAndMimeTypeSet |
| 228 PathAndMimeTypeSet; |
| 229 |
| 230 // Holds fields to build a task result. |
| 231 struct TaskInfo; |
| 232 |
| 233 // Map from a task id to TaskInfo. |
| 234 typedef std::map<std::string, TaskInfo> TaskInfoMap; |
| 235 |
| 236 // Looks up available apps for each file in |path_mime_set| in the |
| 237 // |registry|, and returns the intersection of all available apps as a |
| 238 // map from task id to TaskInfo. |
| 239 void GetAvailableDriveTasks(const drive::DriveAppRegistry& registry, |
| 240 const PathAndMimeTypeSet& path_mime_set, |
| 241 TaskInfoMap* task_info_map); |
| 242 |
| 243 // Looks in the preferences and finds any of the available apps that are |
| 244 // also listed as default apps for any of the files in the info list. |
| 245 void FindDefaultDriveTasks(const PrefService& pref_service, |
| 246 const PathAndMimeTypeSet& path_mime_set, |
| 247 const TaskInfoMap& task_info_map, |
| 248 std::set<std::string>* default_tasks); |
| 249 |
| 250 // Creates a list of each task in |task_info_map| and stores the result into |
| 251 // |result_list|. If a default task is set in the result list, |
| 252 // |default_already_set| is set to true. |
| 253 void CreateDriveTasks(const TaskInfoMap& task_info_map, |
| 254 const std::set<std::string>& default_tasks, |
| 255 ListValue* result_list, |
| 256 bool* default_already_set); |
| 257 |
| 258 // Finds the drive app tasks that can be used with the given files, and |
| 259 // append them to the |result_list|. |*default_already_set| indicates if |
| 260 // the |result_list| already contains the default task. If the value is |
| 261 // false, the function will find the default task and set the value to true |
| 262 // if found. |
| 263 // |
| 264 // "taskId" field in |result_list| will look like |
| 265 // "<drive-app-id>|drive|open-with" (See also file_tasks.h). |
| 266 // "driveApp" field in |result_list| will be set to "true". |
| 267 void FindDriveAppTasks(Profile* profile, |
| 268 const PathAndMimeTypeSet& path_mime_set, |
| 269 ListValue* result_list, |
| 270 bool* default_already_set); |
| 271 |
| 272 // Finds the file handler tasks (apps declaring "file_handlers" in |
| 273 // manifest.json) that can be used with the given files, appending them to |
| 274 // the |result_list|. See the comment at FindDriveAppTasks() about |
| 275 // |default_already_set| |
| 276 void FindFileHandlerTasks(Profile* profile, |
| 277 const PathAndMimeTypeSet& path_mime_set, |
| 278 ListValue* result_list, |
| 279 bool* default_already_set); |
| 280 |
| 281 // Finds the file browser handler tasks (app/extensions declaring |
| 282 // "file_browser_handlers" in manifest.json) that can be used with the |
| 283 // given files, appending them to the |result_list|. See the comment at |
| 284 // FindDriveAppTasks() about |default_already_set| |
| 285 void FindFileBrowserHandlerTasks( |
| 286 Profile* profile, |
| 287 const std::vector<GURL>& file_urls, |
| 288 const std::vector<base::FilePath>& file_paths, |
| 289 ListValue* result_list, |
| 290 bool* default_already_set); |
| 291 |
| 292 // Finds all types (drive, file handlers, file browser handlers) of |
| 293 // tasks. See the comment at FindDriveAppTasks() about |result_list|. |
| 294 void FindAllTypesOfTasks( |
| 295 Profile* profile, |
| 296 const PathAndMimeTypeSet& path_mime_set, |
| 297 const std::vector<GURL>& file_urls, |
| 298 const std::vector<base::FilePath>& file_paths, |
| 299 ListValue* result_list); |
| 300 |
222 } // namespace file_tasks | 301 } // namespace file_tasks |
223 } // namespace file_manager | 302 } // namespace file_manager |
224 | 303 |
225 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ | 304 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ |
OLD | NEW |