OLD | NEW |
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" | |
10 #include "chrome/browser/system_monitor/removable_device_constants.h" | 9 #include "chrome/browser/system_monitor/removable_device_constants.h" |
11 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
12 #include "ui/base/text/bytes_formatting.h" | |
13 | 11 |
14 namespace chrome { | 12 namespace chrome { |
15 | 13 |
16 bool IsMediaDevice(const FilePath::StringType& mount_point) { | 14 bool IsMediaDevice(const FilePath::StringType& mount_point) { |
17 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 15 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
18 | 16 |
19 FilePath dcim_path(mount_point); | 17 FilePath dcim_path(mount_point); |
20 FilePath::StringType dcim_dir(kDCIMDirectoryName); | 18 FilePath::StringType dcim_dir(kDCIMDirectoryName); |
21 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) { | 19 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) { |
22 // Check for lowercase 'dcim' as well. | 20 // Check for lowercase 'dcim' as well. |
23 FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir))); | 21 FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir))); |
24 if (!file_util::DirectoryExists(dcim_path_lower)) | 22 if (!file_util::DirectoryExists(dcim_path_lower)) |
25 return false; | 23 return false; |
26 } | 24 } |
27 return true; | 25 return true; |
28 } | 26 } |
29 | 27 |
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 | |
53 } // namespace chrome | 28 } // namespace chrome |
OLD | NEW |