Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/file_handler_util.cc |
| diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc |
| index 4bbdaa9a43c79b75b2e7efa73ffab01de452847d..a8cf37ee6ec3aa514ae8be5d91cca3dc8272238a 100644 |
| --- a/chrome/browser/chromeos/extensions/file_handler_util.cc |
| +++ b/chrome/browser/chromeos/extensions/file_handler_util.cc |
| @@ -230,6 +230,19 @@ bool CrackTaskID(const std::string& task_id, |
| return true; |
| } |
| +// Find a specific handler in the handler list. |
| +LastUsedHandlerList::iterator FindHandler( |
| + LastUsedHandlerList* list, |
| + const std::string & extension_id, |
|
dgozman
2012/06/18 15:21:14
no space before &
Vladislav Kaznacheev
2012/06/18 17:05:54
Done.
|
| + const std::string & id) { |
| + LastUsedHandlerList::iterator iter = list->begin(); |
| + while (iter != list->end() && |
| + !(iter->handler->extension_id() == extension_id && |
|
dgozman
2012/06/18 15:21:14
I'd indent this with 3 more spaces.
Vladislav Kaznacheev
2012/06/18 17:05:54
Done.
|
| + iter->handler->id() == id)) |
| + iter++; |
|
dgozman
2012/06/18 15:21:14
AFAIK, while body must be a block.
Vladislav Kaznacheev
2012/06/18 17:05:54
Done.
|
| + return iter; |
| +} |
| + |
| // Given the list of selected files, returns array of context menu tasks |
| // that are shared |
| bool FindCommonTasks(Profile* profile, |
| @@ -272,7 +285,7 @@ bool FindCommonTasks(Profile* profile, |
| int last_used_timestamp = 0; |
| if ((*iter)->extension_id() == kFileBrowserDomain) { |
| - // Give a little bump to the action from File Browser extenion |
| + // Give a little bump to the action from File Browser extension |
| // to make sure it is the default on a fresh profile. |
| last_used_timestamp = 1; |
| } |
| @@ -283,6 +296,23 @@ bool FindCommonTasks(Profile* profile, |
| matching_patterns)); |
| } |
| + LastUsedHandlerList::iterator watch_iter = FindHandler( |
| + named_action_list, kFileBrowserDomain, kFileBrowserWatchTaskId); |
| + LastUsedHandlerList::iterator gallery_iter = FindHandler( |
| + named_action_list, kFileBrowserDomain, kFileBrowserGalleryTaskId); |
| + if (watch_iter != named_action_list->end() && |
| + gallery_iter != named_action_list->end()) { |
| + // Both "watch" and "gallery" actions are applicable which means that |
| + // the selection is all videos. Showing them both is confusing. We only keep |
| + // the one that makes more sense ("watch" for single selection, "gallery" |
| + // for multiple selection). |
| + |
| + if (files_list.size() == 1) |
| + named_action_list->erase(gallery_iter); |
| + else |
| + named_action_list->erase(watch_iter); |
| + } |
| + |
| SortLastUsedHandlerList(named_action_list); |
| return true; |
| } |