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 implementation. | 5 // chrome::MediaStorageUtil implementation. |
6 | 6 |
7 #include "chrome/browser/system_monitor/media_storage_util.h" | 7 #include "chrome/browser/system_monitor/media_storage_util.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 247 |
248 #if defined(OS_LINUX) | 248 #if defined(OS_LINUX) |
249 if (!found_device) { | 249 if (!found_device) { |
250 MediaTransferProtocolDeviceObserverLinux* mtp_manager = | 250 MediaTransferProtocolDeviceObserverLinux* mtp_manager = |
251 MediaTransferProtocolDeviceObserverLinux::GetInstance(); | 251 MediaTransferProtocolDeviceObserverLinux::GetInstance(); |
252 found_device = mtp_manager->GetStorageInfoForPath(path, &device_info); | 252 found_device = mtp_manager->GetStorageInfoForPath(path, &device_info); |
253 } | 253 } |
254 #endif | 254 #endif |
255 | 255 |
256 if (found_device && IsRemovableDevice(device_info.device_id)) { | 256 if (found_device && IsRemovableDevice(device_info.device_id)) { |
257 FilePath sub_folder_path; | |
258 if (device_name || relative_path) { | |
259 bool success = FilePath(device_info.location) | |
260 .AppendRelativePath(path, &sub_folder_path); | |
261 DCHECK(success); | |
262 } | |
263 | |
264 #if defined(OS_CHROMEOS) | |
Lei Zhang
2012/11/09 01:12:18
So after this CL, Linux no longer gets folder name
kmadhusu
2012/11/09 21:59:40
Yes. Linux changes are ready for review (https://c
| |
265 if (device_name) { | |
Lei Zhang
2012/11/09 01:12:18
Can we do all the |device_name| appends in one blo
kmadhusu
2012/11/09 21:59:40
sure.
| |
266 *device_name = notifier->GetStorageSizeInfo(device_info.location) + | |
267 ASCIIToUTF16(" "); | |
268 if (!sub_folder_path.value().empty()) { | |
269 *device_name += ASCIIToUTF16(" (") + | |
270 sub_folder_path.BaseName().LossyDisplayName() + ASCIIToUTF16(") "); | |
271 } | |
272 } | |
273 #endif | |
274 | |
257 if (device_id) | 275 if (device_id) |
258 *device_id = device_info.device_id; | 276 *device_id = device_info.device_id; |
259 if (device_name) | 277 if (device_name) |
260 *device_name = device_info.name; | 278 *device_name += device_info.name; |
261 if (relative_path) { | 279 if (relative_path) |
262 *relative_path = FilePath(); | 280 *relative_path = sub_folder_path; |
263 FilePath mount_point(device_info.location); | |
264 bool success = mount_point.AppendRelativePath(path, relative_path); | |
265 #if defined(OS_POSIX) | |
266 if (!relative_path->value().empty() && device_name) { | |
267 *device_name += ASCIIToUTF16(" (") + | |
268 relative_path->BaseName().LossyDisplayName() + ASCIIToUTF16(")"); | |
269 } | |
270 #endif | |
271 DCHECK(success); | |
272 } | |
273 return true; | 281 return true; |
274 } | 282 } |
275 | 283 |
276 // On Posix systems, there's one root so any absolute path could be valid. | 284 // On Posix systems, there's one root so any absolute path could be valid. |
277 #if !defined(OS_POSIX) | 285 #if !defined(OS_POSIX) |
278 if (!found_device) | 286 if (!found_device) |
279 return false; | 287 return false; |
280 #endif | 288 #endif |
281 | 289 |
282 if (device_id) | 290 if (device_id) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 | 339 |
332 // static | 340 // static |
333 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( | 341 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( |
334 GetDeviceInfoFromPathFunction function) { | 342 GetDeviceInfoFromPathFunction function) { |
335 g_test_get_device_info_from_path_function = function; | 343 g_test_get_device_info_from_path_function = function; |
336 } | 344 } |
337 | 345 |
338 MediaStorageUtil::MediaStorageUtil() {} | 346 MediaStorageUtil::MediaStorageUtil() {} |
339 | 347 |
340 } // namespace chrome | 348 } // namespace chrome |
OLD | NEW |