Commit 29364f25 authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Replace the mount path for Android files with correct label.

The absolute path for the mount point of Android files is long and not user
friendly. We should replace the path with the "Play files" label, which we use
in Files app UI.

Bug: 863616
Test: Manually tested on ARC-enabled device with multiple languages.
Change-Id: I96548e96489c8480736f8cfc1de53f1c838eb98b
Reviewed-on: https://chromium-review.googlesource.com/1145100Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579324}
parent 51e63525
......@@ -24,7 +24,7 @@
<div class="settings-box first two-line">
<div class="start">
<div>$i18n{downloadLocation}</div>
<div class="secondary">
<div class="secondary" id="defaultDownloadPath">
<if expr="not chromeos">
[[prefs.download.default_directory.value]]
</if>
......
......@@ -112,10 +112,17 @@ Polymer({
getDownloadLocation_: function(path) {
// Replace /special/drive-<hash>/root with "Google Drive" for remote files,
// /home/chronos/user/Downloads or /home/chronos/u-<hash>/Downloads with
// "Downloads" for local paths, and '/' with ' \u203a ' (angled quote sign)
// everywhere. It is used only for display purpose.
// "Downloads" for local paths, /run/arc/sdcard/write/emulated/0 with
// "Play files" for Android files, and '/' with ' \u203a '
// (angled quote sign) everywhere. It is used only for display purpose.
// TODO(fukino): Move the logic of converting these special paths to
// something else to C++ side so that UI side does not depend on these
// hard-coded paths.
path = path.replace(/^\/special\/drive[^\/]*\/root/, 'Google Drive');
path = path.replace(/^\/home\/chronos\/(user|u-[^\/]*)\//, '');
path = path.replace(
/^\/run\/arc\/sdcard\/write\/emulated\/0/,
loadTimeData.getString('downloadsAndroidFilesRootLabel'));
path = path.replace(/\//g, ' \u203a ');
return path;
},
......
......@@ -831,6 +831,8 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_UNSUPPORTED_DEVICE_MESSAGE},
{"smbShareAddedMountExistsMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE},
{"downloadsAndroidFilesRootLabel",
IDS_FILE_BROWSER_ANDROID_FILES_ROOT_LABEL}
#endif
};
AddLocalizedStringsBulk(html_source, localized_strings,
......
......@@ -77,4 +77,39 @@ suite('DownloadsHandler', function() {
assertTrue(!button);
});
});
if (cr.isChromeOS) {
function setDefaultDownloadPathPref(downloadPath) {
downloadsPage.prefs = {
download: {
default_directory: {
key: 'download.default_directory',
type: chrome.settingsPrivate.PrefType.STRING,
value: downloadPath,
}
}
};
}
function getDefaultDownloadPathString() {
const pathElement = downloadsPage.$$('#defaultDownloadPath');
assertTrue(!!pathElement);
return pathElement.textContent.trim();
}
test('rewrite default download paths.', function() {
// Rewrite path for directories in Downloads volume.
setDefaultDownloadPathPref('/home/chronos/u-0123456789abcdef/Downloads');
assertEquals('Downloads', getDefaultDownloadPathString());
// Rewrite path for directories in Google Drive.
setDefaultDownloadPathPref('/special/drive-0123456789abcdef/root/foo');
assertEquals('Google Drive \u203a foo', getDefaultDownloadPathString());
// Rewrite path for directories in Android files volume.
setDefaultDownloadPathPref('/run/arc/sdcard/write/emulated/0/foo/bar');
assertEquals(
'Play files \u203a foo \u203a bar', getDefaultDownloadPathString());
});
}
});
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