Chromium Code Reviews| Index: ui/file_manager/file_manager/foreground/js/file_manager_commands.js |
| diff --git a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js |
| index 1685b3534450d5cd98716f79e3326d0e0e72a44e..019d81c3c268e955e481b98f92631036efed0cbc 100644 |
| --- a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js |
| +++ b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js |
| @@ -181,9 +181,17 @@ CommandUtil.forceDefaultHandler = function(node, commandId) { |
| * @type {Command} |
| */ |
| CommandUtil.defaultCommand = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
|
fukino
2014/10/31 07:04:21
Could you make these parameter type non-nullable?
hirono
2014/10/31 07:47:29
Done.
|
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.document.execCommand(event.command.id); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| event.canExecute = fileManager.document.queryCommandEnabled( |
| event.command.id); |
| @@ -197,9 +205,17 @@ CommandUtil.defaultCommand = /** @type {Command} */ ({ |
| */ |
| CommandUtil.createVolumeSwitchCommand = function(index) { |
| return /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.directoryTree.selectByIndex(index - 1); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| event.canExecute = index > 0 && |
| index <= fileManager.directoryTree.items.length; |
| @@ -425,9 +441,17 @@ CommandHandler.COMMANDS_['format'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['new-folder'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.createNewFolder(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var directoryModel = fileManager.directoryModel; |
| event.canExecute = !fileManager.isOnReadonlyDirectory() && |
| @@ -442,6 +466,10 @@ CommandHandler.COMMANDS_['new-folder'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['new-window'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.getProfiles( |
| function(profiles, currentId, displayedId) { |
| @@ -452,6 +480,10 @@ CommandHandler.COMMANDS_['new-window'] = /** @type {Command} */ ({ |
| }); |
| }); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| event.canExecute = |
| fileManager.getCurrentDirectoryEntry() && |
| @@ -464,9 +496,17 @@ CommandHandler.COMMANDS_['new-window'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['drive-sync-settings'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.toggleDriveSyncSettings(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| event.canExecute = fileManager.shouldShowDriveSettings(); |
| event.command.setHidden(!event.canExecute); |
| @@ -478,9 +518,17 @@ CommandHandler.COMMANDS_['drive-sync-settings'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['drive-hosted-settings'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.toggleDriveHostedSettings(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| event.canExecute = fileManager.shouldShowDriveSettings(); |
| event.command.setHidden(!event.canExecute); |
| @@ -492,6 +540,10 @@ CommandHandler.COMMANDS_['drive-hosted-settings'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['delete'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| var entries = fileManager.getSelection().entries; |
| var message = entries.length == 1 ? |
| @@ -501,6 +553,10 @@ CommandHandler.COMMANDS_['delete'] = /** @type {Command} */ ({ |
| fileManager.fileOperationManager.deleteEntries(entries); |
| }); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var selection = fileManager.getSelection(); |
| event.canExecute = !fileManager.isOnReadonlyDirectory() && |
| @@ -514,9 +570,17 @@ CommandHandler.COMMANDS_['delete'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['paste'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.document.execCommand(event.command.id); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var fileTransferController = fileManager.fileTransferController; |
| event.canExecute = (fileTransferController && |
| @@ -532,6 +596,10 @@ CommandHandler.COMMANDS_['paste'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['paste-into-folder'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| var selection = fileManager.getSelection(); |
| var dest = CommandUtil.getOnlyOneSelectedDirectory(selection); |
| @@ -547,6 +615,10 @@ CommandHandler.COMMANDS_['paste-into-folder'] = /** @type {Command} */ ({ |
| fileManager.document.execCommand('paste'); |
| fileManager.document.removeEventListener('paste', handler, true); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var fileTransferController = fileManager.fileTransferController; |
| event.canExecute = (fileTransferController && |
| @@ -565,9 +637,17 @@ CommandHandler.COMMANDS_['copy'] = CommandUtil.defaultCommand; |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['rename'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.initiateRename(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var selection = fileManager.getSelection(); |
| event.canExecute = !fileManager.isRenamingInProgress() && |
| @@ -582,12 +662,20 @@ CommandHandler.COMMANDS_['rename'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['volume-help'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| if (fileManager.isOnDrive()) |
| util.visitURL(str('GOOGLE_DRIVE_HELP_URL')); |
| else |
| util.visitURL(str('FILES_APP_HELP_URL')); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| // Hides the help menu in modal dialog mode. It does not make much sense |
| // because after all, users cannot view the help without closing, and |
| @@ -605,6 +693,10 @@ CommandHandler.COMMANDS_['volume-help'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['drive-buy-more-space'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| util.visitURL(str('GOOGLE_DRIVE_BUY_STORAGE_URL')); |
| }, |
| @@ -616,6 +708,10 @@ CommandHandler.COMMANDS_['drive-buy-more-space'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['drive-go-to-drive'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| util.visitURL(str('GOOGLE_DRIVE_ROOT_URL')); |
| }, |
| @@ -627,6 +723,10 @@ CommandHandler.COMMANDS_['drive-go-to-drive'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['open-with'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| var tasks = fileManager.getSelection().tasks; |
| if (tasks) { |
| @@ -638,6 +738,10 @@ CommandHandler.COMMANDS_['open-with'] = /** @type {Command} */ ({ |
| }); |
| } |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var tasks = fileManager.getSelection().tasks; |
| event.canExecute = tasks && tasks.size() > 1; |
| @@ -649,11 +753,19 @@ CommandHandler.COMMANDS_['open-with'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['search'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| var element = fileManager.document.querySelector('#search-box input'); |
| element.focus(); |
| element.select(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| event.canExecute = !fileManager.isRenamingInProgress(); |
| } |
| @@ -748,6 +860,10 @@ CommandHandler.COMMANDS_['toggle-pinned'] = /** @type {Command} */ ({ |
| driveSyncHandler.showDisabledMobileSyncNotification(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var entries = CommandUtil.getPinTargetEntries(); |
| var checked = true; |
| @@ -770,11 +886,22 @@ CommandHandler.COMMANDS_['toggle-pinned'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['zip-selection'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| var dirEntry = fileManager.getCurrentDirectoryEntry(); |
| + if (!dirEntry) |
| + return; |
| var selectionEntries = fileManager.getSelection().entries; |
| - fileManager.fileOperationManager_.zipSelection(dirEntry, selectionEntries); |
| + fileManager.fileOperationManager_.zipSelection( |
| + dirEntry, selectionEntries); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var dirEntry = fileManager.getCurrentDirectoryEntry(); |
| var selection = fileManager.getSelection(); |
| @@ -791,9 +918,17 @@ CommandHandler.COMMANDS_['zip-selection'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['share'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| fileManager.shareSelection(); |
| }, |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| canExecute: function(event, fileManager) { |
| var selection = fileManager.getSelection(); |
| var isDriveOffline = |
| @@ -889,6 +1024,10 @@ CommandHandler.COMMANDS_['remove-folder-shortcut'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['zoom-in'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.zoom('in'); |
| }, |
| @@ -900,6 +1039,10 @@ CommandHandler.COMMANDS_['zoom-in'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['zoom-out'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.zoom('out'); |
| }, |
| @@ -911,6 +1054,10 @@ CommandHandler.COMMANDS_['zoom-out'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['zoom-reset'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.zoom('reset'); |
| }, |
| @@ -922,6 +1069,10 @@ CommandHandler.COMMANDS_['zoom-reset'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['inspect-normal'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.openInspector('normal'); |
| }, |
| @@ -933,6 +1084,10 @@ CommandHandler.COMMANDS_['inspect-normal'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['inspect-console'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.openInspector('console'); |
| }, |
| @@ -944,6 +1099,10 @@ CommandHandler.COMMANDS_['inspect-console'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['inspect-element'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.openInspector('element'); |
| }, |
| @@ -955,6 +1114,10 @@ CommandHandler.COMMANDS_['inspect-element'] = /** @type {Command} */ ({ |
| * @type {Command} |
| */ |
| CommandHandler.COMMANDS_['inspect-background'] = /** @type {Command} */ ({ |
| + /** |
| + * @param {Event} event Command event. |
| + * @param {FileManager} fileManager FileManager to use. |
| + */ |
| execute: function(event, fileManager) { |
| chrome.fileManagerPrivate.openInspector('background'); |
| }, |