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

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

Issue 11366144: [Media Gallery][ChromeOS] Improve device media gallery names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" 5 #include "chrome/browser/system_monitor/media_device_notifications_utils.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/system_monitor/removable_device_constants.h" 10 #include "chrome/browser/system_monitor/removable_device_constants.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "ui/base/text/bytes_formatting.h"
11 13
12 namespace chrome { 14 namespace chrome {
13 15
14 bool IsMediaDevice(const FilePath::StringType& mount_point) { 16 bool IsMediaDevice(const FilePath::StringType& mount_point) {
15 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 17 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
16 18
17 FilePath dcim_path(mount_point); 19 FilePath dcim_path(mount_point);
18 FilePath::StringType dcim_dir(kDCIMDirectoryName); 20 FilePath::StringType dcim_dir(kDCIMDirectoryName);
19 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) { 21 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) {
20 // Check for lowercase 'dcim' as well. 22 // Check for lowercase 'dcim' as well.
21 FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir))); 23 FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir)));
22 if (!file_util::DirectoryExists(dcim_path_lower)) 24 if (!file_util::DirectoryExists(dcim_path_lower))
23 return false; 25 return false;
24 } 26 }
25 return true; 27 return true;
26 } 28 }
27 29
30 string16 GetFullProductName(const std::string& vendor_name,
31 const std::string& model_name) {
32 if (vendor_name.empty() && model_name.empty())
33 return string16();
34
35 std::string product_name;
36 if (vendor_name.empty())
37 product_name = model_name;
38 else if (model_name.empty())
39 product_name = vendor_name;
40 else
41 product_name = vendor_name + ", " + model_name;
42 return IsStringUTF8(product_name) ?
43 UTF8ToUTF16("(" + product_name + ")") : string16();
44 }
45
46 string16 GetDisplayNameForDevice(uint64 storage_size_in_bytes,
47 const string16& name) {
48 DCHECK(!name.empty());
49 return (storage_size_in_bytes == 0) ?
50 name : ui::FormatBytes(storage_size_in_bytes) + ASCIIToUTF16(" ") + name;
51 }
52
28 } // namespace chrome 53 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698