| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // The icon URL for the task (ex. app icon) | 173 // The icon URL for the task (ex. app icon) |
| 174 const GURL& icon_url() const { return icon_url_; } | 174 const GURL& icon_url() const { return icon_url_; } |
| 175 | 175 |
| 176 // True if this task is set as default. | 176 // True if this task is set as default. |
| 177 bool is_default() const { return is_default_; } | 177 bool is_default() const { return is_default_; } |
| 178 void set_is_default(bool is_default) { is_default_ = is_default; } | 178 void set_is_default(bool is_default) { is_default_ = is_default; } |
| 179 | 179 |
| 180 // Returns a DictionaryValue representation, which looks like: | 180 // Returns a DictionaryValue representation, which looks like: |
| 181 // | 181 // |
| 182 // { | 182 // { |
| 183 // "driveApp": true, | |
| 184 // "iconUrl": "<app_icon_url>", | 183 // "iconUrl": "<app_icon_url>", |
| 185 // "isDefault": false, | 184 // "isDefault": false, |
| 186 // "taskId": "<drive_app_id>|drive|open-with", | 185 // "taskId": "<drive_app_id>|drive|open-with", |
| 187 // "title": "Drive App Name (ex. Pixlr Editor)" | 186 // "title": "Drive App Name (ex. Pixlr Editor)" |
| 188 // }, | 187 // }, |
| 189 // | 188 // |
| 190 // "iconUrl" is omitted if icon_url_ is empty. | 189 // "iconUrl" is omitted if icon_url_ is empty. |
| 191 // | 190 // |
| 192 // This representation will be used to send task info to the JavaScript. | 191 // This representation will be used to send task info to the JavaScript. |
| 193 scoped_ptr<base::DictionaryValue> AsDictionaryValue() const; | 192 scoped_ptr<base::DictionaryValue> AsDictionaryValue() const; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 const GURL& source_url, | 262 const GURL& source_url, |
| 264 const std::string& app_id, | 263 const std::string& app_id, |
| 265 int32 tab_id, | 264 int32 tab_id, |
| 266 const TaskDescriptor& task, | 265 const TaskDescriptor& task, |
| 267 const std::vector<fileapi::FileSystemURL>& file_urls, | 266 const std::vector<fileapi::FileSystemURL>& file_urls, |
| 268 const FileTaskFinishedCallback& done); | 267 const FileTaskFinishedCallback& done); |
| 269 | 268 |
| 270 typedef extensions::app_file_handler_util::PathAndMimeTypeSet | 269 typedef extensions::app_file_handler_util::PathAndMimeTypeSet |
| 271 PathAndMimeTypeSet; | 270 PathAndMimeTypeSet; |
| 272 | 271 |
| 273 // Finds the drive app tasks that can be used with the given |path_mime_set| | 272 // Finds the Drive app tasks that can be used with the given |path_mime_set| |
| 274 // from |drive_app_registry|, and append them to the |result_list|. | 273 // from |drive_app_registry|, and append them to the |result_list|. |
| 274 // Drive app tasks will be found only if all of the files are on Drive. |
| 275 void FindDriveAppTasks(const drive::DriveAppRegistry& drive_app_registry, | 275 void FindDriveAppTasks(const drive::DriveAppRegistry& drive_app_registry, |
| 276 const PathAndMimeTypeSet& path_mime_set, | 276 const PathAndMimeTypeSet& path_mime_set, |
| 277 std::vector<FullTaskDescriptor>* result_list); | 277 std::vector<FullTaskDescriptor>* result_list); |
| 278 | 278 |
| 279 // Finds the file handler tasks (apps declaring "file_handlers" in | 279 // Finds the file handler tasks (apps declaring "file_handlers" in |
| 280 // manifest.json) that can be used with the given files, appending them to | 280 // manifest.json) that can be used with the given files, appending them to |
| 281 // the |result_list|. | 281 // the |result_list|. |
| 282 void FindFileHandlerTasks(Profile* profile, | 282 void FindFileHandlerTasks(Profile* profile, |
| 283 const PathAndMimeTypeSet& path_mime_set, | 283 const PathAndMimeTypeSet& path_mime_set, |
| 284 std::vector<FullTaskDescriptor>* result_list); | 284 std::vector<FullTaskDescriptor>* result_list); |
| 285 | 285 |
| 286 // Finds the file browser handler tasks (app/extensions declaring | 286 // Finds the file browser handler tasks (app/extensions declaring |
| 287 // "file_browser_handlers" in manifest.json) that can be used with the | 287 // "file_browser_handlers" in manifest.json) that can be used with the |
| 288 // given files, appending them to the |result_list|. | 288 // given files, appending them to the |result_list|. |
| 289 void FindFileBrowserHandlerTasks( | 289 void FindFileBrowserHandlerTasks( |
| 290 Profile* profile, | 290 Profile* profile, |
| 291 const std::vector<GURL>& file_urls, | 291 const std::vector<GURL>& file_urls, |
| 292 std::vector<FullTaskDescriptor>* result_list); | 292 std::vector<FullTaskDescriptor>* result_list); |
| 293 | 293 |
| 294 // Finds all types (drive, file handlers, file browser handlers) of | 294 // Finds all types (drive, file handlers, file browser handlers) of |
| 295 // tasks. See the comment at FindDriveAppTasks() about |result_list|. | 295 // tasks. See the comment at FindDriveAppTasks() about |result_list|. |
| 296 // Drive app tasks will be found only if all of the files are on Drive. |
| 296 void FindAllTypesOfTasks( | 297 void FindAllTypesOfTasks( |
| 297 Profile* profile, | 298 Profile* profile, |
| 298 const PathAndMimeTypeSet& path_mime_set, | 299 const PathAndMimeTypeSet& path_mime_set, |
| 299 const std::vector<GURL>& file_urls, | 300 const std::vector<GURL>& file_urls, |
| 300 std::vector<FullTaskDescriptor>* result_list); | 301 std::vector<FullTaskDescriptor>* result_list); |
| 301 | 302 |
| 302 // Chooses the default task in |tasks| and sets it as default, if the default | 303 // Chooses the default task in |tasks| and sets it as default, if the default |
| 303 // task is found (i.e. the default task may not exist in |tasks|). No tasks | 304 // task is found (i.e. the default task may not exist in |tasks|). No tasks |
| 304 // should be set as default before calling this function. | 305 // should be set as default before calling this function. |
| 305 void ChooseAndSetDefaultTask(const PrefService& pref_service, | 306 void ChooseAndSetDefaultTask(const PrefService& pref_service, |
| 306 const PathAndMimeTypeSet& path_mime_set, | 307 const PathAndMimeTypeSet& path_mime_set, |
| 307 std::vector<FullTaskDescriptor>* tasks); | 308 std::vector<FullTaskDescriptor>* tasks); |
| 308 | 309 |
| 309 } // namespace file_tasks | 310 } // namespace file_tasks |
| 310 } // namespace file_manager | 311 } // namespace file_manager |
| 311 | 312 |
| 312 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ | 313 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_TASKS_H_ |
| OLD | NEW |