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 b980caf302897eb35822ba1d4b16ccf90e71456a..0459c577228c3802578cc35287bf8a29baa13abd 100644 |
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc |
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc |
@@ -20,6 +20,7 @@ |
#include "chrome/browser/chromeos/file_manager/path_util.h" |
#include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" |
#include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
+#include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" |
#include "chrome/browser/chromeos/profiles/profile_helper.h" |
#include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" |
#include "chrome/browser/profiles/profile.h" |
@@ -103,6 +104,8 @@ std::string VolumeTypeToString(VolumeType type) { |
return "cloud_device"; |
case VOLUME_TYPE_TESTING: |
return "testing"; |
+ case VOLUME_TYPE_PROVIDED: |
+ return "provided"; |
} |
NOTREACHED(); |
return ""; |
@@ -199,6 +202,18 @@ VolumeInfo CreatePrivetVolumeInfo( |
return volume_info; |
} |
+VolumeInfo CreateProvidedFileSystemVolumeInfo( |
+ const chromeos::file_system_provider::ProvidedFileSystem& file_system) { |
+ VolumeInfo volume_info; |
+ volume_info.type = VOLUME_TYPE_PROVIDED; |
+ volume_info.mount_path = file_system.mount_path(); |
+ volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; |
+ volume_info.is_parent = true; |
+ volume_info.is_read_only = true; |
+ volume_info.volume_id = GenerateVolumeId(volume_info); |
+ return volume_info; |
+} |
+ |
} // namespace |
VolumeInfo::VolumeInfo() { |
@@ -211,12 +226,14 @@ VolumeManager::VolumeManager( |
Profile* profile, |
drive::DriveIntegrationService* drive_integration_service, |
chromeos::PowerManagerClient* power_manager_client, |
- chromeos::disks::DiskMountManager* disk_mount_manager) |
+ chromeos::disks::DiskMountManager* disk_mount_manager, |
+ chromeos::file_system_provider::Service* file_system_provider_service) |
: profile_(profile), |
drive_integration_service_(drive_integration_service), |
disk_mount_manager_(disk_mount_manager), |
mounted_disk_monitor_( |
- new MountedDiskMonitor(power_manager_client, disk_mount_manager)) { |
+ new MountedDiskMonitor(power_manager_client, disk_mount_manager)), |
+ file_system_provider_service_(file_system_provider_service) { |
DCHECK(disk_mount_manager); |
} |
@@ -272,6 +289,21 @@ void VolumeManager::Initialize() { |
// Subscribe to DiskMountManager. |
disk_mount_manager_->AddObserver(this); |
+ // Subscribe to FileSystemProviderService and register currently mounted |
+ // volumes for the profile. |
+ if (file_system_provider_service_) { |
+ using chromeos::file_system_provider::ProvidedFileSystem; |
+ file_system_provider_service_->AddObserver(this); |
+ |
+ std::vector<ProvidedFileSystem> provided_file_systems = |
+ file_system_provider_service_->GetRegisteredFileSystems(); |
+ for (size_t i = 0; i < provided_file_systems.size(); ++i) { |
+ VolumeInfo volume_info = |
+ CreateProvidedFileSystemVolumeInfo(provided_file_systems[i]); |
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, kNotRemounting); |
+ } |
+ } |
+ |
std::vector<VolumeInfo> archives; |
const chromeos::disks::DiskMountManager::MountPointMap& mount_points = |
@@ -342,6 +374,9 @@ void VolumeManager::Shutdown() { |
if (drive_integration_service_) |
drive_integration_service_->RemoveObserver(this); |
+ |
+ if (file_system_provider_service_) |
+ file_system_provider_service_->RemoveObserver(this); |
} |
void VolumeManager::AddObserver(VolumeManagerObserver* observer) { |
@@ -584,6 +619,18 @@ void VolumeManager::OnFormatEvent( |
NOTREACHED(); |
} |
+void VolumeManager::OnProvidedFileSystemRegistered( |
+ const chromeos::file_system_provider::ProvidedFileSystem& file_system) { |
+ VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); |
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info, false /* remounting */); |
+} |
+ |
+void VolumeManager::OnProvidedFileSystemUnregistered( |
+ const chromeos::file_system_provider::ProvidedFileSystem& file_system) { |
+ VolumeInfo volume_info = CreateProvidedFileSystemVolumeInfo(file_system); |
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, volume_info); |
+} |
+ |
void VolumeManager::OnExternalStorageDisabledChanged() { |
// If the policy just got disabled we have to unmount every device currently |
// mounted. The opposite is fine - we can let the user re-plug her device to |