| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 if (type == MediaStorageUtil::FIXED_MASS_STORAGE) { | 95 if (type == MediaStorageUtil::FIXED_MASS_STORAGE) { |
| 96 if (!file_util::PathExists(FilePath::FromUTF8Unsafe(unique_id))) | 96 if (!file_util::PathExists(FilePath::FromUTF8Unsafe(unique_id))) |
| 97 missing_devices.insert(*it); | 97 missing_devices.insert(*it); |
| 98 continue; | 98 continue; |
| 99 } | 99 } |
| 100 | 100 |
| 101 DCHECK(type == MediaStorageUtil::MTP_OR_PTP || | 101 DCHECK(type == MediaStorageUtil::MTP_OR_PTP || |
| 102 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM || | 102 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM || |
| 103 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM); | 103 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM); |
| 104 if (!FindRemovableStorageLocationById(*it).empty()) | 104 if (FindRemovableStorageLocationById(*it).empty()) |
| 105 missing_devices.insert(*it); | 105 missing_devices.insert(*it); |
| 106 } | 106 } |
| 107 | 107 |
| 108 for (MediaStorageUtil::DeviceIdSet::const_iterator it = | 108 for (MediaStorageUtil::DeviceIdSet::const_iterator it = |
| 109 missing_devices.begin(); | 109 missing_devices.begin(); |
| 110 it != missing_devices.end(); | 110 it != missing_devices.end(); |
| 111 ++it) { | 111 ++it) { |
| 112 devices->erase(*it); | 112 devices->erase(*it); |
| 113 } | 113 } |
| 114 } | 114 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return false; | 228 return false; |
| 229 | 229 |
| 230 if (g_test_get_device_info_from_path_function) { | 230 if (g_test_get_device_info_from_path_function) { |
| 231 return g_test_get_device_info_from_path_function(path, device_id, | 231 return g_test_get_device_info_from_path_function(path, device_id, |
| 232 device_name, | 232 device_name, |
| 233 relative_path); | 233 relative_path); |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool found_device = false; | 236 bool found_device = false; |
| 237 base::SystemMonitor::RemovableStorageInfo device_info; | 237 base::SystemMonitor::RemovableStorageInfo device_info; |
| 238 #if (defined(OS_LINUX) || defined(OS_MACOSX)) && !defined(OS_CHROMEOS) | 238 #if (defined(OS_LINUX) || defined(OS_MACOSX)) |
| 239 RemovableDeviceNotifications* notifier = | 239 RemovableDeviceNotifications* notifier = |
| 240 RemovableDeviceNotifications::GetInstance(); | 240 RemovableDeviceNotifications::GetInstance(); |
| 241 found_device = notifier->GetDeviceInfoForPath(path, &device_info); | 241 found_device = notifier->GetDeviceInfoForPath(path, &device_info); |
| 242 #endif | 242 #endif |
| 243 | 243 |
| 244 #if 0 && defined(OS_CHROMEOS) | 244 #if defined(OS_CHROMEOS) |
| 245 if (!found_device) { | 245 if (!found_device) { |
| 246 MediaTransferProtocolDeviceObserver* mtp_manager = | 246 chromeos::mtp::MediaTransferProtocolDeviceObserverCros* mtp_manager = |
| 247 MediaTransferProtocolDeviceObserver::GetInstance(); | 247 chromeos::mtp::MediaTransferProtocolDeviceObserverCros::GetInstance(); |
| 248 found_device = mtp_manager->GetStorageInfoForPath(path, &device_info); | 248 found_device = mtp_manager->GetStorageInfoForPath(path, &device_info); |
| 249 } | 249 } |
| 250 #endif | 250 #endif |
| 251 | 251 |
| 252 if (found_device && IsRemovableDevice(device_info.device_id)) { | 252 if (found_device && IsRemovableDevice(device_info.device_id)) { |
| 253 if (device_id) | 253 if (device_id) |
| 254 *device_id = device_info.device_id; | 254 *device_id = device_info.device_id; |
| 255 if (device_name) | 255 if (device_name) |
| 256 *device_name = device_info.name; | 256 *device_name = device_info.name; |
| 257 if (relative_path) { | 257 if (relative_path) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 314 |
| 315 // static | 315 // static |
| 316 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( | 316 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( |
| 317 GetDeviceInfoFromPathFunction function) { | 317 GetDeviceInfoFromPathFunction function) { |
| 318 g_test_get_device_info_from_path_function = function; | 318 g_test_get_device_info_from_path_function = function; |
| 319 } | 319 } |
| 320 | 320 |
| 321 MediaStorageUtil::MediaStorageUtil() {} | 321 MediaStorageUtil::MediaStorageUtil() {} |
| 322 | 322 |
| 323 } // namespace chrome | 323 } // namespace chrome |
| OLD | NEW |