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

Unified Diff: ui/file_manager/file_manager/foreground/js/task_controller.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/task_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/task_controller.js b/ui/file_manager/file_manager/foreground/js/task_controller.js
index e011fa0a74ab00079949afcb21db928b0c439acc..b6acaaa926ea40859769decc9358baa2c8104511 100644
--- a/ui/file_manager/file_manager/foreground/js/task_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/task_controller.js
@@ -67,7 +67,7 @@ function TaskController(
/**
* @private {boolean}
*/
- this.canExecuteOpenWith_ = false;
+ this.canExecuteMoreActions_ = false;
/**
* @private {!cr.ui.Command}
@@ -80,8 +80,8 @@ function TaskController(
* @private {!cr.ui.Command}
* @const
*/
- this.openWithCommand_ =
- assertInstanceof(document.querySelector('#open-with'), cr.ui.Command);
+ this.moreActionsCommand_ =
+ assertInstanceof(document.querySelector('#more-actions'), cr.ui.Command);
/**
* @private {Promise<!FileTasks>}
@@ -332,8 +332,8 @@ TaskController.prototype.canExecuteDefaultTask = function() {
* Returns whether open with command can be executed or not.
* @return {boolean} True if open with command is executable.
*/
-TaskController.prototype.canExecuteOpenWith = function() {
- return this.canExecuteOpenWith_;
+TaskController.prototype.canExecuteMoreActions = function() {
+ return this.canExecuteMoreActions_;
};
/**
@@ -343,34 +343,37 @@ TaskController.prototype.canExecuteOpenWith = function() {
* @private
*/
TaskController.prototype.updateContextMenuTaskItems_ = function(items) {
- // When only one task is available, show it as default item.
- if (items.length === 1) {
- var taskItem = items[0];
-
- if (taskItem.iconType) {
+ // Always show a default item in case at least one task is available, even
+ // if there is no corresponding default task (i.e. the available task is
+ // a generic handler).
+ if (items.length >= 1) {
+ var defaultTask = FileTasks.getDefaultTask(
+ items, items[0] /* task to use in case of no default */);
+
+ if (defaultTask.iconType) {
this.ui_.fileContextMenu.defaultTaskMenuItem.style.backgroundImage = '';
this.ui_.fileContextMenu.defaultTaskMenuItem.setAttribute(
- 'file-type-icon', taskItem.iconType);
- } else if (taskItem.iconUrl) {
+ 'file-type-icon', defaultTask.iconType);
+ } else if (defaultTask.iconUrl) {
this.ui_.fileContextMenu.defaultTaskMenuItem.style.backgroundImage =
- 'url(' + taskItem.iconUrl + ')';
+ 'url(' + defaultTask.iconUrl + ')';
} else {
this.ui_.fileContextMenu.defaultTaskMenuItem.style.backgroundImage = '';
}
this.ui_.fileContextMenu.defaultTaskMenuItem.label =
- taskItem.taskId === FileTasks.ZIP_UNPACKER_TASK_ID ?
- str('TASK_OPEN') : taskItem.title;
+ defaultTask.taskId === FileTasks.ZIP_UNPACKER_TASK_ID ?
+ str('TASK_OPEN') : defaultTask.title;
this.ui_.fileContextMenu.defaultTaskMenuItem.disabled =
- !!taskItem.disabled;
- this.ui_.fileContextMenu.defaultTaskMenuItem.taskId = taskItem.taskId;
+ !!defaultTask.disabled;
+ this.ui_.fileContextMenu.defaultTaskMenuItem.taskId = defaultTask.taskId;
}
- this.canExecuteDefaultTask_ = items.length === 1;
+ this.canExecuteDefaultTask_ = items.length >= 1;
this.defaultTaskCommand_.canExecuteChange(this.ui_.listContainer.element);
- this.canExecuteOpenWith_ = items.length > 1;
- this.openWithCommand_.canExecuteChange(this.ui_.listContainer.element);
+ this.canExecuteMoreActions_ = items.length > 1;
+ this.moreActionsCommand_.canExecuteChange(this.ui_.listContainer.element);
this.ui_.fileContextMenu.tasksSeparator.hidden = items.length === 0;
};

Powered by Google App Engine
This is Rietveld 408576698