Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: chrome/browser/system_monitor/media_storage_util.cc

Issue 10911234: Update Windows System Monitor Removable Device Impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_CHROMEOS)
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 0 && defined(OS_CHROMEOS)
231 if (!found_device) { 231 if (!found_device) {
232 MediaTransferProtocolDeviceObserver* mtp_manager = 232 MediaTransferProtocolDeviceObserver* mtp_manager =
233 MediaTransferProtocolDeviceObserver::GetInstance(); 233 MediaTransferProtocolDeviceObserver::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) {
244 *relative_path = FilePath(); 244 *relative_path = FilePath();
245 FilePath mount_point(device_info.location); 245 FilePath mount_point(device_info.location);
246 mount_point.AppendRelativePath(path, relative_path); 246 mount_point.AppendRelativePath(path, relative_path);
247 } 247 }
248 return true; 248 return true;
249 } 249 }
250 250
251 // On Posix systems, there's one root so any absolute path could be valid.
252 #if !defined(POSIX)
Lei Zhang 2012/09/18 00:06:26 OS_POSIX
vandebo (ex-Chrome) 2012/09/18 00:16:21 Done.
253 if (!found_device)
254 return false;
255 #endif
256
251 if (device_id) 257 if (device_id)
252 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); 258 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe());
253 if (device_name) 259 if (device_name)
254 *device_name = path.BaseName().LossyDisplayName(); 260 *device_name = path.BaseName().LossyDisplayName();
255 if (relative_path) 261 if (relative_path)
256 *relative_path = FilePath(); 262 *relative_path = FilePath();
257 return true; 263 return true;
258 } 264 }
259 265
260 // static 266 // static
(...skipping 16 matching lines...) Expand all
277 283
278 // static 284 // static
279 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( 285 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting(
280 GetDeviceInfoFromPathFunction function) { 286 GetDeviceInfoFromPathFunction function) {
281 g_test_get_device_info_from_path_function = function; 287 g_test_get_device_info_from_path_function = function;
282 } 288 }
283 289
284 MediaStorageUtil::MediaStorageUtil() {} 290 MediaStorageUtil::MediaStorageUtil() {}
285 291
286 } // namespace chrome 292 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698