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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10411018: [FileBrowser] Added DefaultAction dialog to choose default action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index d29de39efcc67ea3a7d0086abe2c6a555b9b6a08..5da7fc2dc2f8ef4eb2278b8dea9d6a9c5c7eba3a 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -495,6 +495,8 @@ FileManager.prototype = {
this.alert = new d.AlertDialog(this.dialogDom_);
this.confirm = new d.ConfirmDialog(this.dialogDom_);
this.prompt = new d.PromptDialog(this.dialogDom_);
+ this.defaultTaskPicker =
+ new cr.filebrowser.DefaultActionDialog(this.dialogDom_);
};
/**
@@ -2433,11 +2435,19 @@ FileManager.prototype = {
task.title = str('INSTALL_CRX');
}
}
+
+ var label = task.title;
+ if (defaultTask == null) {
+ defaultTask = task;
+ label = label + ' ' + str('DEFAULT_ACTION_LABEL');
+ }
+
if (tasksList.length > 1)
- this.taskItems_.addItem({label: task.title,
+ this.taskItems_.addItem({label: label,
iconUrl: task.iconUrl, task: task});
+
tasksCount++;
- if (defaultTask == null) defaultTask = task;
+
}
this.taskItems_.hidden = tasksCount == 0;
@@ -2446,6 +2456,12 @@ FileManager.prototype = {
iconUrl: defaultTask.iconUrl, task: defaultTask});
}
+ if (tasksList.length > 1) {
dgozman 2012/05/18 14:50:06 use tasksCount, which is not the same as tasksList
Dmitry Zvorygin 2012/05/22 14:32:59 Done.
+ this.taskItems_.addSeparator();
+ this.taskItems_.addItem(
+ {label: str('CHANGE_DEFAULT_MENU_ITEM'), taskList: tasksList});
+ }
+
selection.tasksList = tasksList;
if (selection.dispatchDefault) {
// We got a request to dispatch the default task for the selection.
@@ -2465,10 +2481,45 @@ FileManager.prototype = {
}
};
+ /**
+ * Task combobox handler.
+ *
+ * @param {Object} event Event containing task which was clicked.
+ */
FileManager.prototype.onTaskItemClicked_ = function(event) {
- this.dispatchFileTask_(event.item.task.taskId, this.selection.urls);
+ if (event.item.task) {
+ this.dispatchFileTask_(event.item.task.taskId, this.selection.urls);
+ } else {
dgozman 2012/05/18 14:50:06 We should have a comment that item without task mu
Dmitry Zvorygin 2012/05/22 14:32:59 Done.
+ var extensions = [];
+
+ for (var i = 0; i < this.selection.urls.length; i++) {
+ var ext = /\.(\w+)$/g.exec(this.selection.urls[i])[1].toUpperCase();
dgozman 2012/05/18 14:50:06 There may be no extension.
Dmitry Zvorygin 2012/05/22 14:32:59 Done.
+ if (extensions.indexOf(ext) == -1) {
+ extensions.push(ext);
+ }
+ }
+
+ // Change default was clicked. We should open "change default" dialog.
+ this.defaultTaskPicker.show(
+ strf('CHANGE_DEFAULT_CAPTION',
dgozman 2012/05/18 14:50:06 We don't want to show all extensions in the captio
Dmitry Zvorygin 2012/05/22 14:32:59 Done.
+ extensions.join(', ')),
dgozman 2012/05/18 14:50:06 indentation
Dmitry Zvorygin 2012/05/22 14:32:59 Done.
+ event.item.taskList, this.onDefaultTaskDone_.bind(this));
+ }
};
+
+ /**
+ * Set's given task as default, when this task is applicable.
+ * @param {Object} task Task to set as default.
+ */
+ FileManager.prototype.onDefaultTaskDone_ = function(task) {
+ chrome.fileBrowserPrivate.setDefaultTask(task.taskId);
+
+ chrome.fileBrowserPrivate.getFileTasks(
+ this.selection.urls,
+ this.onTasksFound_.bind(this, this.selection));
+ }
+
/**
* Dispatches default task for the current selection. If tasks are not ready
* yet, dispatches after task are available.

Powered by Google App Engine
This is Rietveld 408576698