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

Unified Diff: ui/file_manager/file_manager/foreground/js/file_tasks.js

Issue 1872223002: Add verbs API to file handlers. Modify the Chrome OS UI so that it displayes the internationalized … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments mentioned by fukino@. Created 4 years, 8 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
Index: ui/file_manager/file_manager/foreground/js/file_tasks.js
diff --git a/ui/file_manager/file_manager/foreground/js/file_tasks.js b/ui/file_manager/file_manager/foreground/js/file_tasks.js
index 1096215199a1d6691d7d238adef44fd5e7bc1e8b..1cdceb4d7f0105c0f49e04f31e629b3344af0008 100644
--- a/ui/file_manager/file_manager/foreground/js/file_tasks.js
+++ b/ui/file_manager/file_manager/foreground/js/file_tasks.js
@@ -141,19 +141,7 @@ FileTasks.create = function(volumeManager, metadataModel, directoryModel, ui,
});
var defaultTaskPromise = tasksPromise.then(function(tasks) {
- for (var i = 0; i < tasks.length; i++) {
- if (tasks[i].isDefault) {
- return tasks[i];
- }
- }
- // If we haven't picked a default task yet, then just pick the first one
- // which is not generic file handler.
- for (var i = 0; i < tasks.length; i++) {
- if (!tasks[i].isGenericFileHandler) {
- return tasks[i];
- }
- }
- return null;
+ return FileTasks.getDefaultTask(tasks);
});
return Promise.all([tasksPromise, defaultTaskPromise]).then(
@@ -720,7 +708,7 @@ FileTasks.prototype.display = function(combobutton) {
} else {
combobutton.defaultItem = {
type: FileTasks.TaskMenuButtonItemType.ShowMenu,
- label: str('OPEN_WITH_BUTTON_LABEL')
+ label: str('MORE_ACTIONS_BUTTON_LABEL')
};
}
@@ -803,7 +791,7 @@ FileTasks.prototype.createCombobuttonItem_ = function(task, opt_title,
opt_isDefault) {
return {
type: FileTasks.TaskMenuButtonItemType.RunTask,
- label: opt_title || task.title,
+ label: (opt_title || task.title),
iconUrl: task.iconUrl,
iconType: task.iconType,
task: task,
@@ -846,3 +834,31 @@ FileTasks.prototype.showTaskPicker = function(taskDialog, title, message,
onSuccess(item.task);
});
};
+
+/**
+ * Gets the default task from tasks. In case there is no such task (i.e. all
+ * tasks are generic file handlers), then return opt_taskToUseIfNoDefault or
+ * null.
+ *
+ * @param {!Array<!Object>} tasks The list of tasks from where to choose the
+ * default task.
+ * @param {!Object=} opt_taskToUseIfNoDefault The task to return in case there
+ * is no default task available in tasks.
+ * @return {Object} opt_taskToUseIfNoDefault or null in case
+ * opt_taskToUseIfNoDefault is undefined.
+ */
+FileTasks.getDefaultTask = function(tasks, opt_taskToUseIfNoDefault) {
+ for (var i = 0; i < tasks.length; i++) {
+ if (tasks[i].isDefault) {
+ return tasks[i];
+ }
+ }
+ // If we haven't picked a default task yet, then just pick the first one
+ // which is not generic file handler.
+ for (var i = 0; i < tasks.length; i++) {
+ if (!tasks[i].isGenericFileHandler) {
+ return tasks[i];
+ }
+ }
+ return !!opt_taskToUseIfNoDefault ? opt_taskToUseIfNoDefault : null;
+};

Powered by Google App Engine
This is Rietveld 408576698