| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 std::string app_id; | 164 std::string app_id; |
| 165 TaskType task_type; | 165 TaskType task_type; |
| 166 std::string action_id; | 166 std::string action_id; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 // Describes a task with extra information such as icon URL. | 169 // Describes a task with extra information such as icon URL. |
| 170 class FullTaskDescriptor { | 170 class FullTaskDescriptor { |
| 171 public: | 171 public: |
| 172 FullTaskDescriptor(const TaskDescriptor& task_descriptor, | 172 FullTaskDescriptor(const TaskDescriptor& task_descriptor, |
| 173 const std::string& task_title, | 173 const std::string& task_title, |
| 174 const std::string& task_verb, |
| 174 const GURL& icon_url, | 175 const GURL& icon_url, |
| 175 bool is_default, | 176 bool is_default, |
| 176 bool is_generic_file_handler); | 177 bool is_generic_file_handler); |
| 178 |
| 179 ~FullTaskDescriptor(); |
| 180 |
| 177 FullTaskDescriptor(const FullTaskDescriptor& other); | 181 FullTaskDescriptor(const FullTaskDescriptor& other); |
| 178 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } | 182 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } |
| 179 | 183 |
| 180 // The title of the task. | 184 // The title of the task. |
| 181 const std::string& task_title() const { return task_title_; } | 185 const std::string& task_title() const { return task_title_; } |
| 186 // The verb of the task. |
| 187 const std::string& task_verb() const { return task_verb_; } |
| 182 // The icon URL for the task (ex. app icon) | 188 // The icon URL for the task (ex. app icon) |
| 183 const GURL& icon_url() const { return icon_url_; } | 189 const GURL& icon_url() const { return icon_url_; } |
| 184 | 190 |
| 185 // True if this task is set as default. | 191 // True if this task is set as default. |
| 186 bool is_default() const { return is_default_; } | 192 bool is_default() const { return is_default_; } |
| 187 void set_is_default(bool is_default) { is_default_ = is_default; } | 193 void set_is_default(bool is_default) { is_default_ = is_default; } |
| 188 | 194 |
| 189 // True if this task is from generic file handler. Generic file handler is a | 195 // True if this task is from generic file handler. Generic file handler is a |
| 190 // file handler which handles any type of files (e.g. extensions: ["*"], | 196 // file handler which handles any type of files (e.g. extensions: ["*"], |
| 191 // types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not | 197 // types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not |
| 192 // generic file handler. | 198 // generic file handler. |
| 193 bool is_generic_file_handler() const { return is_generic_file_handler_; } | 199 bool is_generic_file_handler() const { return is_generic_file_handler_; } |
| 194 void set_is_generic_file_handler(bool is_generic_file_handler) { | 200 void set_is_generic_file_handler(bool is_generic_file_handler) { |
| 195 is_generic_file_handler_ = is_generic_file_handler; | 201 is_generic_file_handler_ = is_generic_file_handler; |
| 196 } | 202 } |
| 197 | 203 |
| 198 private: | 204 private: |
| 199 TaskDescriptor task_descriptor_; | 205 TaskDescriptor task_descriptor_; |
| 200 std::string task_title_; | 206 std::string task_title_; |
| 207 std::string task_verb_; |
| 201 GURL icon_url_; | 208 GURL icon_url_; |
| 202 bool is_default_; | 209 bool is_default_; |
| 203 bool is_generic_file_handler_; | 210 bool is_generic_file_handler_; |
| 204 }; | 211 }; |
| 205 | 212 |
| 206 // Update the default file handler for the given sets of suffixes and MIME | 213 // Update the default file handler for the given sets of suffixes and MIME |
| 207 // types. | 214 // types. |
| 208 void UpdateDefaultTask(PrefService* pref_service, | 215 void UpdateDefaultTask(PrefService* pref_service, |
| 209 const std::string& task_id, | 216 const std::string& task_id, |
| 210 const std::set<std::string>& suffixes, | 217 const std::set<std::string>& suffixes, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // task is found (i.e. the default task may not exist in |tasks|). No tasks | 322 // task is found (i.e. the default task may not exist in |tasks|). No tasks |
| 316 // should be set as default before calling this function. | 323 // should be set as default before calling this function. |
| 317 void ChooseAndSetDefaultTask(const PrefService& pref_service, | 324 void ChooseAndSetDefaultTask(const PrefService& pref_service, |
| 318 const std::vector<extensions::EntryInfo>& entries, | 325 const std::vector<extensions::EntryInfo>& entries, |
| 319 std::vector<FullTaskDescriptor>* tasks); | 326 std::vector<FullTaskDescriptor>* tasks); |
| 320 | 327 |
| 321 } // namespace file_tasks | 328 } // namespace file_tasks |
| 322 } // namespace file_manager | 329 } // namespace file_manager |
| 323 | 330 |
| 324 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 331 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
| OLD | NEW |