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

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

Issue 10918259: [Chrome OS]Implement MediaStorageUtil::GetDeviceInfoForPath function to support media gallery permi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' 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
(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 // Chrome OS specific implementation of chrome::MediaStorageUtil.
6
7 #include "chrome/browser/system_monitor/media_storage_util.h"
8
9 #include "base/file_path.h"
10 #include "base/string16.h"
11 #include "base/system_monitor/system_monitor.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"
14
15 namespace chrome {
16
17 using base::SystemMonitor;
18 using chromeos::mtp::MediaTransferProtocolDeviceObserverCros;
19 using chromeos::RemovableDeviceNotificationsCros;
20
21 // static
22 void MediaStorageUtil::GetDeviceInfoFromPathImpl(const FilePath& path,
23 std::string* device_id,
24 string16* device_name,
25 FilePath* relative_path) {
26 // Check if the |path| belongs to a removable mass storage device.
27 RemovableDeviceNotificationsCros* mass_storage_tracker =
28 RemovableDeviceNotificationsCros::GetInstance();
29 DCHECK(mass_storage_tracker);
30 base::SystemMonitor::RemovableStorageInfo 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 if (!mtp_device_tracker->GetStorageInfoForPath(path, &device_info))
38 return; // No matching device found.
Lei Zhang 2012/09/16 00:17:05 This makes me think GetDeviceInfoFromPath() should
vandebo (ex-Chrome) 2012/09/16 00:31:44 The function can fail, so we should propagate that
kmadhusu 2012/09/16 22:35:42 Done.
kmadhusu 2012/09/16 22:35:42 Modified the function signature to return bool.
39 }
40
41 if (device_id)
42 *device_id = device_info.device_id;
43 if (device_name)
44 *device_name = device_info.name;
45 if (relative_path) {
46 *relative_path = FilePath();
47 FilePath mount_point(device_info.location);
48 mount_point.AppendRelativePath(path, relative_path);
49 }
50 }
51
52 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698