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

Unified Diff: chrome/browser/storage_monitor/media_storage_util.cc

Issue 12544005: Consolidate storage_monitor/MediaDeviceNotificationsUtils into MediaStorageUtil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac apply patch Created 7 years, 9 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/storage_monitor/media_storage_util.cc
diff --git a/chrome/browser/storage_monitor/media_storage_util.cc b/chrome/browser/storage_monitor/media_storage_util.cc
index b937ba5da800f2eeac8d01e2cda7f28426831023..b1e11a5589dedb073456e39ac606cbe8c2a44408 100644
--- a/chrome/browser/storage_monitor/media_storage_util.cc
+++ b/chrome/browser/storage_monitor/media_storage_util.cc
@@ -10,10 +10,12 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/storage_monitor/media_device_notifications_utils.h"
+#include "chrome/browser/storage_monitor/removable_device_constants.h"
#include "chrome/browser/storage_monitor/storage_monitor.h"
#include "content/public/browser/browser_thread.h"
+#include "ui/base/text/bytes_formatting.h"
#if defined(OS_LINUX) // Implies OS_CHROMEOS
#include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.h"
@@ -126,6 +128,47 @@ string16 GetDisplayNameForSubFolder(const string16& device_name,
} // namespace
// static
+bool MediaStorageUtil::HasDcim(const base::FilePath::StringType& mount_point) {
+ DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ base::FilePath dcim_path(mount_point);
+ base::FilePath::StringType dcim_dir(kDCIMDirectoryName);
+ if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) {
+ // Check for lowercase 'dcim' as well.
+ base::FilePath dcim_path_lower(
+ dcim_path.Append(StringToLowerASCII(dcim_dir)));
+ if (!file_util::DirectoryExists(dcim_path_lower))
+ return false;
+ }
+ return true;
+}
+
+// static
+string16 MediaStorageUtil::GetFullProductName(const std::string& vendor_name,
+ const std::string& model_name) {
+ if (vendor_name.empty() && model_name.empty())
+ return string16();
+
+ std::string product_name;
+ if (vendor_name.empty())
+ product_name = model_name;
+ else if (model_name.empty())
+ product_name = vendor_name;
+ else
+ product_name = vendor_name + ", " + model_name;
+ return IsStringUTF8(product_name) ?
+ UTF8ToUTF16("(" + product_name + ")") : string16();
+}
+
+// static
+string16 MediaStorageUtil::GetDisplayNameForDevice(uint64 storage_size_in_bytes,
+ const string16& name) {
+ DCHECK(!name.empty());
+ return (storage_size_in_bytes == 0) ?
+ name : ui::FormatBytes(storage_size_in_bytes) + ASCIIToUTF16(" ") + name;
+}
+
+// static
std::string MediaStorageUtil::MakeDeviceId(Type type,
const std::string& unique_id) {
DCHECK(!unique_id.empty());
« no previous file with comments | « chrome/browser/storage_monitor/media_storage_util.h ('k') | chrome/browser/storage_monitor/media_storage_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698