| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 if (type == MediaStorageUtil::FIXED_MASS_STORAGE) { | 81 if (type == MediaStorageUtil::FIXED_MASS_STORAGE) { |
| 82 if (!file_util::PathExists(FilePath::FromUTF8Unsafe(unique_id))) | 82 if (!file_util::PathExists(FilePath::FromUTF8Unsafe(unique_id))) |
| 83 missing_devices.insert(*it); | 83 missing_devices.insert(*it); |
| 84 continue; | 84 continue; |
| 85 } | 85 } |
| 86 | 86 |
| 87 DCHECK(type == MediaStorageUtil::MTP_OR_PTP || | 87 DCHECK(type == MediaStorageUtil::MTP_OR_PTP || |
| 88 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM || | 88 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM || |
| 89 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM); | 89 type == MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM); |
| 90 if (!FindRemovableStorageLocationById(*it).empty()) | 90 if (FindRemovableStorageLocationById(*it).empty()) |
| 91 missing_devices.insert(*it); | 91 missing_devices.insert(*it); |
| 92 } | 92 } |
| 93 | 93 |
| 94 for (MediaStorageUtil::DeviceIdSet::const_iterator it = | 94 for (MediaStorageUtil::DeviceIdSet::const_iterator it = |
| 95 missing_devices.begin(); | 95 missing_devices.begin(); |
| 96 it != missing_devices.end(); | 96 it != missing_devices.end(); |
| 97 ++it) { | 97 ++it) { |
| 98 devices->erase(*it); | 98 devices->erase(*it); |
| 99 } | 99 } |
| 100 } | 100 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return false; | 214 return false; |
| 215 | 215 |
| 216 if (g_test_get_device_info_from_path_function) { | 216 if (g_test_get_device_info_from_path_function) { |
| 217 return g_test_get_device_info_from_path_function(path, device_id, | 217 return g_test_get_device_info_from_path_function(path, device_id, |
| 218 device_name, | 218 device_name, |
| 219 relative_path); | 219 relative_path); |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool found_device = false; | 222 bool found_device = false; |
| 223 base::SystemMonitor::RemovableStorageInfo device_info; | 223 base::SystemMonitor::RemovableStorageInfo device_info; |
| 224 #if (defined(OS_LINUX) || defined(OS_MACOSX)) && !defined(OS_CHROMEOS) | 224 #if (defined(OS_LINUX) || defined(OS_MACOSX)) |
| 225 RemovableDeviceNotifications* notifier = | 225 RemovableDeviceNotifications* notifier = |
| 226 RemovableDeviceNotifications::GetInstance(); | 226 RemovableDeviceNotifications::GetInstance(); |
| 227 found_device = notifier->GetDeviceInfoForPath(path, &device_info); | 227 found_device = notifier->GetDeviceInfoForPath(path, &device_info); |
| 228 #endif | 228 #endif |
| 229 | 229 |
| 230 #if 0 && defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
| 231 if (!found_device) { | 231 if (!found_device) { |
| 232 MediaTransferProtocolDeviceObserver* mtp_manager = | 232 chromeos::mtp::MediaTransferProtocolDeviceObserverCros* mtp_manager = |
| 233 MediaTransferProtocolDeviceObserver::GetInstance(); | 233 chromeos::mtp::MediaTransferProtocolDeviceObserverCros::GetInstance(); |
| 234 found_device = mtp_manager->GetStorageInfoForPath(path, &device_info); | 234 found_device = mtp_manager->GetStorageInfoForPath(path, &device_info); |
| 235 } | 235 } |
| 236 #endif | 236 #endif |
| 237 | 237 |
| 238 if (found_device && IsRemovableDevice(device_info.device_id)) { | 238 if (found_device && IsRemovableDevice(device_info.device_id)) { |
| 239 if (device_id) | 239 if (device_id) |
| 240 *device_id = device_info.device_id; | 240 *device_id = device_info.device_id; |
| 241 if (device_name) | 241 if (device_name) |
| 242 *device_name = device_info.name; | 242 *device_name = device_info.name; |
| 243 if (relative_path) { | 243 if (relative_path) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 277 |
| 278 // static | 278 // static |
| 279 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( | 279 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( |
| 280 GetDeviceInfoFromPathFunction function) { | 280 GetDeviceInfoFromPathFunction function) { |
| 281 g_test_get_device_info_from_path_function = function; | 281 g_test_get_device_info_from_path_function = function; |
| 282 } | 282 } |
| 283 | 283 |
| 284 MediaStorageUtil::MediaStorageUtil() {} | 284 MediaStorageUtil::MediaStorageUtil() {} |
| 285 | 285 |
| 286 } // namespace chrome | 286 } // namespace chrome |
| OLD | NEW |