Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Unified Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 10782028: Merge 142938 - [File Manager] Avoiding confusion between "Watch" and "Open" actions for video files (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_manager_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/file_handler_util.cc
===================================================================
--- chrome/browser/chromeos/extensions/file_handler_util.cc (revision 146983)
+++ chrome/browser/chromeos/extensions/file_handler_util.cc (working copy)
@@ -230,6 +230,20 @@
return true;
}
+// Find a specific handler in the handler list.
+LastUsedHandlerList::iterator FindHandler(
+ LastUsedHandlerList* list,
+ const std::string& extension_id,
+ const std::string& id) {
+ LastUsedHandlerList::iterator iter = list->begin();
+ while (iter != list->end() &&
+ !(iter->handler->extension_id() == extension_id &&
+ iter->handler->id() == id)) {
+ iter++;
+ }
+ return iter;
+}
+
// Given the list of selected files, returns array of context menu tasks
// that are shared
bool FindCommonTasks(Profile* profile,
@@ -272,7 +286,7 @@
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 +297,23 @@
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;
}
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_manager_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698