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 #include "components/storage_monitor/storage_info.h" | 5 #include "components/storage_monitor/storage_info.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/storage_monitor/media_storage_util.h" | 9 #include "components/storage_monitor/media_storage_util.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 Type type; | 173 Type type; |
174 return CrackDeviceId(device_id, &type, NULL) && type == IPHOTO; | 174 return CrackDeviceId(device_id, &type, NULL) && type == IPHOTO; |
175 } | 175 } |
176 | 176 |
177 // static | 177 // static |
178 bool StorageInfo::IsPicasaDevice(const std::string& device_id) { | 178 bool StorageInfo::IsPicasaDevice(const std::string& device_id) { |
179 Type type; | 179 Type type; |
180 return CrackDeviceId(device_id, &type, NULL) && type == PICASA; | 180 return CrackDeviceId(device_id, &type, NULL) && type == PICASA; |
181 } | 181 } |
182 | 182 |
| 183 // static |
| 184 bool StorageInfo::IsMTPDevice(const std::string& device_id) { |
| 185 Type type; |
| 186 return CrackDeviceId(device_id, &type, NULL) && type == MTP_OR_PTP; |
| 187 } |
| 188 |
183 base::string16 StorageInfo::GetDisplayName(bool with_size) const { | 189 base::string16 StorageInfo::GetDisplayName(bool with_size) const { |
184 return GetDisplayNameWithOverride(base::string16(), with_size); | 190 return GetDisplayNameWithOverride(base::string16(), with_size); |
185 } | 191 } |
186 | 192 |
187 base::string16 StorageInfo::GetDisplayNameWithOverride( | 193 base::string16 StorageInfo::GetDisplayNameWithOverride( |
188 const base::string16& override_display_name, bool with_size) const { | 194 const base::string16& override_display_name, bool with_size) const { |
189 if (!IsRemovableDevice(device_id_)) { | 195 if (!IsRemovableDevice(device_id_)) { |
190 if (!storage_label_.empty()) | 196 if (!storage_label_.empty()) |
191 return storage_label_; | 197 return storage_label_; |
192 return base::FilePath(location_).LossyDisplayName(); | 198 return base::FilePath(location_).LossyDisplayName(); |
193 } | 199 } |
194 | 200 |
195 base::string16 name = override_display_name; | 201 base::string16 name = override_display_name; |
196 if (name.empty()) | 202 if (name.empty()) |
197 name = storage_label_; | 203 name = storage_label_; |
198 if (name.empty()) | 204 if (name.empty()) |
199 name = GetFullProductName(vendor_name_, model_name_); | 205 name = GetFullProductName(vendor_name_, model_name_); |
200 if (name.empty()) | 206 if (name.empty()) |
201 name = base::ASCIIToUTF16("Unlabeled device"); | 207 name = base::ASCIIToUTF16("Unlabeled device"); |
202 | 208 |
203 if (with_size) | 209 if (with_size) |
204 name = GetDisplayNameForDevice(total_size_in_bytes_, name); | 210 name = GetDisplayNameForDevice(total_size_in_bytes_, name); |
205 return name; | 211 return name; |
206 } | 212 } |
207 | 213 |
208 } // namespace storage_monitor | 214 } // namespace storage_monitor |
OLD | NEW |