| 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 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_ | 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_ |
| 6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_ | 6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 | 10 |
| 11 namespace chrome { | 11 namespace chrome { |
| 12 | 12 |
| 13 struct StorageInfo { | 13 class StorageInfo { |
| 14 public: | 14 public: |
| 15 enum Type { | 15 enum Type { |
| 16 // A removable mass storage device with a DCIM directory. | 16 // A removable mass storage device with a DCIM directory. |
| 17 REMOVABLE_MASS_STORAGE_WITH_DCIM, | 17 REMOVABLE_MASS_STORAGE_WITH_DCIM, |
| 18 // A removable mass storage device without a DCIM directory. | 18 // A removable mass storage device without a DCIM directory. |
| 19 REMOVABLE_MASS_STORAGE_NO_DCIM, | 19 REMOVABLE_MASS_STORAGE_NO_DCIM, |
| 20 // A fixed mass storage device. | 20 // A fixed mass storage device. |
| 21 FIXED_MASS_STORAGE, | 21 FIXED_MASS_STORAGE, |
| 22 // A MTP or PTP device. | 22 // A MTP or PTP device. |
| 23 MTP_OR_PTP, | 23 MTP_OR_PTP, |
| 24 // A Mac ImageCapture device. | 24 // A Mac ImageCapture device. |
| 25 MAC_IMAGE_CAPTURE, | 25 MAC_IMAGE_CAPTURE, |
| 26 // An iTunes library. | 26 // An iTunes library. |
| 27 ITUNES, | 27 ITUNES, |
| 28 // A Picasa database. | 28 // A Picasa database. |
| 29 PICASA, | 29 PICASA, |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 StorageInfo(); | 32 StorageInfo(); |
| 33 // Note: |device_id_in| should be constructed with MakeDeviceId. | 33 // Note: |device_id_in| should be constructed with MakeDeviceId. |
| 34 StorageInfo(const std::string& device_id_in, | 34 StorageInfo(const std::string& device_id_in, |
| 35 const string16& device_name, | |
| 36 const base::FilePath::StringType& device_location, | 35 const base::FilePath::StringType& device_location, |
| 37 const string16& label, | 36 const string16& label, |
| 38 const string16& vendor, | 37 const string16& vendor, |
| 39 const string16& model, | 38 const string16& model, |
| 40 uint64 size_in_bytes); | 39 uint64 size_in_bytes); |
| 41 ~StorageInfo(); | 40 ~StorageInfo(); |
| 42 | 41 |
| 43 // Returns a device id given properties of the device. A prefix dependent on | 42 // Returns a device id given properties of the device. A prefix dependent on |
| 44 // |type| is added so |unique_id| need only be unique within the given type. | 43 // |type| is added so |unique_id| need only be unique within the given type. |
| 45 // Returns an empty string if an invalid type is passed in. | 44 // Returns an empty string if an invalid type is passed in. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 static bool IsRemovableDevice(const std::string& device_id); | 58 static bool IsRemovableDevice(const std::string& device_id); |
| 60 | 59 |
| 61 // Looks inside |device_id| to determine if it is a mass storage device | 60 // Looks inside |device_id| to determine if it is a mass storage device |
| 62 // (type isn't MTP_OR_PTP). | 61 // (type isn't MTP_OR_PTP). |
| 63 static bool IsMassStorageDevice(const std::string& device_id); | 62 static bool IsMassStorageDevice(const std::string& device_id); |
| 64 | 63 |
| 65 static bool IsITunesDevice(const std::string& device_id); | 64 static bool IsITunesDevice(const std::string& device_id); |
| 66 | 65 |
| 67 static bool IsPicasaDevice(const std::string& device_id); | 66 static bool IsPicasaDevice(const std::string& device_id); |
| 68 | 67 |
| 68 // Get the display name for the device represented by this StorageInfo. |
| 69 // Include the size for removable devices if |with_size| is true. |
| 70 base::string16 GetDisplayName(bool with_size) const; |
| 71 |
| 72 // Same as GetDisplayName(), but may be overridden by |override_display_name|. |
| 73 base::string16 GetDisplayNameWithOverride( |
| 74 const base::string16& override_display_name, bool with_size) const; |
| 75 |
| 69 const std::string& device_id() const { return device_id_; } | 76 const std::string& device_id() const { return device_id_; } |
| 70 const string16& name() const { return name_; } | |
| 71 const base::FilePath::StringType& location() const { return location_; } | 77 const base::FilePath::StringType& location() const { return location_; } |
| 72 const string16& storage_label() const { return storage_label_; } | 78 const string16& storage_label() const { return storage_label_; } |
| 73 const string16& vendor_name() const { return vendor_name_; } | 79 const string16& vendor_name() const { return vendor_name_; } |
| 74 const string16& model_name() const { return model_name_; } | 80 const string16& model_name() const { return model_name_; } |
| 75 uint64 total_size_in_bytes() const { return total_size_in_bytes_; } | 81 uint64 total_size_in_bytes() const { return total_size_in_bytes_; } |
| 76 | 82 |
| 77 void set_device_id(const std::string& device_id) { device_id_ = device_id; } | 83 void set_device_id(const std::string& device_id) { device_id_ = device_id; } |
| 78 void set_name(const string16& name) { name_ = name; } | |
| 79 void set_location(const base::FilePath::StringType& location) { | 84 void set_location(const base::FilePath::StringType& location) { |
| 80 location_ = location; | 85 location_ = location; |
| 81 } | 86 } |
| 82 | 87 |
| 83 private: | 88 private: |
| 84 // Unique device id - persists between device attachments. | 89 // Unique device id - persists between device attachments. |
| 85 // This is the string that should be used as the label for a particular | 90 // This is the string that should be used as the label for a particular |
| 86 // storage device when interacting with the API. Clients should treat | 91 // storage device when interacting with the API. Clients should treat |
| 87 // this as an opaque string. | 92 // this as an opaque string. |
| 88 std::string device_id_; | 93 std::string device_id_; |
| 89 | 94 |
| 90 // Human readable removable storage device name. | |
| 91 string16 name_; | |
| 92 | |
| 93 // Current attached removable storage device location. | 95 // Current attached removable storage device location. |
| 94 base::FilePath::StringType location_; | 96 base::FilePath::StringType location_; |
| 95 | 97 |
| 96 // Label given to this storage device by the user. | 98 // Label given to this storage device by the user. |
| 97 // May be empty if not found or the device is unlabeled. | 99 // May be empty if not found or the device is unlabeled. |
| 98 string16 storage_label_; | 100 string16 storage_label_; |
| 99 | 101 |
| 100 // Vendor name for the removable device. (Human readable) | 102 // Vendor name for the removable device. (Human readable) |
| 101 // May be empty if not collected. | 103 // May be empty if not collected. |
| 102 string16 vendor_name_; | 104 string16 vendor_name_; |
| 103 | 105 |
| 104 // Model name for the removable device. (Human readable) | 106 // Model name for the removable device. (Human readable) |
| 105 // May be empty if not collected. | 107 // May be empty if not collected. |
| 106 string16 model_name_; | 108 string16 model_name_; |
| 107 | 109 |
| 108 // Size of the removable device in bytes. | 110 // Size of the removable device in bytes. |
| 109 // Zero if not collected or unknown. | 111 // Zero if not collected or unknown. |
| 110 uint64 total_size_in_bytes_; | 112 uint64 total_size_in_bytes_; |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 } // namespace chrome | 115 } // namespace chrome |
| 114 | 116 |
| 115 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_ | 117 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_ |
| OLD | NEW |