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

Side by Side Diff: chrome/browser/storage_monitor/media_device_notifications_utils.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 unified diff | Download patch
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 #include "chrome/browser/storage_monitor/media_device_notifications_utils.h"
6
7 #include "base/file_util.h"
8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/storage_monitor/removable_device_constants.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "ui/base/text/bytes_formatting.h"
13
14 namespace chrome {
15
16 bool IsMediaDevice(const base::FilePath::StringType& mount_point) {
17 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
18
19 base::FilePath dcim_path(mount_point);
20 base::FilePath::StringType dcim_dir(kDCIMDirectoryName);
21 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) {
22 // Check for lowercase 'dcim' as well.
23 base::FilePath dcim_path_lower(
24 dcim_path.Append(StringToLowerASCII(dcim_dir)));
25 if (!file_util::DirectoryExists(dcim_path_lower))
26 return false;
27 }
28 return true;
29 }
30
31 string16 GetFullProductName(const std::string& vendor_name,
32 const std::string& model_name) {
33 if (vendor_name.empty() && model_name.empty())
34 return string16();
35
36 std::string product_name;
37 if (vendor_name.empty())
38 product_name = model_name;
39 else if (model_name.empty())
40 product_name = vendor_name;
41 else
42 product_name = vendor_name + ", " + model_name;
43 return IsStringUTF8(product_name) ?
44 UTF8ToUTF16("(" + product_name + ")") : string16();
45 }
46
47 string16 GetDisplayNameForDevice(uint64 storage_size_in_bytes,
48 const string16& name) {
49 DCHECK(!name.empty());
50 return (storage_size_in_bytes == 0) ?
51 name : ui::FormatBytes(storage_size_in_bytes) + ASCIIToUTF16(" ") + name;
52 }
53
54 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698