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

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

Issue 12857002: Files.app: Add subfolders in the left nav (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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_commands.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager_commands.js b/chrome/browser/resources/file_manager/js/file_manager_commands.js
index e7fa055aa7fd79a6ae1fd30ca422de253c471092..75fd153c0a2933132903af8ea0524d3853f471c1 100644
--- a/chrome/browser/resources/file_manager/js/file_manager_commands.js
+++ b/chrome/browser/resources/file_manager/js/file_manager_commands.js
@@ -8,24 +8,25 @@ var CommandUtil = {};
* Extracts root on which command event was dispatched.
*
* @param {Event} event Command event for which to retrieve root to operate on.
- * @param {cr.ui.List} rootsList Root list to extract root node.
- * @return {DirectoryEntry} Found root.
+ * @param {DirectoryTree} directoryTree Directory tree to extract root node.
+ * @return {?DirectoryEntry} Found root.
mtomasz 2013/03/14 02:52:05 AFAIK objects do not need ? in jsdoc.
yoshiki 2013/03/14 07:57:53 Oops, removed.
*/
-CommandUtil.getCommandRoot = function(event, rootsList) {
- var result = rootsList.dataModel.item(
- rootsList.getIndexOfListItem(event.target)) ||
- rootsList.selectedItem;
+CommandUtil.getCommandRoot = function(event, directoryTree) {
+ var entry = directoryTree.selectedItem;
- return result;
+ if (entry && PathUtil.isRootPath(entry.fullPath))
+ return entry;
+ else
+ return null;
};
/**
* @param {Event} event Command event for which to retrieve root type.
- * @param {cr.ui.List} rootsList Root list to extract root node.
- * @return {string} Found root.
+ * @param {DirectoryTree} directoryTree Directory tree to extract root node.
+ * @return {?string} Found root.
*/
-CommandUtil.getCommandRootType = function(event, rootsList) {
- var root = CommandUtil.getCommandRoot(event, rootsList);
+CommandUtil.getCommandRootType = function(event, directoryTree) {
+ var root = CommandUtil.getCommandRoot(event, directoryTree);
return root && PathUtil.getRootType(root.fullPath);
};
@@ -128,16 +129,24 @@ Commands.defaultCommand = {
* Unmounts external drive.
*/
Commands.unmountCommand = {
- execute: function(event, rootsList, fileManager) {
- var root = CommandUtil.getCommandRoot(event, rootsList);
+ /**
+ * @param {Event} event Command event.
+ * @param {DirectoryTree} directoryTree Target directory tree.
+ */
+ execute: function(event, directoryTree, fileManager) {
+ var root = CommandUtil.getCommandRoot(event, directoryTree);
if (root)
fileManager.unmountVolume(PathUtil.getRootPath(root.fullPath));
},
- canExecute: function(event, rootsList) {
- var rootType = CommandUtil.getCommandRootType(event, rootsList);
-
- event.canExecute = (rootType == RootType.ARCHIVE ||
- rootType == RootType.REMOVABLE);
+ /**
+ * @param {Event} event Command event.
+ * @param {DirectoryTree} directoryTree Target directory tree.
+ */
+ canExecute: function(event, directoryTree) {
+ var rootType = CommandUtil.getCommandRootType(event, directoryTree);
+
+ event.canExecute = (rootType === RootType.ARCHIVE ||
mtomasz 2013/03/14 02:52:05 Is this change necessary? RootType.* values are ne
yoshiki 2013/03/14 07:57:53 Done.
+ rootType === RootType.REMOVABLE);
event.command.label = rootType == RootType.ARCHIVE ?
str('CLOSE_ARCHIVE_BUTTON_LABEL') :
str('UNMOUNT_DEVICE_BUTTON_LABEL');
@@ -148,8 +157,12 @@ Commands.unmountCommand = {
* Formats external drive.
*/
Commands.formatCommand = {
- execute: function(event, rootsList, fileManager) {
- var root = CommandUtil.getCommandRoot(event, rootsList);
+ /**
+ * @param {Event} event Command event.
+ * @param {DirectoryTree} directoryTree Target directory tree.
+ */
+ execute: function(event, directoryTree, fileManager) {
+ var root = CommandUtil.getCommandRoot(event, directoryTree);
if (root) {
var url = util.makeFilesystemUrl(PathUtil.getRootPath(root.fullPath));
@@ -158,8 +171,12 @@ Commands.formatCommand = {
chrome.fileBrowserPrivate.formatDevice.bind(null, url));
}
},
- canExecute: function(event, rootsList, fileManager, directoryModel) {
- var root = CommandUtil.getCommandRoot(event, rootsList);
+ /**
+ * @param {Event} event Command event.
+ * @param {DirectoryTree} directoryTree Target directory tree.
+ */
+ canExecute: function(event, directoryTree, fileManager, directoryModel) {
+ var root = CommandUtil.getCommandRoot(event, directoryTree);
var removable = root &&
PathUtil.getRootType(root.fullPath) == RootType.REMOVABLE;
var isReadOnly = root && directoryModel.isPathReadOnly(root.fullPath);
@@ -172,8 +189,12 @@ Commands.formatCommand = {
* Imports photos from external drive
*/
Commands.importCommand = {
- execute: function(event, rootsList) {
- var root = CommandUtil.getCommandRoot(event, rootsList);
+ /**
+ * @param {Event} event Command event.
+ * @param {DirectoryTree} directoryTree Target directory tree.
+ */
+ execute: function(event, directoryTree) {
+ var root = CommandUtil.getCommandRoot(event, directoryTree);
if (!root)
return;
@@ -184,9 +205,13 @@ Commands.importCommand = {
type: 'popup' });
}.bind(this));
},
- canExecute: function(event, rootsList) {
- event.canExecute =
- (CommandUtil.getCommandRootType(event, rootsList) != RootType.DRIVE);
+ /**
+ * @param {Event} event Command event.
+ * @param {DirectoryTree} directoryTree Target directory tree.
+ */
+ canExecute: function(event, directoryTree) {
+ var rootType = CommandUtil.getCommandRootType(event, directoryTree);
+ event.canExecute = (rootType != RootType.DRIVE);
}
};

Powered by Google App Engine
This is Rietveld 408576698