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} */ ({
canExecute: function(event, fileManager) {
var directoryModel = fileManager.directoryModel;
var root = CommandUtil.getCommandEntry(event.target);
// |root| is null for unrecognized volumes. Regard such volumes as writable
// so that the format command is enabled.
var isReadOnly = root && fileManager.isOnReadonlyDirectory();
// |root| is null for unrecognized volumes. Enable format command for such
// volumes.
var isUnrecognizedVolume = (root == null);
// See the comment in execute() for why doing this.
if (!root)
root = directoryModel.getCurrentDirEntry();
var location = root && fileManager.volumeManager.getLocationInfo(root);
var writable = location && !location.isReadOnly;
var removable = location && location.rootType ===
VolumeManagerCommon.RootType.REMOVABLE;
event.canExecute = removable && !isReadOnly;
event.canExecute = removable && (isUnrecognizedVolume || writable);
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