Commit 400f1d0c authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Files app: Make "Play files" root read-only.

Although "Play files" root directory is writable in file system level,
we prohibit write operations on it in the UI level to avoid confusion.
Users can still have write access in sub directories like
Play files/Pictures, /Play files/DCIM, etc...

Bug: 851345
Test: Manually tested on Kevin
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ib5052088aa75a934646081c18c5266fa3fbbac28
Reviewed-on: https://chromium-review.googlesource.com/1140173Reviewed-by: default avatarTatsuhisa Yamaguchi <yamaguchi@chromium.org>
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575628}
parent bfb33ba8
......@@ -371,8 +371,17 @@ VolumeManagerImpl.prototype.getLocationInfo = function(entry) {
// Programming error, throw an exception.
throw new Error('Invalid volume type: ' + volumeInfo.volumeType);
}
isReadOnly = volumeInfo.isReadOnly;
isRootEntry = util.isSameEntry(entry, volumeInfo.fileSystem.root);
// Although "Play files" root directory is writable in file system level,
// we prohibit write operations on it in the UI level to avoid confusion.
// Users can still have write access in sub directories like
// /Play files/Pictures, /Play files/DCIM, etc...
if (volumeInfo.volumeType == VolumeManagerCommon.VolumeType.ANDROID_FILES &&
isRootEntry) {
isReadOnly = true;
} else {
isReadOnly = volumeInfo.isReadOnly;
}
}
return new EntryLocationImpl(volumeInfo, rootType, isRootEntry, isReadOnly);
......
......@@ -6,7 +6,8 @@ var chrome;
loadTimeData.data = {
DRIVE_DIRECTORY_LABEL: 'My Drive',
DOWNLOADS_DIRECTORY_LABEL: 'Downloads'
DOWNLOADS_DIRECTORY_LABEL: 'Downloads',
ANDROID_FILES_ROOT_LABEL: 'Play files'
};
function setUp() {
......@@ -106,12 +107,23 @@ function setUp() {
configurable: false,
watchable: true,
source: VolumeManagerCommon.Source.NETWORK
},
{
volumeId: 'android_files:0',
volumeLabel: '',
volumeType: VolumeManagerCommon.VolumeType.ANDROID_FILES,
isReadOnly: false,
provile: getMockProfile(),
configurable: false,
watchable: true,
source: VolumeManagerCommon.Source.SYSTEM
}
];
chrome.fileManagerPrivate.fileSystemMap_ = {
'download:Downloads': new MockFileSystem('download:Downloads'),
'drive:drive-foobar%40chromium.org-hash':
new MockFileSystem('drive:drive-foobar%40chromium.org-hash')
new MockFileSystem('drive:drive-foobar%40chromium.org-hash'),
'android_files:0': new MockFileSystem('android_files:0')
};
}
......@@ -284,6 +296,20 @@ function testGetLocationInfo(callback) {
assertFalse(teamDriveLocationInfo.hasFixedLabel);
assertFalse(teamDriveLocationInfo.isReadOnly);
assertTrue(teamDriveLocationInfo.isRootEntry);
var androidRoot =
new MockFileEntry(new MockFileSystem('android_files:0'), '/');
var androidRootLocationInfo =
volumeManager.getLocationInfo(androidRoot);
assertTrue(androidRootLocationInfo.isReadOnly);
assertTrue(androidRootLocationInfo.isRootEntry);
var androidSubFolder = new MockFileEntry(
new MockFileSystem('android_files:0'), '/Pictures');
var androidSubFolderLocationInfo =
volumeManager.getLocationInfo(androidSubFolder);
assertFalse(androidSubFolderLocationInfo.isReadOnly);
assertFalse(androidSubFolderLocationInfo.isRootEntry);
}),
callback);
}
......
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