OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Linux specific implementation of chrome::MediaStorageUtil. | |
6 | |
7 #include "chrome/browser/system_monitor/media_storage_util.h" | |
8 | |
9 #include "base/callback.h" | |
10 #include "base/system_monitor/system_monitor.h" | |
11 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" | |
12 | |
13 namespace chrome { | |
14 | |
15 // static | |
16 bool MediaStorageUtil::GetDeviceInfoFromPathImpl(const FilePath& path, | |
17 std::string* device_id, | |
18 string16* device_name, | |
19 FilePath* relative_path) { | |
20 RemovableDeviceNotificationsLinux* device_tracker = | |
21 RemovableDeviceNotificationsLinux::GetInstance(); | |
22 DCHECK(device_tracker); | |
23 base::SystemMonitor::RemovableStorageInfo device_info; | |
24 bool found_device = device_tracker->GetDeviceInfoForPath(path, &device_info); | |
25 | |
26 if (found_device && IsRemovableDevice(device_info.device_id)) { | |
27 if (device_id) | |
28 *device_id = device_info.device_id; | |
29 if (device_name) | |
30 *device_name = device_info.name; | |
31 if (relative_path) { | |
32 *relative_path = FilePath(); | |
33 FilePath mount_point(device_info.location); | |
34 mount_point.AppendRelativePath(path, relative_path); | |
35 } | |
36 return true; | |
37 } | |
38 | |
39 if (device_id) | |
40 *device_id = MakeDeviceId(FIXED_MASS_STORAGE, path.AsUTF8Unsafe()); | |
41 if (device_name) | |
42 *device_name = path.BaseName().LossyDisplayName(); | |
43 if (relative_path) | |
44 *relative_path = FilePath(); | |
45 return true; | |
46 } | |
47 | |
48 } // namespace chrome | |
OLD | NEW |