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

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: rebase 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..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);
}
};
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | chrome/browser/resources/file_manager/js/main_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698