Chromium Code Reviews| Index: chrome/browser/chromeos/file_manager/file_tasks.cc |
| diff --git a/chrome/browser/chromeos/file_manager/file_tasks.cc b/chrome/browser/chromeos/file_manager/file_tasks.cc |
| index 9572b954c89f3ec5e8649f55737d89eaeb37bd38..b011665e3c59c23d693c0e5e5d93e8a9192d9181 100644 |
| --- a/chrome/browser/chromeos/file_manager/file_tasks.cc |
| +++ b/chrome/browser/chromeos/file_manager/file_tasks.cc |
| @@ -107,6 +107,48 @@ void KeepOnlyFileManagerInternalTasks(std::vector<FullTaskDescriptor>* tasks) { |
| tasks->swap(filtered); |
| } |
| +// Finds a task that matches |app_id| and |action_id| from |task_list|. |
| +// Returns a mutable iterator to the handler if found. Returns task_list->end() |
| +// if not found. |
| +std::vector<FullTaskDescriptor>::iterator |
| +FindTaskForExtensionIdAndActionId( |
|
hashimoto
2014/03/28 07:57:10
nit: FindTaskForAppIdAndActionId? The argument is
hashimoto
2014/03/28 09:28:59
ping?
yoshiki
2014/03/28 09:31:27
Done.
|
| + std::vector<FullTaskDescriptor>* task_list, |
| + const std::string& app_id, |
| + const std::string& action_id) { |
| + DCHECK(task_list); |
| + |
| + std::vector<FullTaskDescriptor>::iterator iter = task_list->begin(); |
| + while (iter != task_list->end() && |
| + !(iter->task_descriptor().app_id == app_id && |
| + iter->task_descriptor().action_id == action_id)) { |
| + ++iter; |
| + } |
| + return iter; |
| +} |
| + |
| +// Chooses a suitable video handeler and removes other internal video hander. |
| +// Both "watch" and "gallery-video" actions are applicable which means that the |
| +// selection is all videos. Showing them both is confusing, so we only keep |
| +// the one that makes more sense ("watch" for single selection, "gallery" |
| +// for multiple selection). |
| +void ChooseSuitableVideoHandler( |
|
hashimoto
2014/03/28 07:57:10
This new function is not used?
|
| + const std::vector<GURL>& file_urls, |
| + std::vector<FullTaskDescriptor>* task_list) { |
| + std::vector<FullTaskDescriptor>::iterator video_player_iter = |
| + FindTaskForExtensionIdAndActionId(task_list, kVideoPlayerAppId, "video"); |
| + std::vector<FullTaskDescriptor>::iterator gallery_video_iter = |
| + FindTaskForExtensionIdAndActionId( |
| + task_list, kFileManagerAppId, "gallery-video"); |
| + |
| + if (video_player_iter != task_list->end() && |
| + gallery_video_iter != task_list->end()) { |
| + if (file_urls.size() == 1) |
| + task_list->erase(gallery_video_iter); |
| + else |
| + task_list->erase(video_player_iter); |
| + } |
| +} |
| + |
| } // namespace |
| FullTaskDescriptor::FullTaskDescriptor( |
| @@ -467,6 +509,8 @@ void FindAllTypesOfTasks( |
| if (ContainsGoogleDocument(path_mime_set)) |
| KeepOnlyFileManagerInternalTasks(result_list); |
| + RemoveDuplicateVideoHandler(file_urls, result_list); |
| + |
| ChooseAndSetDefaultTask(*profile->GetPrefs(), path_mime_set, result_list); |
| } |