| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
| 12 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 12 #include "chromeos/disks/disk_mount_manager.h" | 13 #include "chromeos/disks/disk_mount_manager.h" |
| 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 14 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 14 | 15 |
| 15 class Profile; | 16 class Profile; |
| 16 | 17 |
| 17 namespace chromeos { | 18 namespace chromeos { |
| 18 class PowerManagerClient; | 19 class PowerManagerClient; |
| 19 } // namespace chromeos | 20 } // namespace chromeos |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 class BrowserContext; | 23 class BrowserContext; |
| 23 } // namespace content | 24 } // namespace content |
| 24 | 25 |
| 26 namespace drive { |
| 27 class DriveIntegrationService; |
| 28 } // namespace drive |
| 29 |
| 25 namespace file_manager { | 30 namespace file_manager { |
| 26 | 31 |
| 27 class MountedDiskMonitor; | 32 class MountedDiskMonitor; |
| 28 class VolumeManagerObserver; | 33 class VolumeManagerObserver; |
| 29 | 34 |
| 30 // This manager manages "Drive" and "Downloads" in addition to disks managed | 35 // This manager manages "Drive" and "Downloads" in addition to disks managed |
| 31 // by DiskMountManager. | 36 // by DiskMountManager. |
| 32 enum VolumeType { | 37 enum VolumeType { |
| 33 VOLUME_TYPE_GOOGLE_DRIVE, | 38 VOLUME_TYPE_GOOGLE_DRIVE, |
| 34 VOLUME_TYPE_DOWNLOADS_DIRECTORY, | 39 VOLUME_TYPE_DOWNLOADS_DIRECTORY, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 base::FilePath system_path_prefix; | 68 base::FilePath system_path_prefix; |
| 64 | 69 |
| 65 // If disk is a parent, then its label, else parents label. | 70 // If disk is a parent, then its label, else parents label. |
| 66 // (e.g. "TransMemory") | 71 // (e.g. "TransMemory") |
| 67 std::string drive_label; | 72 std::string drive_label; |
| 68 | 73 |
| 69 // Is the device is a parent device (i.e. sdb rather than sdb1). | 74 // Is the device is a parent device (i.e. sdb rather than sdb1). |
| 70 bool is_parent; | 75 bool is_parent; |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 // Returns the VolumeInfo for Drive file system. | |
| 74 // This is temporarily exposed for EventRouter's FileSystem mounting event | |
| 75 // handling. | |
| 76 // TODO(hidehiko): Hide this when the observing code is moved to VolumeManager. | |
| 77 VolumeInfo CreateDriveVolumeInfo(); | |
| 78 | |
| 79 // Manages "Volume"s for file manager. Here are "Volume"s. | 78 // Manages "Volume"s for file manager. Here are "Volume"s. |
| 80 // - Drive File System (not yet supported). | 79 // - Drive File System (not yet supported). |
| 81 // - Downloads directory. | 80 // - Downloads directory. |
| 82 // - Removable disks (volume will be created for each partition, not only one | 81 // - Removable disks (volume will be created for each partition, not only one |
| 83 // for a device). | 82 // for a device). |
| 84 // - Mounted zip archives. | 83 // - Mounted zip archives. |
| 85 class VolumeManager : public BrowserContextKeyedService, | 84 class VolumeManager : public BrowserContextKeyedService, |
| 85 public drive::DriveIntegrationServiceObserver, |
| 86 public chromeos::disks::DiskMountManager::Observer { | 86 public chromeos::disks::DiskMountManager::Observer { |
| 87 public: | 87 public: |
| 88 VolumeManager(Profile* profile, | 88 VolumeManager(Profile* profile, |
| 89 drive::DriveIntegrationService* drive_integration_service, |
| 89 chromeos::PowerManagerClient* power_manager_client, | 90 chromeos::PowerManagerClient* power_manager_client, |
| 90 chromeos::disks::DiskMountManager* disk_mount_manager); | 91 chromeos::disks::DiskMountManager* disk_mount_manager); |
| 91 virtual ~VolumeManager(); | 92 virtual ~VolumeManager(); |
| 92 | 93 |
| 93 // Returns the instance corresponding to the |context|. | 94 // Returns the instance corresponding to the |context|. |
| 94 static VolumeManager* Get(content::BrowserContext* context); | 95 static VolumeManager* Get(content::BrowserContext* context); |
| 95 | 96 |
| 96 // Intializes this instance. | 97 // Intializes this instance. |
| 97 void Initialize(); | 98 void Initialize(); |
| 98 | 99 |
| 99 // Disposes this instance. | 100 // Disposes this instance. |
| 100 virtual void Shutdown() OVERRIDE; | 101 virtual void Shutdown() OVERRIDE; |
| 101 | 102 |
| 102 // Adds an observer. | 103 // Adds an observer. |
| 103 void AddObserver(VolumeManagerObserver* observer); | 104 void AddObserver(VolumeManagerObserver* observer); |
| 104 | 105 |
| 105 // Removes the observer. | 106 // Removes the observer. |
| 106 void RemoveObserver(VolumeManagerObserver* observer); | 107 void RemoveObserver(VolumeManagerObserver* observer); |
| 107 | 108 |
| 108 // Returns the information about all volumes currently mounted. | 109 // Returns the information about all volumes currently mounted. |
| 109 // TODO(hidehiko): make this just an accessor. | |
| 110 std::vector<VolumeInfo> GetVolumeInfoList() const; | 110 std::vector<VolumeInfo> GetVolumeInfoList() const; |
| 111 | 111 |
| 112 // drive::DriveIntegrationServiceObserver overrides. |
| 113 virtual void OnFileSystemMounted() OVERRIDE; |
| 114 virtual void OnFileSystemBeingUnmounted() OVERRIDE; |
| 115 |
| 112 // chromeos::disks::DiskMountManager::Observer overrides. | 116 // chromeos::disks::DiskMountManager::Observer overrides. |
| 113 virtual void OnDiskEvent( | 117 virtual void OnDiskEvent( |
| 114 chromeos::disks::DiskMountManager::DiskEvent event, | 118 chromeos::disks::DiskMountManager::DiskEvent event, |
| 115 const chromeos::disks::DiskMountManager::Disk* disk) OVERRIDE; | 119 const chromeos::disks::DiskMountManager::Disk* disk) OVERRIDE; |
| 116 virtual void OnDeviceEvent( | 120 virtual void OnDeviceEvent( |
| 117 chromeos::disks::DiskMountManager::DeviceEvent event, | 121 chromeos::disks::DiskMountManager::DeviceEvent event, |
| 118 const std::string& device_path) OVERRIDE; | 122 const std::string& device_path) OVERRIDE; |
| 119 virtual void OnMountEvent( | 123 virtual void OnMountEvent( |
| 120 chromeos::disks::DiskMountManager::MountEvent event, | 124 chromeos::disks::DiskMountManager::MountEvent event, |
| 121 chromeos::MountError error_code, | 125 chromeos::MountError error_code, |
| 122 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) | 126 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) |
| 123 OVERRIDE; | 127 OVERRIDE; |
| 124 virtual void OnFormatEvent( | 128 virtual void OnFormatEvent( |
| 125 chromeos::disks::DiskMountManager::FormatEvent event, | 129 chromeos::disks::DiskMountManager::FormatEvent event, |
| 126 chromeos::FormatError error_code, | 130 chromeos::FormatError error_code, |
| 127 const std::string& device_path) OVERRIDE; | 131 const std::string& device_path) OVERRIDE; |
| 128 | 132 |
| 129 // Called on change to kExternalStorageDisabled pref. | 133 // Called on change to kExternalStorageDisabled pref. |
| 130 void OnExternalStorageDisabledChanged(); | 134 void OnExternalStorageDisabledChanged(); |
| 131 | 135 |
| 132 private: | 136 private: |
| 133 Profile* profile_; | 137 Profile* profile_; |
| 138 drive::DriveIntegrationService* drive_integration_service_; |
| 134 chromeos::disks::DiskMountManager* disk_mount_manager_; | 139 chromeos::disks::DiskMountManager* disk_mount_manager_; |
| 135 scoped_ptr<MountedDiskMonitor> mounted_disk_monitor_; | 140 scoped_ptr<MountedDiskMonitor> mounted_disk_monitor_; |
| 136 PrefChangeRegistrar pref_change_registrar_; | 141 PrefChangeRegistrar pref_change_registrar_; |
| 137 ObserverList<VolumeManagerObserver> observers_; | 142 ObserverList<VolumeManagerObserver> observers_; |
| 138 DISALLOW_COPY_AND_ASSIGN(VolumeManager); | 143 DISALLOW_COPY_AND_ASSIGN(VolumeManager); |
| 139 }; | 144 }; |
| 140 | 145 |
| 141 } // namespace file_manager | 146 } // namespace file_manager |
| 142 | 147 |
| 143 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 148 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
| OLD | NEW |