Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.h

Issue 2580303002: mediaview: Mount ARC documents provider file system volumes. (Closed)
Patch Set: Consistently use GetGlobalService(). Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/files/file.h" 14 #include "base/files/file.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 20 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
21 #include "chrome/browser/chromeos/file_system_provider/observer.h" 21 #include "chrome/browser/chromeos/file_system_provider/observer.h"
22 #include "chrome/browser/chromeos/file_system_provider/service.h" 22 #include "chrome/browser/chromeos/file_system_provider/service.h"
23 #include "chromeos/dbus/cros_disks_client.h" 23 #include "chromeos/dbus/cros_disks_client.h"
24 #include "chromeos/disks/disk_mount_manager.h" 24 #include "chromeos/disks/disk_mount_manager.h"
25 #include "components/arc/file_system/arc_file_system_observer.h"
25 #include "components/keyed_service/core/keyed_service.h" 26 #include "components/keyed_service/core/keyed_service.h"
26 #include "components/prefs/pref_change_registrar.h" 27 #include "components/prefs/pref_change_registrar.h"
27 #include "components/storage_monitor/removable_storage_observer.h" 28 #include "components/storage_monitor/removable_storage_observer.h"
28 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" 29 #include "device/media_transfer_protocol/mtp_storage_info.pb.h"
29 30
30 class Profile; 31 class Profile;
31 32
32 namespace chromeos { 33 namespace chromeos {
33 class PowerManagerClient; 34 class PowerManagerClient;
34 } // namespace chromeos 35 } // namespace chromeos
35 36
36 namespace content { 37 namespace content {
37 class BrowserContext; 38 class BrowserContext;
38 } // namespace content 39 } // namespace content
39 40
40 namespace file_manager { 41 namespace file_manager {
41 42
42 class SnapshotManager; 43 class SnapshotManager;
43 class VolumeManagerObserver; 44 class VolumeManagerObserver;
44 45
45 // Identifiers for volume types managed by Chrome OS file manager. 46 // Identifiers for volume types managed by Chrome OS file manager.
46 enum VolumeType { 47 enum VolumeType {
47 VOLUME_TYPE_TESTING = -1, // Used only in tests. 48 VOLUME_TYPE_TESTING = -1, // Used only in tests.
48 VOLUME_TYPE_GOOGLE_DRIVE = 0, 49 VOLUME_TYPE_GOOGLE_DRIVE = 0,
49 VOLUME_TYPE_DOWNLOADS_DIRECTORY, 50 VOLUME_TYPE_DOWNLOADS_DIRECTORY,
50 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, 51 VOLUME_TYPE_REMOVABLE_DISK_PARTITION,
51 VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, 52 VOLUME_TYPE_MOUNTED_ARCHIVE_FILE,
52 VOLUME_TYPE_PROVIDED, // File system provided by the FileSystemProvider API. 53 VOLUME_TYPE_PROVIDED, // File system provided by the FileSystemProvider API.
53 VOLUME_TYPE_MTP, 54 VOLUME_TYPE_MTP,
55 VOLUME_TYPE_MEDIA_VIEW,
54 // The enum values must be kept in sync with FileManagerVolumeType in 56 // The enum values must be kept in sync with FileManagerVolumeType in
55 // tools/metrics/histograms/histograms.xml. Since enums for histograms are 57 // tools/metrics/histograms/histograms.xml. Since enums for histograms are
56 // append-only (for keeping the number consistent across versions), new values 58 // append-only (for keeping the number consistent across versions), new values
57 // for this enum also has to be always appended at the end (i.e., here). 59 // for this enum also has to be always appended at the end (i.e., here).
58 NUM_VOLUME_TYPE, 60 NUM_VOLUME_TYPE,
59 }; 61 };
60 62
61 // Says how was the mount performed, whether due to user interaction, or 63 // Says how was the mount performed, whether due to user interaction, or
62 // automatic. User interaction includes both hardware (pluggins a USB stick) 64 // automatic. User interaction includes both hardware (pluggins a USB stick)
63 // or software (mounting a ZIP archive) interaction. 65 // or software (mounting a ZIP archive) interaction.
(...skipping 19 matching lines...) Expand all
83 static Volume* CreateForRemovable( 85 static Volume* CreateForRemovable(
84 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point, 86 const chromeos::disks::DiskMountManager::MountPointInfo& mount_point,
85 const chromeos::disks::DiskMountManager::Disk* disk); 87 const chromeos::disks::DiskMountManager::Disk* disk);
86 static Volume* CreateForProvidedFileSystem( 88 static Volume* CreateForProvidedFileSystem(
87 const chromeos::file_system_provider::ProvidedFileSystemInfo& 89 const chromeos::file_system_provider::ProvidedFileSystemInfo&
88 file_system_info, 90 file_system_info,
89 MountContext mount_context); 91 MountContext mount_context);
90 static Volume* CreateForMTP(const base::FilePath& mount_path, 92 static Volume* CreateForMTP(const base::FilePath& mount_path,
91 const std::string& label, 93 const std::string& label,
92 bool read_only); 94 bool read_only);
95 static Volume* CreateForMediaView(const std::string& root_document_id);
93 static Volume* CreateForTesting(const base::FilePath& path, 96 static Volume* CreateForTesting(const base::FilePath& path,
94 VolumeType volume_type, 97 VolumeType volume_type,
95 chromeos::DeviceType device_type, 98 chromeos::DeviceType device_type,
96 bool read_only); 99 bool read_only);
97 static Volume* CreateForTesting(const base::FilePath& device_path, 100 static Volume* CreateForTesting(const base::FilePath& device_path,
98 const base::FilePath& mount_path); 101 const base::FilePath& mount_path);
99 102
100 // Getters for all members. See below for details. 103 // Getters for all members. See below for details.
101 const std::string& volume_id() const { return volume_id_; } 104 const std::string& volume_id() const { return volume_id_; }
102 const std::string& file_system_id() const { return file_system_id_; } 105 const std::string& file_system_id() const { return file_system_id_; }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 DISALLOW_COPY_AND_ASSIGN(Volume); 207 DISALLOW_COPY_AND_ASSIGN(Volume);
205 }; 208 };
206 209
207 // Manages "Volume"s for file manager. Here are "Volume"s. 210 // Manages "Volume"s for file manager. Here are "Volume"s.
208 // - Drive File System (not yet supported). 211 // - Drive File System (not yet supported).
209 // - Downloads directory. 212 // - Downloads directory.
210 // - Removable disks (volume will be created for each partition, not only one 213 // - Removable disks (volume will be created for each partition, not only one
211 // for a device). 214 // for a device).
212 // - Mounted zip archives. 215 // - Mounted zip archives.
213 class VolumeManager : public KeyedService, 216 class VolumeManager : public KeyedService,
217 public arc::ArcFileSystemObserver,
214 public drive::DriveIntegrationServiceObserver, 218 public drive::DriveIntegrationServiceObserver,
215 public chromeos::disks::DiskMountManager::Observer, 219 public chromeos::disks::DiskMountManager::Observer,
216 public chromeos::file_system_provider::Observer, 220 public chromeos::file_system_provider::Observer,
217 public storage_monitor::RemovableStorageObserver { 221 public storage_monitor::RemovableStorageObserver {
218 public: 222 public:
219 // Returns MediaTransferProtocolManager. Used for injecting 223 // Returns MediaTransferProtocolManager. Used for injecting
220 // FakeMediaTransferProtocolManager for testing. 224 // FakeMediaTransferProtocolManager for testing.
221 typedef base::Callback<const MtpStorageInfo*(const std::string&)> 225 typedef base::Callback<const MtpStorageInfo*(const std::string&)>
222 GetMtpStorageInfoCallback; 226 GetMtpStorageInfoCallback;
223 227
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void OnProvidedFileSystemMount( 294 void OnProvidedFileSystemMount(
291 const chromeos::file_system_provider::ProvidedFileSystemInfo& 295 const chromeos::file_system_provider::ProvidedFileSystemInfo&
292 file_system_info, 296 file_system_info,
293 chromeos::file_system_provider::MountContext context, 297 chromeos::file_system_provider::MountContext context,
294 base::File::Error error) override; 298 base::File::Error error) override;
295 void OnProvidedFileSystemUnmount( 299 void OnProvidedFileSystemUnmount(
296 const chromeos::file_system_provider::ProvidedFileSystemInfo& 300 const chromeos::file_system_provider::ProvidedFileSystemInfo&
297 file_system_info, 301 file_system_info,
298 base::File::Error error) override; 302 base::File::Error error) override;
299 303
304 // arc::ArcFileSystemObserver overrides.
305 void OnFileSystemsReady() override;
306 void OnFileSystemsClosed() override;
307
300 // Called on change to kExternalStorageDisabled pref. 308 // Called on change to kExternalStorageDisabled pref.
301 void OnExternalStorageDisabledChanged(); 309 void OnExternalStorageDisabledChanged();
302 310
303 // Called on change to kExternalStorageReadOnly pref. 311 // Called on change to kExternalStorageReadOnly pref.
304 void OnExternalStorageReadOnlyChanged(); 312 void OnExternalStorageReadOnlyChanged();
305 313
306 // RemovableStorageObserver overrides. 314 // RemovableStorageObserver overrides.
307 void OnRemovableStorageAttached( 315 void OnRemovableStorageAttached(
308 const storage_monitor::StorageInfo& info) override; 316 const storage_monitor::StorageInfo& info) override;
309 void OnRemovableStorageDetached( 317 void OnRemovableStorageDetached(
(...skipping 24 matching lines...) Expand all
334 342
335 // Note: This should remain the last member so it'll be destroyed and 343 // Note: This should remain the last member so it'll be destroyed and
336 // invalidate its weak pointers before any other members are destroyed. 344 // invalidate its weak pointers before any other members are destroyed.
337 base::WeakPtrFactory<VolumeManager> weak_ptr_factory_; 345 base::WeakPtrFactory<VolumeManager> weak_ptr_factory_;
338 DISALLOW_COPY_AND_ASSIGN(VolumeManager); 346 DISALLOW_COPY_AND_ASSIGN(VolumeManager);
339 }; 347 };
340 348
341 } // namespace file_manager 349 } // namespace file_manager
342 350
343 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_ 351 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_VOLUME_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698