summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-17 11:37:20 +0000
committerkaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-17 11:37:20 +0000
commit84f487e99b2f1de3a3056aef6ff10084b33cb78d (patch)
tree5dc57aa49a9590e301ec1ee0da1d4a4eb525c147 /chrome/browser/chromeos
parentefa33c2de9bd23bea7fc1fe89489df6799749c3f (diff)
downloadchromium_src-84f487e99b2f1de3a3056aef6ff10084b33cb78d.zip
chromium_src-84f487e99b2f1de3a3056aef6ff10084b33cb78d.tar.gz
chromium_src-84f487e99b2f1de3a3056aef6ff10084b33cb78d.tar.bz2
Merge 142938 - [File Manager] Avoiding confusion between "Watch" and "Open" actions for video files
BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10556041 TBR=kaznacheev@chromium.org Review URL: https://chromiumcodereview.appspot.com/10782028 git-svn-id: svn://svn.chromium.org/chrome/branches/1180/src@146984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/extensions/file_handler_util.cc33
-rw-r--r--chrome/browser/chromeos/extensions/file_manager_util.h2
2 files changed, 34 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
index 4bbdaa9..9ad7715 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.cc
+++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
@@ -230,6 +230,20 @@ 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,
+ 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 @@ 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 +297,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;
}
diff --git a/chrome/browser/chromeos/extensions/file_manager_util.h b/chrome/browser/chromeos/extensions/file_manager_util.h
index 40a0c19..658e357 100644
--- a/chrome/browser/chromeos/extensions/file_manager_util.h
+++ b/chrome/browser/chromeos/extensions/file_manager_util.h
@@ -22,6 +22,8 @@ class ListValue;
}
extern const char kFileBrowserDomain[];
+extern const char kFileBrowserGalleryTaskId[];
+extern const char kFileBrowserWatchTaskId[];
// File manager helper methods.
namespace file_manager_util {