Chromium Code Reviews| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 std::string app_id; | 161 std::string app_id; |
| 162 TaskType task_type; | 162 TaskType task_type; |
| 163 std::string action_id; | 163 std::string action_id; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 // Describes a task with extra information such as icon URL. | 166 // Describes a task with extra information such as icon URL. |
| 167 class FullTaskDescriptor { | 167 class FullTaskDescriptor { |
| 168 public: | 168 public: |
| 169 FullTaskDescriptor(const TaskDescriptor& task_descriptor, | 169 FullTaskDescriptor(const TaskDescriptor& task_descriptor, |
| 170 const std::string& task_title, | 170 const std::string& task_title, |
| 171 const std::string& task_verb, | |
| 171 const GURL& icon_url, | 172 const GURL& icon_url, |
| 172 bool is_default, | 173 bool is_default, |
| 173 bool is_generic_file_handler); | 174 bool is_generic_file_handler); |
| 175 | |
| 176 ~FullTaskDescriptor(); | |
|
fukino
2016/04/18 08:06:05
not necessary
cmihail
2016/04/21 09:36:43
Actually necessary due to the extra task_verb fiel
| |
| 177 | |
| 174 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } | 178 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } |
| 175 | 179 |
| 176 // The title of the task. | 180 // The title of the task. |
| 177 const std::string& task_title() const { return task_title_; } | 181 const std::string& task_title() const { return task_title_; } |
| 182 // The verb of the task. | |
| 183 const std::string& task_verb() const { return task_verb_; } | |
| 178 // The icon URL for the task (ex. app icon) | 184 // The icon URL for the task (ex. app icon) |
| 179 const GURL& icon_url() const { return icon_url_; } | 185 const GURL& icon_url() const { return icon_url_; } |
| 180 | 186 |
| 181 // True if this task is set as default. | 187 // True if this task is set as default. |
| 182 bool is_default() const { return is_default_; } | 188 bool is_default() const { return is_default_; } |
| 183 void set_is_default(bool is_default) { is_default_ = is_default; } | 189 void set_is_default(bool is_default) { is_default_ = is_default; } |
| 184 | 190 |
| 185 // True if this task is from generic file handler. Generic file handler is a | 191 // True if this task is from generic file handler. Generic file handler is a |
| 186 // file handler which handles any type of files (e.g. extensions: ["*"], | 192 // file handler which handles any type of files (e.g. extensions: ["*"], |
| 187 // types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not | 193 // types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not |
| 188 // generic file handler. | 194 // generic file handler. |
| 189 bool is_generic_file_handler() const { return is_generic_file_handler_; } | 195 bool is_generic_file_handler() const { return is_generic_file_handler_; } |
| 190 void set_is_generic_file_handler(bool is_generic_file_handler) { | 196 void set_is_generic_file_handler(bool is_generic_file_handler) { |
| 191 is_generic_file_handler_ = is_generic_file_handler; | 197 is_generic_file_handler_ = is_generic_file_handler; |
| 192 } | 198 } |
| 193 | 199 |
| 194 private: | 200 private: |
| 195 TaskDescriptor task_descriptor_; | 201 TaskDescriptor task_descriptor_; |
| 196 std::string task_title_; | 202 std::string task_title_; |
| 203 std::string task_verb_; | |
| 197 GURL icon_url_; | 204 GURL icon_url_; |
| 198 bool is_default_; | 205 bool is_default_; |
| 199 bool is_generic_file_handler_; | 206 bool is_generic_file_handler_; |
| 200 }; | 207 }; |
| 201 | 208 |
| 202 // Update the default file handler for the given sets of suffixes and MIME | 209 // Update the default file handler for the given sets of suffixes and MIME |
| 203 // types. | 210 // types. |
| 204 void UpdateDefaultTask(PrefService* pref_service, | 211 void UpdateDefaultTask(PrefService* pref_service, |
| 205 const std::string& task_id, | 212 const std::string& task_id, |
| 206 const std::set<std::string>& suffixes, | 213 const std::set<std::string>& suffixes, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 // task is found (i.e. the default task may not exist in |tasks|). No tasks | 313 // task is found (i.e. the default task may not exist in |tasks|). No tasks |
| 307 // should be set as default before calling this function. | 314 // should be set as default before calling this function. |
| 308 void ChooseAndSetDefaultTask(const PrefService& pref_service, | 315 void ChooseAndSetDefaultTask(const PrefService& pref_service, |
| 309 const std::vector<extensions::EntryInfo>& entries, | 316 const std::vector<extensions::EntryInfo>& entries, |
| 310 std::vector<FullTaskDescriptor>* tasks); | 317 std::vector<FullTaskDescriptor>* tasks); |
| 311 | 318 |
| 312 } // namespace file_tasks | 319 } // namespace file_tasks |
| 313 } // namespace file_manager | 320 } // namespace file_manager |
| 314 | 321 |
| 315 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 322 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
| OLD | NEW |