Index: chrome/browser/media_gallery/media_storage_util.h |
diff --git a/chrome/browser/media_gallery/media_storage_util.h b/chrome/browser/media_gallery/media_storage_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e6b129a4623733cfaf6c28d203c1362e69c81969 |
--- /dev/null |
+++ b/chrome/browser/media_gallery/media_storage_util.h |
@@ -0,0 +1,81 @@ |
+// 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::MediaStorageUtil provides information about storage devices attached |
+// to the computer. |
+ |
+#ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ |
+#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/callback_forward.h" |
+#include "base/file_path.h" |
+ |
+namespace chrome { |
+ |
+class MediaStorageUtil { |
+ public: |
+ enum Type { |
+ // A USB mass storage device with a DCIM directory. |
+ USB_MASS_STORAGE_WITH_DCIM, |
+ // A USB mass storage device without a DCIM directory. |
+ USB_MASS_STORAGE_NO_DCIM, |
+ // Mass storage not connected through USB - a proxy for fixed/removable. |
+ OTHER_MASS_STORAGE, |
+ // A MTP or PTP device. |
+ USB_MTP, |
+ }; |
+ |
+ typedef base::Callback<void(bool)> BoolCallback; |
+ typedef base::Callback<void(FilePath)> FilePathCallback; |
kmadhusu
2012/08/20 17:13:50
const FilePath&
vandebo (ex-Chrome)
2012/08/20 18:35:14
Both in this case the the one below, the purpose o
|
+ typedef base::Callback<void(std::string /*device id*/, |
kmadhusu
2012/08/20 17:13:50
const std::string&
const FilePath&
|
+ FilePath /*path relative to device root*/, |
+ string16 /*display name*/)> DeviceInfoCallback; |
+ |
+ // Returns a device id given properties of the device. A prefix dependent on |
+ // |type| is added so |unique_id| need only be unique within the given type. |
+ static std::string MakeDeviceId(Type type, const std::string& unique_id); |
+ |
+ // Extracts the device |type| and |unique_id| from |device_id|. |
+ static void CrackDeviceId(const std::string& device_id, |
+ Type* type, std::string* unique_id); |
+ |
+ // Looks inside |device_id| to determine if it is a media device |
+ // (type is USB_MASS_STORAGE_WITH_DCIM or USB_MTP). |
+ static bool IsMediaDevice(const std::string& device_id); |
+ |
+ // Looks inside |device_id| to determine if it is a media device |
+ // (type isn't OTHER_MASS_STORAGE). |
+ static bool IsRemovableDevice(const std::string& device_id); |
+ |
+ // Determines if the device is attached to the computer. |
+ static void IsDeviceAttached(const std::string& device_id, |
+ const BoolCallback& callback); |
+ |
+ // Given |path|, get the device_id, relative path from the root of the |
+ // device, and the device name. |
+ static void GetDeviceInfoFromPath(const FilePath& path, |
+ const DeviceInfoCallback& callback); |
+ |
+ // Get a FilePath for the given |device_id|. If the device isn't connected |
+ // or isn't a mass storage type, the FilePath will be empty. |
+ static void FindDevicePathById(const std::string& device_id, |
+ const FilePathCallback& callback); |
+ |
+ private: |
+ // All methods are static, this class should not be instantiated. |
+ MediaStorageUtil(); |
+ |
+ // A platform specific helper. |
+ static void FindUSBDeviceById(const std::string unique_id, |
+ const FilePathCallback& callback); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); |
+}; |
+ |
+} // namespace chromeos |
kmadhusu
2012/08/20 17:13:50
chromeos => chrome
vandebo (ex-Chrome)
2012/08/20 18:35:14
Done.
|
+ |
+#endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ |