Commit a77c573e authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Show consistent volume label with Files app.

When a disk's device label is not available, Files app uses the base
name of the mount path as the volume's label.
Settings screen should use the consistent label with Files app.

Although we should share the implementation in Files and Settings for
the labels, I'd like to keep this CL as simple as possible for safer
merge to M78 branch.
I filed crbug.com/1002535 for the refactoring.

Bug: 1002161
Change-Id: I84a83c42c0645c8e1a105dd010a73d8a9994e0b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795533
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696041}
parent 85c09dce
...@@ -488,9 +488,18 @@ void StorageHandler::UpdateExternalStorages() { ...@@ -488,9 +488,18 @@ void StorageHandler::UpdateExternalStorages() {
if (!disk) if (!disk)
continue; continue;
std::string label = disk->device_label();
if (label.empty()) {
// To make volume labels consistent with Files app, we follow how Files
// generates a volume label when the volume doesn't have specific label.
// That is, we use the base name of mount path instead in such cases.
// TODO(fukino): Share the implementation to compute the volume name with
// Files app. crbug.com/1002535.
label = base::FilePath(mount_info.mount_path).BaseName().AsUTF8Unsafe();
}
base::Value device(base::Value::Type::DICTIONARY); base::Value device(base::Value::Type::DICTIONARY);
device.SetKey("uuid", base::Value(disk->fs_uuid())); device.SetKey("uuid", base::Value(disk->fs_uuid()));
device.SetKey("label", base::Value(disk->device_label())); device.SetKey("label", base::Value(label));
devices.Append(std::move(device)); devices.Append(std::move(device));
} }
FireWebUIListener("onExternalStoragesUpdated", devices); FireWebUIListener("onExternalStoragesUpdated", devices);
......
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