Chromium Code Reviews| 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 // Linux specific implementation of chrome::MediaStorageUtil. | 5 // Chrome OS specific implementation of chrome::MediaStorageUtil. |
|
kmadhusu
2012/09/16 22:35:42
Do not review this file. Just uploaded for referen
vandebo (ex-Chrome)
2012/09/16 23:03:19
You can remove it now, since it's still in the pre
| |
| 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 "base/callback.h" | 9 #include "base/file_path.h" |
| 10 #include "base/string16.h" | |
| 10 #include "base/system_monitor/system_monitor.h" | 11 #include "base/system_monitor/system_monitor.h" |
| 11 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" | 12 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_ chromeos.h" |
| 13 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h" | |
| 12 | 14 |
| 13 namespace chrome { | 15 namespace chrome { |
| 14 | 16 |
| 17 using base::SystemMonitor; | |
| 18 using chromeos::mtp::MediaTransferProtocolDeviceObserverCros; | |
| 19 using chromeos::RemovableDeviceNotificationsCros; | |
| 20 | |
| 15 // static | 21 // static |
| 16 bool MediaStorageUtil::GetDeviceInfoFromPathImpl(const FilePath& path, | 22 bool MediaStorageUtil::GetDeviceInfoFromPathImpl(const FilePath& path, |
| 17 std::string* device_id, | 23 std::string* device_id, |
| 18 string16* device_name, | 24 string16* device_name, |
| 19 FilePath* relative_path) { | 25 FilePath* relative_path) { |
| 20 RemovableDeviceNotificationsLinux* device_tracker = | 26 // Check if the |path| belongs to a removable mass storage device. |
| 21 RemovableDeviceNotificationsLinux::GetInstance(); | 27 RemovableDeviceNotificationsCros* mass_storage_tracker = |
| 22 DCHECK(device_tracker); | 28 RemovableDeviceNotificationsCros::GetInstance(); |
| 29 DCHECK(mass_storage_tracker); | |
| 23 base::SystemMonitor::RemovableStorageInfo device_info; | 30 base::SystemMonitor::RemovableStorageInfo device_info; |
| 24 bool found_device = device_tracker->GetDeviceInfoForPath(path, &device_info); | 31 bool found_device = mass_storage_tracker->GetDeviceInfoForPath(path, |
| 32 &device_info); | |
| 33 if (!found_device) { | |
| 34 // Check if the |path| belongs to a mtp storage device. | |
| 35 MediaTransferProtocolDeviceObserverCros * mtp_device_tracker = | |
| 36 MediaTransferProtocolDeviceObserverCros::GetInstance(); | |
| 37 found_device = mtp_device_tracker->GetStorageInfoForPath(path, | |
| 38 &device_info); | |
| 39 } | |
| 25 | 40 |
| 26 if (found_device && IsRemovableDevice(device_info.device_id)) { | 41 if (found_device && IsRemovableDevice(device_info.device_id)) { |
| 27 if (device_id) | 42 if (device_id) |
| 28 *device_id = device_info.device_id; | 43 *device_id = device_info.device_id; |
| 29 if (device_name) | 44 if (device_name) |
| 30 *device_name = device_info.name; | 45 *device_name = device_info.name; |
| 31 if (relative_path) { | 46 if (relative_path) { |
| 32 *relative_path = FilePath(); | 47 *relative_path = FilePath(); |
| 33 FilePath mount_point(device_info.location); | 48 FilePath mount_point(device_info.location); |
| 34 mount_point.AppendRelativePath(path, relative_path); | 49 mount_point.AppendRelativePath(path, relative_path); |
| 35 } | 50 } |
| 36 return true; | 51 return true; |
| 37 } | 52 } |
| 38 | 53 |
| 39 if (device_id) | 54 if (device_id) |
| 40 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); | 55 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); |
| 41 if (device_name) | 56 if (device_name) |
| 42 *device_name = path.BaseName().LossyDisplayName(); | 57 *device_name = path.BaseName().LossyDisplayName(); |
| 43 if (relative_path) | 58 if (relative_path) |
| 44 *relative_path = FilePath(); | 59 *relative_path = FilePath(); |
| 45 return true; | 60 return true; |
| 46 } | 61 } |
| 47 | 62 |
| 48 } // namespace chrome | 63 } // namespace chrome |
| OLD | NEW |