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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/prefs/pref_change_registrar.h" | 15 #include "base/prefs/pref_change_registrar.h" |
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 17 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
| 18 #include "chrome/browser/chromeos/file_system_provider/service.h" |
17 #include "chrome/browser/local_discovery/storage/privet_volume_lister.h" | 19 #include "chrome/browser/local_discovery/storage/privet_volume_lister.h" |
18 #include "chromeos/dbus/cros_disks_client.h" | 20 #include "chromeos/dbus/cros_disks_client.h" |
19 #include "chromeos/disks/disk_mount_manager.h" | 21 #include "chromeos/disks/disk_mount_manager.h" |
20 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 22 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
21 | 23 |
22 class Profile; | 24 class Profile; |
23 | 25 |
24 namespace chromeos { | 26 namespace chromeos { |
25 class PowerManagerClient; | 27 class PowerManagerClient; |
26 } // namespace chromeos | 28 } // namespace chromeos |
(...skipping 12 matching lines...) Expand all Loading... |
39 class VolumeManagerObserver; | 41 class VolumeManagerObserver; |
40 | 42 |
41 // This manager manages "Drive" and "Downloads" in addition to disks managed | 43 // This manager manages "Drive" and "Downloads" in addition to disks managed |
42 // by DiskMountManager. | 44 // by DiskMountManager. |
43 enum VolumeType { | 45 enum VolumeType { |
44 VOLUME_TYPE_GOOGLE_DRIVE, | 46 VOLUME_TYPE_GOOGLE_DRIVE, |
45 VOLUME_TYPE_DOWNLOADS_DIRECTORY, | 47 VOLUME_TYPE_DOWNLOADS_DIRECTORY, |
46 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, | 48 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, |
47 VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, | 49 VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, |
48 VOLUME_TYPE_CLOUD_DEVICE, | 50 VOLUME_TYPE_CLOUD_DEVICE, |
| 51 VOLUME_TYPE_PROVIDED, |
49 VOLUME_TYPE_TESTING | 52 VOLUME_TYPE_TESTING |
50 }; | 53 }; |
51 | 54 |
52 struct VolumeInfo { | 55 struct VolumeInfo { |
53 VolumeInfo(); | 56 VolumeInfo(); |
54 ~VolumeInfo(); | 57 ~VolumeInfo(); |
55 | 58 |
56 // The ID of the volume. | 59 // The ID of the volume. |
57 std::string volume_id; | 60 std::string volume_id; |
58 | 61 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 }; | 96 }; |
94 | 97 |
95 // Manages "Volume"s for file manager. Here are "Volume"s. | 98 // Manages "Volume"s for file manager. Here are "Volume"s. |
96 // - Drive File System (not yet supported). | 99 // - Drive File System (not yet supported). |
97 // - Downloads directory. | 100 // - Downloads directory. |
98 // - Removable disks (volume will be created for each partition, not only one | 101 // - Removable disks (volume will be created for each partition, not only one |
99 // for a device). | 102 // for a device). |
100 // - Mounted zip archives. | 103 // - Mounted zip archives. |
101 class VolumeManager : public BrowserContextKeyedService, | 104 class VolumeManager : public BrowserContextKeyedService, |
102 public drive::DriveIntegrationServiceObserver, | 105 public drive::DriveIntegrationServiceObserver, |
103 public chromeos::disks::DiskMountManager::Observer { | 106 public chromeos::disks::DiskMountManager::Observer, |
| 107 public chromeos::file_system_provider::Observer { |
104 public: | 108 public: |
105 VolumeManager(Profile* profile, | 109 VolumeManager( |
106 drive::DriveIntegrationService* drive_integration_service, | 110 Profile* profile, |
107 chromeos::PowerManagerClient* power_manager_client, | 111 drive::DriveIntegrationService* drive_integration_service, |
108 chromeos::disks::DiskMountManager* disk_mount_manager); | 112 chromeos::PowerManagerClient* power_manager_client, |
| 113 chromeos::disks::DiskMountManager* disk_mount_manager, |
| 114 chromeos::file_system_provider::Service* file_system_provider_service); |
109 virtual ~VolumeManager(); | 115 virtual ~VolumeManager(); |
110 | 116 |
111 // Returns the instance corresponding to the |context|. | 117 // Returns the instance corresponding to the |context|. |
112 static VolumeManager* Get(content::BrowserContext* context); | 118 static VolumeManager* Get(content::BrowserContext* context); |
113 | 119 |
114 // Intializes this instance. | 120 // Intializes this instance. |
115 void Initialize(); | 121 void Initialize(); |
116 | 122 |
117 // Disposes this instance. | 123 // Disposes this instance. |
118 virtual void Shutdown() OVERRIDE; | 124 virtual void Shutdown() OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 virtual void OnMountEvent( | 159 virtual void OnMountEvent( |
154 chromeos::disks::DiskMountManager::MountEvent event, | 160 chromeos::disks::DiskMountManager::MountEvent event, |
155 chromeos::MountError error_code, | 161 chromeos::MountError error_code, |
156 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) | 162 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) |
157 OVERRIDE; | 163 OVERRIDE; |
158 virtual void OnFormatEvent( | 164 virtual void OnFormatEvent( |
159 chromeos::disks::DiskMountManager::FormatEvent event, | 165 chromeos::disks::DiskMountManager::FormatEvent event, |
160 chromeos::FormatError error_code, | 166 chromeos::FormatError error_code, |
161 const std::string& device_path) OVERRIDE; | 167 const std::string& device_path) OVERRIDE; |
162 | 168 |
| 169 // chromeos::file_system_provider::Observer overrides. |
| 170 virtual void OnProvidedFileSystemRegistered( |
| 171 const chromeos::file_system_provider::ProvidedFileSystem& file_system) |
| 172 OVERRIDE; |
| 173 virtual void OnProvidedFileSystemUnregistered( |
| 174 const chromeos::file_system_provider::ProvidedFileSystem& file_system) |
| 175 OVERRIDE; |
| 176 |
163 // Called on change to kExternalStorageDisabled pref. | 177 // Called on change to kExternalStorageDisabled pref. |
164 void OnExternalStorageDisabledChanged(); | 178 void OnExternalStorageDisabledChanged(); |
165 | 179 |
166 private: | 180 private: |
167 void OnPrivetVolumesAvailable( | 181 void OnPrivetVolumesAvailable( |
168 const local_discovery::PrivetVolumeLister::VolumeList& volumes); | 182 const local_discovery::PrivetVolumeLister::VolumeList& volumes); |
169 void DoMountEvent(chromeos::MountError error_code, | 183 void DoMountEvent(chromeos::MountError error_code, |
170 const VolumeInfo& volume_info, | 184 const VolumeInfo& volume_info, |
171 bool is_remounting); | 185 bool is_remounting); |
172 void DoUnmountEvent(chromeos::MountError error_code, | 186 void DoUnmountEvent(chromeos::MountError error_code, |
173 const VolumeInfo& volume_info); | 187 const VolumeInfo& volume_info); |
174 | 188 |
175 Profile* profile_; | 189 Profile* profile_; |
176 drive::DriveIntegrationService* drive_integration_service_; | 190 drive::DriveIntegrationService* drive_integration_service_; |
177 chromeos::disks::DiskMountManager* disk_mount_manager_; | 191 chromeos::disks::DiskMountManager* disk_mount_manager_; |
178 scoped_ptr<MountedDiskMonitor> mounted_disk_monitor_; | 192 scoped_ptr<MountedDiskMonitor> mounted_disk_monitor_; |
179 PrefChangeRegistrar pref_change_registrar_; | 193 PrefChangeRegistrar pref_change_registrar_; |
180 ObserverList<VolumeManagerObserver> observers_; | 194 ObserverList<VolumeManagerObserver> observers_; |
181 scoped_ptr<local_discovery::PrivetVolumeLister> privet_volume_lister_; | 195 scoped_ptr<local_discovery::PrivetVolumeLister> privet_volume_lister_; |
| 196 chromeos::file_system_provider::Service* file_system_provider_service_; |
182 | 197 |
183 std::map<std::string, VolumeInfo> mounted_volumes_; | 198 std::map<std::string, VolumeInfo> mounted_volumes_; |
184 | 199 |
185 DISALLOW_COPY_AND_ASSIGN(VolumeManager); | 200 DISALLOW_COPY_AND_ASSIGN(VolumeManager); |
186 }; | 201 }; |
187 | 202 |
188 } // namespace file_manager | 203 } // namespace file_manager |
189 | 204 |
190 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ | 205 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ |
OLD | NEW |