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 16 matching lines...) Expand all Loading... |
27 // | 27 // |
28 // 3) Drive app, which is a hosted app (i.e. just web site), that can work | 28 // 3) Drive app, which is a hosted app (i.e. just web site), that can work |
29 // with Drive (ex. Pixlr Editor). This information comes from | 29 // with Drive (ex. Pixlr Editor). This information comes from |
30 // drive::DriveAppRegistry. | 30 // drive::DriveAppRegistry. |
31 // | 31 // |
32 // See also: | 32 // See also: |
33 // https://chrome.google.com/webstore/category/collection/drive_apps | 33 // https://chrome.google.com/webstore/category/collection/drive_apps |
34 // | 34 // |
35 // For example, if the user is now selecting a JPEG file, Files.app will | 35 // For example, if the user is now selecting a JPEG file, Files.app will |
36 // receive file tasks represented as a JSON object via | 36 // receive file tasks represented as a JSON object via |
37 // chrome.fileBrowserPrivate.getFileTasks() API, which look like: | 37 // chrome.fileManagerPrivate.getFileTasks() API, which look like: |
38 // | 38 // |
39 // [ | 39 // [ |
40 // { | 40 // { |
41 // "driveApp": true, | 41 // "driveApp": true, |
42 // "iconUrl": "<app_icon_url>", | 42 // "iconUrl": "<app_icon_url>", |
43 // "isDefault": false, | 43 // "isDefault": false, |
44 // "taskId": "<drive_app_id>|drive|open-with", | 44 // "taskId": "<drive_app_id>|drive|open-with", |
45 // "title": "Drive App Name (ex. Pixlr Editor)" | 45 // "title": "Drive App Name (ex. Pixlr Editor)" |
46 // }, | 46 // }, |
47 // { | 47 // { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // - "drive" - Drive App | 86 // - "drive" - Drive App |
87 // | 87 // |
88 // <task-action-id> is an ID string used for identifying actions provided | 88 // <task-action-id> is an ID string used for identifying actions provided |
89 // from a single Chrome Extension/App. In other words, a single | 89 // from a single Chrome Extension/App. In other words, a single |
90 // Chrome/Extension can provide multiple file handlers hence each of them | 90 // Chrome/Extension can provide multiple file handlers hence each of them |
91 // needs to have a unique action ID. For Drive apps, <task-action-id> is | 91 // needs to have a unique action ID. For Drive apps, <task-action-id> is |
92 // always "open-with". | 92 // always "open-with". |
93 // | 93 // |
94 // HOW TASKS ARE EXECUTED? | 94 // HOW TASKS ARE EXECUTED? |
95 // | 95 // |
96 // chrome.fileBrowserPrivate.viewFiles() is used to open a file in a browser, | 96 // chrome.fileManagerPrivate.viewFiles() is used to open a file in a browser, |
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.fileBrowserPrivate.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/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" |
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 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
120 #include "chrome/common/extensions/api/file_browser_private.h" | 120 #include "chrome/common/extensions/api/file_manager_private.h" |
121 #include "url/gurl.h" | 121 #include "url/gurl.h" |
122 | 122 |
123 class PrefService; | 123 class PrefService; |
124 class Profile; | 124 class Profile; |
125 | 125 |
126 namespace drive { | 126 namespace drive { |
127 class DriveAppRegistry; | 127 class DriveAppRegistry; |
128 } | 128 } |
129 | 129 |
130 namespace storage { | 130 namespace storage { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Parses the task ID and extracts app ID, task type, and action ID into | 215 // Parses the task ID and extracts app ID, task type, and action ID into |
216 // |task|. On failure, returns false, and the contents of |task| are | 216 // |task|. On failure, returns false, and the contents of |task| are |
217 // undefined. | 217 // undefined. |
218 // | 218 // |
219 // See also the comment at the beginning of the file for details for how | 219 // See also the comment at the beginning of the file for details for how |
220 // "task_id" looks like. | 220 // "task_id" looks like. |
221 bool ParseTaskID(const std::string& task_id, TaskDescriptor* task); | 221 bool ParseTaskID(const std::string& task_id, TaskDescriptor* task); |
222 | 222 |
223 // The callback is used for ExecuteFileTask(). Will be called with true if | 223 // The callback is used for ExecuteFileTask(). Will be called with true if |
224 // the file task execution is successful, or false if unsuccessful. | 224 // the file task execution is successful, or false if unsuccessful. |
225 typedef base::Callback<void(extensions::api::file_browser_private::TaskResult | 225 typedef base::Callback<void(extensions::api::file_manager_private::TaskResult |
226 result)> FileTaskFinishedCallback; | 226 result)> FileTaskFinishedCallback; |
227 | 227 |
228 // Executes file handler task for each element of |file_urls|. | 228 // Executes file handler task for each element of |file_urls|. |
229 // Returns |false| if the execution cannot be initiated. Otherwise returns | 229 // Returns |false| if the execution cannot be initiated. Otherwise returns |
230 // |true| and then eventually calls |done| when all the files have been handled. | 230 // |true| and then eventually calls |done| when all the files have been handled. |
231 // |done| can be a null callback. | 231 // |done| can be a null callback. |
232 // | 232 // |
233 // Parameters: | 233 // Parameters: |
234 // profile - The profile used for making this function call. | 234 // profile - The profile used for making this function call. |
235 // source_url - The source URL which originates this function call. | 235 // source_url - The source URL which originates this function call. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // task is found (i.e. the default task may not exist in |tasks|). No tasks | 291 // 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. | 292 // should be set as default before calling this function. |
293 void ChooseAndSetDefaultTask(const PrefService& pref_service, | 293 void ChooseAndSetDefaultTask(const PrefService& pref_service, |
294 const PathAndMimeTypeSet& path_mime_set, | 294 const PathAndMimeTypeSet& path_mime_set, |
295 std::vector<FullTaskDescriptor>* tasks); | 295 std::vector<FullTaskDescriptor>* tasks); |
296 | 296 |
297 } // namespace file_tasks | 297 } // namespace file_tasks |
298 } // namespace file_manager | 298 } // namespace file_manager |
299 | 299 |
300 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 300 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
OLD | NEW |