| 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..db791c51b9d301e4196e15162f48d2376fd4a6f7 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.
|
| + * @param {DirectoryTree} directoryTree Directory tree to extract root node.
|
| * @return {DirectoryEntry} Found root.
|
| */
|
| -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,13 +129,21 @@ 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);
|
| + /**
|
| + * @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 ||
|
| rootType == RootType.REMOVABLE);
|
| @@ -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);
|
| }
|
| };
|
|
|
|
|