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

Pass visible flag of a mounted volume to ARC container.

This CL depends on issue http://crrev.com/c/1763553 to have a
preference prefs::kArcVisibleExternalStorages. (will rebase later)

prefs::kArcVisibleExternalStorages remembers a list of visible
external storage's UUIDs. "Visible" means that the storage is
visible to Android apps. (i.e. Android apps can use the external
storage to read/write files.)

With this CL, Chrome checks visibility of newly mounted storages
by reading the preference, and tell the visibility to ARC container
using extended MountPointInfo.
In addition, when the remembered UUID list changes, all
external mount points will be remounted in ARC container to
make sure the latest visibility is applied.

Bug: 954228
Change-Id: Ief8bd50881462f7e5ae0677883ac119eacf33f63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1765099
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690798}
parent 3faf2a5e
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Next MinVersion: 3
module arc.mojom;
[Extensible]
......@@ -36,6 +38,10 @@ struct MountPointInfo {
// The device type that contains this mount point. If unknown, the event
// should be ignored.
DeviceType device_type;
// Whether the mounted volume should be visible to Android apps.
// This is a user-controlled setting, which is accessible in "External
// storage preferences" screen in device settings.
[MinVersion=2] bool visible;
};
// Next Method ID: 1
......
......@@ -86,6 +86,10 @@ ArcVolumeMounterBridge::ArcVolumeMounterBridge(content::BrowserContext* context,
prefs::kArcHasAccessToRemovableMedia,
base::BindRepeating(&ArcVolumeMounterBridge::OnPrefChanged,
weak_ptr_factory_.GetWeakPtr()));
change_registerar_.Add(
prefs::kArcVisibleExternalStorages,
base::BindRepeating(&ArcVolumeMounterBridge::OnVisibleStoragesChanged,
weak_ptr_factory_.GetWeakPtr()));
}
ArcVolumeMounterBridge::~ArcVolumeMounterBridge() {
......@@ -121,7 +125,7 @@ void ArcVolumeMounterBridge::SendMountEventForMyFiles() {
volume_mounter_instance->OnMountEvent(mojom::MountPointInfo::New(
DiskMountManager::MOUNTING, kMyFilesPath, kMyFilesPath, kMyFilesUuid,
device_label, device_type));
device_label, device_type, false));
}
bool ArcVolumeMounterBridge::HasAccessToRemovableMedia() const {
......@@ -146,6 +150,31 @@ void ArcVolumeMounterBridge::OnPrefChanged() {
}
}
bool ArcVolumeMounterBridge::IsVisibleToAndroidApps(
const std::string& uuid) const {
const base::ListValue* uuid_list =
pref_service_->GetList(prefs::kArcVisibleExternalStorages);
for (auto& value : uuid_list->GetList()) {
if (value.is_string() && value.GetString() == uuid)
return true;
}
return false;
}
void ArcVolumeMounterBridge::OnVisibleStoragesChanged() {
// Remount all external mount points when the list of visible storage changes.
for (const auto& key_value :
DiskMountManager::GetInstance()->mount_points()) {
OnMountEvent(DiskMountManager::MountEvent::UNMOUNTING,
chromeos::MountError::MOUNT_ERROR_NONE, key_value.second);
}
for (const auto& key_value :
DiskMountManager::GetInstance()->mount_points()) {
OnMountEvent(DiskMountManager::MountEvent::MOUNTING,
chromeos::MountError::MOUNT_ERROR_NONE, key_value.second);
}
}
void ArcVolumeMounterBridge::OnConnectionReady() {
// Deferring the SendAllMountEvents as a task to current thread to not
// block the mojo request since SendAllMountEvents might take non trivial
......@@ -213,7 +242,7 @@ void ArcVolumeMounterBridge::OnMountEvent(
volume_mounter_instance->OnMountEvent(mojom::MountPointInfo::New(
event, mount_info.source_path, mount_info.mount_path, fs_uuid,
device_label, device_type));
device_label, device_type, IsVisibleToAndroidApps(fs_uuid)));
}
void ArcVolumeMounterBridge::RequestAllMountPoints() {
......
......@@ -67,6 +67,8 @@ class ArcVolumeMounterBridge
bool HasAccessToRemovableMedia() const;
void OnPrefChanged();
bool IsVisibleToAndroidApps(const std::string& uuid) const;
void OnVisibleStoragesChanged();
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
......
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