Chromium Code Reviews| 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/string16.h" | |
| 8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | |
| 9 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 10 | 12 |
| 11 namespace { | 13 namespace { |
| 12 | 14 |
| 13 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 14 const wchar_t kDCIMDirName[] = L"DCIM"; | 16 const wchar_t kDCIMDirName[] = L"DCIM"; |
| 15 #else | 17 #else |
| 16 const char kDCIMDirName[] = "DCIM"; | 18 const char kDCIMDirName[] = "DCIM"; |
| 17 #endif | 19 #endif |
| 18 | 20 |
| 19 } // namespace | 21 } // namespace |
| 20 | 22 |
| 21 namespace chrome { | 23 namespace chrome { |
| 22 | 24 |
| 23 bool IsMediaDevice(const FilePath::StringType& mount_point) { | 25 bool IsMediaDevice(const FilePath::StringType& mount_point) { |
| 24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 25 | 27 |
| 26 FilePath dcim_path(mount_point); | 28 FilePath dcim_path(mount_point); |
| 27 FilePath::StringType dcim_dir = kDCIMDirName; | 29 FilePath::StringType dcim_dir = kDCIMDirName; |
| 28 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) { | 30 if (!file_util::DirectoryExists(dcim_path.Append(dcim_dir))) { |
| 29 // Check for lowercase 'dcim' as well. | 31 // Check for lowercase 'dcim' as well. |
| 30 FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir))); | 32 FilePath dcim_path_lower(dcim_path.Append(StringToLowerASCII(dcim_dir))); |
| 31 if (!file_util::DirectoryExists(dcim_path_lower)) | 33 if (!file_util::DirectoryExists(dcim_path_lower)) |
| 32 return false; | 34 return false; |
| 33 } | 35 } |
| 34 return true; | 36 return true; |
| 35 } | 37 } |
| 36 | 38 |
| 39 std::string GetDeviceManufacturerName(const std::string& vendor_name, | |
| 40 const std::string& model_name) { | |
| 41 if (!vendor_name.empty() && !model_name.empty()) | |
|
Lei Zhang
2012/11/12 07:46:56
Do you think this will be a little better?
if (ve
kmadhusu
2012/11/12 19:56:56
Sure. I tried to avoid the temp variable "product_
| |
| 42 return "(" + vendor_name + ", " + model_name + ")"; | |
| 43 else if (!vendor_name.empty()) | |
| 44 return "(" + vendor_name + ")"; | |
| 45 else if (!model_name.empty()) | |
| 46 return "(" + model_name + ")"; | |
| 47 else | |
| 48 return std::string(); | |
| 49 } | |
| 50 | |
| 51 string16 GetDisplayNameForDevice(const string16& device_partition_size, | |
| 52 const string16& name) { | |
| 53 DCHECK(!name.empty()); | |
| 54 return device_partition_size.empty() ? | |
| 55 name : device_partition_size + ASCIIToUTF16(" ") + name; | |
| 56 } | |
| 57 | |
| 37 } // namespace chrome | 58 } // namespace chrome |
| OLD | NEW |