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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/system_monitor/media_storage_util_chromeos.cc
diff --git a/chrome/browser/system_monitor/media_storage_util_chromeos.cc b/chrome/browser/system_monitor/media_storage_util_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3464594091b6d86ee87c2d7bf29bc9c18b14ee5f
--- /dev/null
+++ b/chrome/browser/system_monitor/media_storage_util_chromeos.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Chrome OS specific implementation of chrome::MediaStorageUtil.
+
+#include "chrome/browser/system_monitor/media_storage_util.h"
+
+#include "base/file_path.h"
+#include "base/string16.h"
+#include "base/system_monitor/system_monitor.h"
+#include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.h"
+#include "chrome/browser/system_monitor/removable_device_notifications_chromeos.h"
+
+namespace chrome {
+
+using base::SystemMonitor;
+using chromeos::mtp::MediaTransferProtocolDeviceObserverCros;
+using chromeos::RemovableDeviceNotificationsCros;
+
+// static
+void MediaStorageUtil::GetDeviceInfoFromPathImpl(const FilePath& path,
+ std::string* device_id,
+ string16* device_name,
+ FilePath* relative_path) {
+ // Check if the |path| belongs to a removable mass storage device.
+ RemovableDeviceNotificationsCros* mass_storage_tracker =
+ RemovableDeviceNotificationsCros::GetInstance();
+ DCHECK(mass_storage_tracker);
+ base::SystemMonitor::RemovableStorageInfo device_info;
+ bool found_device = mass_storage_tracker->GetDeviceInfoForPath(path,
+ &device_info);
+ if (!found_device) {
+ // Check if the |path| belongs to a mtp storage device.
+ MediaTransferProtocolDeviceObserverCros * mtp_device_tracker =
+ MediaTransferProtocolDeviceObserverCros::GetInstance();
+ if (!mtp_device_tracker->GetStorageInfoForPath(path, &device_info))
+ 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.
+ }
+
+ if (device_id)
+ *device_id = device_info.device_id;
+ if (device_name)
+ *device_name = device_info.name;
+ if (relative_path) {
+ *relative_path = FilePath();
+ FilePath mount_point(device_info.location);
+ mount_point.AppendRelativePath(path, relative_path);
+ }
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698