| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // chrome::MediaStorageUtil provides information about storage devices attached | 5 // chrome::MediaStorageUtil provides information about storage devices attached |
| 6 // to the computer. | 6 // to the computer. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ | 8 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ |
| 9 #define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ | 9 #define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 public: | 21 public: |
| 22 enum Type { | 22 enum Type { |
| 23 // A removable mass storage device with a DCIM directory. | 23 // A removable mass storage device with a DCIM directory. |
| 24 REMOVABLE_MASS_STORAGE_WITH_DCIM, | 24 REMOVABLE_MASS_STORAGE_WITH_DCIM, |
| 25 // A removable mass storage device without a DCIM directory. | 25 // A removable mass storage device without a DCIM directory. |
| 26 REMOVABLE_MASS_STORAGE_NO_DCIM, | 26 REMOVABLE_MASS_STORAGE_NO_DCIM, |
| 27 // A fixed mass storage device. | 27 // A fixed mass storage device. |
| 28 FIXED_MASS_STORAGE, | 28 FIXED_MASS_STORAGE, |
| 29 // A MTP or PTP device. | 29 // A MTP or PTP device. |
| 30 MTP_OR_PTP, | 30 MTP_OR_PTP, |
| 31 // A Mac ImageCapture device. |
| 32 MAC_IMAGE_CAPTURE, |
| 31 }; | 33 }; |
| 32 | 34 |
| 33 typedef std::set<std::string /*device id*/> DeviceIdSet; | 35 typedef std::set<std::string /*device id*/> DeviceIdSet; |
| 34 typedef base::Callback<void(bool)> BoolCallback; | 36 typedef base::Callback<void(bool)> BoolCallback; |
| 35 | 37 |
| 36 // Returns a device id given properties of the device. A prefix dependent on | 38 // Returns a device id given properties of the device. A prefix dependent on |
| 37 // |type| is added so |unique_id| need only be unique within the given type. | 39 // |type| is added so |unique_id| need only be unique within the given type. |
| 38 // Returns an empty string if an invalid type is passed in. | 40 // Returns an empty string if an invalid type is passed in. |
| 39 static std::string MakeDeviceId(Type type, const std::string& unique_id); | 41 static std::string MakeDeviceId(Type type, const std::string& unique_id); |
| 40 | 42 |
| 41 // Extracts the device |type| and |unique_id| from |device_id|. Returns false | 43 // Extracts the device |type| and |unique_id| from |device_id|. Returns false |
| 42 // if the device_id isn't properly formatted. | 44 // if the device_id isn't properly formatted. |
| 43 static bool CrackDeviceId(const std::string& device_id, | 45 static bool CrackDeviceId(const std::string& device_id, |
| 44 Type* type, std::string* unique_id); | 46 Type* type, std::string* unique_id); |
| 45 | 47 |
| 46 // Looks inside |device_id| to determine if it is a media device | 48 // Looks inside |device_id| to determine if it is a media device |
| 47 // (type is REMOVABLE_MASS_STORAGE_WITH_DCIM or MTP_OR_PTP). | 49 // (type is REMOVABLE_MASS_STORAGE_WITH_DCIM or MTP_OR_PTP). |
| 48 static bool IsMediaDevice(const std::string& device_id); | 50 static bool IsMediaDevice(const std::string& device_id); |
| 49 | 51 |
| 50 // Looks inside |device_id| to determine if it is a media device | 52 // Looks inside |device_id| to determine if it is a media device |
| 51 // (type isn't FIXED_MASS_STORAGE). | 53 // (type isn't FIXED_MASS_STORAGE). |
| 52 static bool IsRemovableDevice(const std::string& device_id); | 54 static bool IsRemovableDevice(const std::string& device_id); |
| 53 | 55 |
| 54 // Looks inside |device_id| to determine if it is a mass storage device | 56 // Looks inside |device_id| to determine if it is a mass storage device |
| 55 // (type isn't MTP_OR_PTP). | 57 // (type isn't MTP_OR_PTP). |
| 56 static bool IsMassStorageDevice(const std::string& device_id); | 58 static bool IsMassStorageDevice(const std::string& device_id); |
| 57 | 59 |
| 60 // Returns true if we will be able to create a filesystem for this device. |
| 61 static bool CanCreateFileSystem(const std::string& device_id, |
| 62 const FilePath& path); |
| 63 |
| 58 // Determines if the device is attached to the computer. | 64 // Determines if the device is attached to the computer. |
| 59 static void IsDeviceAttached(const std::string& device_id, | 65 static void IsDeviceAttached(const std::string& device_id, |
| 60 const BoolCallback& callback); | 66 const BoolCallback& callback); |
| 61 | 67 |
| 62 // Removes disconnected devices from |devices| and then calls |done|. | 68 // Removes disconnected devices from |devices| and then calls |done|. |
| 63 static void FilterAttachedDevices(DeviceIdSet* devices, | 69 static void FilterAttachedDevices(DeviceIdSet* devices, |
| 64 const base::Closure& done); | 70 const base::Closure& done); |
| 65 | 71 |
| 66 // Given |path|, fill in |device_id|, |device_name|, and |relative_path| | 72 // Given |path|, fill in |device_id|, |device_name|, and |relative_path| |
| 67 // (from the root of the device) if they are not NULL. | 73 // (from the root of the device) if they are not NULL. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 95 private: | 101 private: |
| 96 // All methods are static, this class should not be instantiated. | 102 // All methods are static, this class should not be instantiated. |
| 97 MediaStorageUtil(); | 103 MediaStorageUtil(); |
| 98 | 104 |
| 99 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); | 105 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); |
| 100 }; | 106 }; |
| 101 | 107 |
| 102 } // namespace chrome | 108 } // namespace chrome |
| 103 | 109 |
| 104 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ | 110 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ |
| OLD | NEW |