Commit cd72b4ad authored by yamaguchi's avatar yamaguchi Committed by Commit bot

Fix the condition to allow format.

When a drive is right-clicked, the focus of fileManager is not set to the drive unless it has been left-clicked once before that.

test=manual test on device using a write-protected SD card and USB drive
BUG=636373

Review-Url: https://codereview.chromium.org/2253873002
Cr-Commit-Position: refs/heads/master@{#412731}
parent 7a659254
...@@ -504,16 +504,17 @@ CommandHandler.COMMANDS_['format'] = /** @type {Command} */ ({ ...@@ -504,16 +504,17 @@ CommandHandler.COMMANDS_['format'] = /** @type {Command} */ ({
canExecute: function(event, fileManager) { canExecute: function(event, fileManager) {
var directoryModel = fileManager.directoryModel; var directoryModel = fileManager.directoryModel;
var root = CommandUtil.getCommandEntry(event.target); var root = CommandUtil.getCommandEntry(event.target);
// |root| is null for unrecognized volumes. Regard such volumes as writable // |root| is null for unrecognized volumes. Enable format command for such
// so that the format command is enabled. // volumes.
var isReadOnly = root && fileManager.isOnReadonlyDirectory(); var isUnrecognizedVolume = (root == null);
// See the comment in execute() for why doing this. // See the comment in execute() for why doing this.
if (!root) if (!root)
root = directoryModel.getCurrentDirEntry(); root = directoryModel.getCurrentDirEntry();
var location = root && fileManager.volumeManager.getLocationInfo(root); var location = root && fileManager.volumeManager.getLocationInfo(root);
var writable = location && !location.isReadOnly;
var removable = location && location.rootType === var removable = location && location.rootType ===
VolumeManagerCommon.RootType.REMOVABLE; VolumeManagerCommon.RootType.REMOVABLE;
event.canExecute = removable && !isReadOnly; event.canExecute = removable && (isUnrecognizedVolume || writable);
event.command.setHidden(!removable); event.command.setHidden(!removable);
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment