Commit ea7cef28 authored by kinaba@chromium.org's avatar kinaba@chromium.org

Files.app: Disable formatting menu for read only volumes.

The purpose of this change is to disable the menu for write-protected
SD cards that anyhow fails to format.

Strictly speaking this is excessive, because there may be a volume with
read-only file system that still is formattable. We however assume that
the practical need for the case is low (see discussion in the BUG.)

BUG=334108

Review URL: https://codereview.chromium.org/386333002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282907 0039d316-1c4b-4281-b951-d872f2087c98
parent 1c9fe77b
......@@ -417,16 +417,16 @@ CommandHandler.COMMANDS_['format'] = {
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();
// See the comment in execute() for why doing this.
if (!root)
root = directoryModel.getCurrentDirEntry();
var location = root && fileManager.volumeManager.getLocationInfo(root);
var removable = location && location.rootType ===
VolumeManagerCommon.RootType.REMOVABLE;
// Don't check if the volume is read-only. Unformatted volume is considered
// read-only per VolumeInfo.isReadOnly, but can be formatted. An error will
// be raised if formatting failed anyway.
event.canExecute = removable;
event.canExecute = removable && !isReadOnly;
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