OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_STORAGE_MONITOR_STORAGE_INFO_H_ | 5 #ifndef COMPONENTS_STORAGE_MONITOR_STORAGE_INFO_H_ |
6 #define COMPONENTS_STORAGE_MONITOR_STORAGE_INFO_H_ | 6 #define COMPONENTS_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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 ITUNES, | 27 ITUNES, |
28 // A Picasa database. | 28 // A Picasa database. |
29 PICASA, | 29 PICASA, |
30 // An iPhoto library. | 30 // An iPhoto library. |
31 IPHOTO, | 31 IPHOTO, |
32 }; | 32 }; |
33 | 33 |
34 StorageInfo(); | 34 StorageInfo(); |
35 // Note: |device_id_in| should be constructed with MakeDeviceId. | 35 // Note: |device_id_in| should be constructed with MakeDeviceId. |
36 StorageInfo(const std::string& device_id_in, | 36 StorageInfo(const std::string& device_id_in, |
37 const base::string16& device_name, | |
38 const base::FilePath::StringType& device_location, | 37 const base::FilePath::StringType& device_location, |
39 const base::string16& label, | 38 const base::string16& label, |
40 const base::string16& vendor, | 39 const base::string16& vendor, |
41 const base::string16& model, | 40 const base::string16& model, |
42 uint64 size_in_bytes); | 41 uint64 size_in_bytes); |
43 ~StorageInfo(); | 42 ~StorageInfo(); |
44 | 43 |
45 // Returns a device id given properties of the device. A prefix dependent on | 44 // Returns a device id given properties of the device. A prefix dependent on |
46 // |type| is added so |unique_id| need only be unique within the given type. | 45 // |type| is added so |unique_id| need only be unique within the given type. |
47 // Returns an empty string if an invalid type is passed in. | 46 // Returns an empty string if an invalid type is passed in. |
(...skipping 15 matching lines...) Expand all Loading... |
63 // Looks inside |device_id| to determine if it is a mass storage device | 62 // Looks inside |device_id| to determine if it is a mass storage device |
64 // (type isn't MTP_OR_PTP). | 63 // (type isn't MTP_OR_PTP). |
65 static bool IsMassStorageDevice(const std::string& device_id); | 64 static bool IsMassStorageDevice(const std::string& device_id); |
66 | 65 |
67 static bool IsITunesDevice(const std::string& device_id); | 66 static bool IsITunesDevice(const std::string& device_id); |
68 | 67 |
69 static bool IsPicasaDevice(const std::string& device_id); | 68 static bool IsPicasaDevice(const std::string& device_id); |
70 | 69 |
71 static bool IsIPhotoDevice(const std::string& device_id); | 70 static bool IsIPhotoDevice(const std::string& device_id); |
72 | 71 |
| 72 // Get the display name for the removable device represented by this |
| 73 // StorageInfo. Include the size for removable devices if |with_size| is true. |
| 74 base::string16 GetDisplayName(bool with_size) const; |
| 75 |
| 76 // Same as GetDisplayName(), but may be overridden by |override_display_name|. |
| 77 base::string16 GetDisplayNameWithOverride( |
| 78 const base::string16& override_display_name, bool with_size) const; |
| 79 |
73 const std::string& device_id() const { return device_id_; } | 80 const std::string& device_id() const { return device_id_; } |
74 const base::string16& name() const { return name_; } | |
75 const base::FilePath::StringType& location() const { return location_; } | 81 const base::FilePath::StringType& location() const { return location_; } |
76 const base::string16& storage_label() const { return storage_label_; } | 82 const base::string16& storage_label() const { return storage_label_; } |
77 const base::string16& vendor_name() const { return vendor_name_; } | 83 const base::string16& vendor_name() const { return vendor_name_; } |
78 const base::string16& model_name() const { return model_name_; } | 84 const base::string16& model_name() const { return model_name_; } |
79 uint64 total_size_in_bytes() const { return total_size_in_bytes_; } | 85 uint64 total_size_in_bytes() const { return total_size_in_bytes_; } |
80 | 86 |
81 void set_device_id(const std::string& device_id) { device_id_ = device_id; } | 87 void set_device_id(const std::string& device_id) { device_id_ = device_id; } |
82 void set_name(const base::string16& name) { name_ = name; } | |
83 void set_location(const base::FilePath::StringType& location) { | 88 void set_location(const base::FilePath::StringType& location) { |
84 location_ = location; | 89 location_ = location; |
85 } | 90 } |
86 | 91 |
87 private: | 92 private: |
88 // Unique device id - persists between device attachments. | 93 // Unique device id - persists between device attachments. |
89 // This is the string that should be used as the label for a particular | 94 // This is the string that should be used as the label for a particular |
90 // storage device when interacting with the API. Clients should treat | 95 // storage device when interacting with the API. Clients should treat |
91 // this as an opaque string. | 96 // this as an opaque string. |
92 std::string device_id_; | 97 std::string device_id_; |
93 | 98 |
94 // Human readable removable storage device name. | |
95 base::string16 name_; | |
96 | |
97 // Current attached removable storage device location. | 99 // Current attached removable storage device location. |
98 base::FilePath::StringType location_; | 100 base::FilePath::StringType location_; |
99 | 101 |
100 // Label given to this storage device by the user. | 102 // Label given to this storage device by the user. |
101 // May be empty if not found or the device is unlabeled. | 103 // May be empty if not found or the device is unlabeled. |
102 base::string16 storage_label_; | 104 base::string16 storage_label_; |
103 | 105 |
104 // Vendor name for the removable device. (Human readable) | 106 // Vendor name for the removable device. (Human readable) |
105 // May be empty if not collected. | 107 // May be empty if not collected. |
106 base::string16 vendor_name_; | 108 base::string16 vendor_name_; |
107 | 109 |
108 // Model name for the removable device. (Human readable) | 110 // Model name for the removable device. (Human readable) |
109 // May be empty if not collected. | 111 // May be empty if not collected. |
110 base::string16 model_name_; | 112 base::string16 model_name_; |
111 | 113 |
112 // Size of the removable device in bytes. | 114 // Size of the removable device in bytes. |
113 // Zero if not collected or unknown. | 115 // Zero if not collected or unknown. |
114 uint64 total_size_in_bytes_; | 116 uint64 total_size_in_bytes_; |
115 }; | 117 }; |
116 | 118 |
117 } // namespace storage_monitor | 119 } // namespace storage_monitor |
118 | 120 |
119 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_INFO_H_ | 121 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_INFO_H_ |
OLD | NEW |