Index: chrome/browser/chromeos/file_manager/volume_manager.cc |
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc |
index 5102eb8d7c59ed158962aae5b855e9f0385436ec..3b1b701938bbc5dcd7b34e0bfaa64c990674e3bb 100644 |
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc |
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc |
@@ -251,12 +251,19 @@ void VolumeManager::Initialize() { |
// Subscribe to DiskMountManager. |
disk_mount_manager_->AddObserver(this); |
+ std::vector<chromeos::disks::DiskMountManager::MountPointInfo> archives; |
+ |
const chromeos::disks::DiskMountManager::MountPointMap& mount_points = |
disk_mount_manager_->mount_points(); |
for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it = |
mount_points.begin(); |
it != mount_points.end(); |
++it) { |
+ if (it->second.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
+ // Archives are mounted after other type of volumes. See below. |
+ archives.push_back(it->second); |
+ continue; |
+ } |
DoMountEvent( |
chromeos::MOUNT_ERROR_NONE, |
CreateVolumeInfoFromMountPointInfo( |
@@ -265,6 +272,34 @@ void VolumeManager::Initialize() { |
false /* is_remounting */); |
} |
+ // We mount archives only if they are opened from currently mounted volumes. |
+ // To check the condition correctly in DoMountEvent, we care the order. |
+ std::vector<bool> done(archives.size(), false); |
+ for (size_t i = 0; i < archives.size(); ++i) { |
+ if (!done[i]) { |
+ std::vector<chromeos::disks::DiskMountManager::MountPointInfo> chain; |
+ done[i] = true; |
+ chain.push_back(archives[i]); |
+ |
+ // If archives[i]'s source_path is in another archive, mount it first. |
+ for (size_t parent = 0; parent < archives.size(); ++parent) { |
+ if (!done[parent] && |
+ chain.back().source_path.find(archives[parent].mount_path) == 0) { |
mtomasz
2014/02/14 05:08:47
Does the mount_path contain a trailing slash? If n
kinaba
2014/02/14 05:20:19
Thanks. Very good point. Fixed.
|
+ done[parent] = true; |
+ chain.push_back(archives[parent]); |
+ parent = 0; // Search archives[parent]'s parent from the beginning. |
+ } |
+ } |
+ |
+ // Mount from the tail of chain. |
+ for (size_t i = chain.size(); i > 0; --i) { |
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
+ CreateVolumeInfoFromMountPointInfo(chain[i - 1], NULL), |
+ false); |
+ } |
+ } |
+ } |
+ |
disk_mount_manager_->RequestMountInfoRefresh(); |
// Subscribe to Profile Preference change. |
@@ -556,7 +591,24 @@ void VolumeManager::OnPrivetVolumesAvailable( |
void VolumeManager::DoMountEvent(chromeos::MountError error_code, |
const VolumeInfo& volume_info, |
bool is_remounting) { |
- // TODO(kinaba): filter zip. |
+ // Archive files are mounted globally in system. We however don't want to show |
+ // archives from profile-specific folders (Drive/Downloads) of other users in |
+ // multi-profile session. To this end, we filter out archives not on the |
+ // volumes already mounted on this VolumeManager instance. |
+ if (volume_info.type == VOLUME_TYPE_MOUNTED_ARCHIVE_FILE) { |
+ // Source may be in Drive cache folder under the current profile directory. |
+ bool from_current_profile = |
+ profile_->GetPath().IsParent(volume_info.source_path); |
+ for (std::map<std::string, VolumeInfo>::const_iterator iter = |
+ mounted_volumes_.begin(); |
+ !from_current_profile && iter != mounted_volumes_.end(); |
+ ++iter) { |
+ if (iter->second.mount_path.IsParent(volume_info.source_path)) |
+ from_current_profile = true; |
+ } |
+ if (!from_current_profile) |
+ return; |
+ } |
if (error_code == chromeos::MOUNT_ERROR_NONE || volume_info.mount_condition) |
mounted_volumes_[volume_info.volume_id] = volume_info; |