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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Describes a task with extra information such as icon URL. | 162 // Describes a task with extra information such as icon URL. |
163 class FullTaskDescriptor { | 163 class FullTaskDescriptor { |
164 public: | 164 public: |
165 FullTaskDescriptor(const TaskDescriptor& task_descriptor, | 165 FullTaskDescriptor(const TaskDescriptor& task_descriptor, |
166 const std::string& task_title, | 166 const std::string& task_title, |
167 const GURL& icon_url, | 167 const GURL& icon_url, |
168 bool is_default); | 168 bool is_default); |
169 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } | 169 const TaskDescriptor& task_descriptor() const { return task_descriptor_; } |
170 | 170 |
171 // The title of the task. | 171 // The title of the task. |
172 const std::string& task_title() { return task_title_; } | 172 const std::string& task_title() const { return task_title_; } |
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: | |
181 // | |
182 // { | |
183 // "iconUrl": "<app_icon_url>", | |
184 // "isDefault": false, | |
185 // "taskId": "<drive_app_id>|drive|open-with", | |
186 // "title": "Drive App Name (ex. Pixlr Editor)" | |
187 // }, | |
188 // | |
189 // "iconUrl" is omitted if icon_url_ is empty. | |
190 // | |
191 // This representation will be used to send task info to the JavaScript. | |
192 scoped_ptr<base::DictionaryValue> AsDictionaryValue() const; | |
193 | |
194 private: | 180 private: |
195 TaskDescriptor task_descriptor_; | 181 TaskDescriptor task_descriptor_; |
196 std::string task_title_; | 182 std::string task_title_; |
197 GURL icon_url_; | 183 GURL icon_url_; |
198 bool is_default_; | 184 bool is_default_; |
199 }; | 185 }; |
200 | 186 |
201 // Update the default file handler for the given sets of suffixes and MIME | 187 // Update the default file handler for the given sets of suffixes and MIME |
202 // types. | 188 // types. |
203 void UpdateDefaultTask(PrefService* pref_service, | 189 void UpdateDefaultTask(PrefService* pref_service, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // task is found (i.e. the default task may not exist in |tasks|). No tasks | 290 // task is found (i.e. the default task may not exist in |tasks|). No tasks |
305 // should be set as default before calling this function. | 291 // should be set as default before calling this function. |
306 void ChooseAndSetDefaultTask(const PrefService& pref_service, | 292 void ChooseAndSetDefaultTask(const PrefService& pref_service, |
307 const PathAndMimeTypeSet& path_mime_set, | 293 const PathAndMimeTypeSet& path_mime_set, |
308 std::vector<FullTaskDescriptor>* tasks); | 294 std::vector<FullTaskDescriptor>* tasks); |
309 | 295 |
310 } // namespace file_tasks | 296 } // namespace file_tasks |
311 } // namespace file_manager | 297 } // namespace file_manager |
312 | 298 |
313 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ | 299 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_ |
OLD | NEW |