Index: chrome/browser/media_galleries/win/mtp_device_operations_util.cc |
=================================================================== |
--- chrome/browser/media_galleries/win/mtp_device_operations_util.cc (revision 256942) |
+++ chrome/browser/media_galleries/win/mtp_device_operations_util.cc (working copy) |
@@ -102,16 +102,16 @@ |
content_type == WPD_CONTENT_TYPE_FUNCTIONAL_OBJECT); |
} |
-// Returns the friendly name of the object from the property key values |
-// specified by the |properties_values|. |
-base::string16 GetObjectName(IPortableDeviceValues* properties_values, |
- bool is_directory) { |
+// Returns the name of the object from |properties_values|. If the object has |
+// no filename, try to use a friendly name instead. e.g. with MTP storage roots. |
+base::string16 GetObjectName(IPortableDeviceValues* properties_values) { |
DCHECK(properties_values); |
+ base::string16 result; |
base::win::ScopedCoMem<base::char16> buffer; |
- REFPROPERTYKEY key = |
- is_directory ? WPD_OBJECT_NAME : WPD_OBJECT_ORIGINAL_FILE_NAME; |
- HRESULT hr = properties_values->GetStringValue(key, &buffer); |
- base::string16 result; |
+ HRESULT hr = properties_values->GetStringValue(WPD_OBJECT_ORIGINAL_FILE_NAME, |
+ &buffer); |
+ if (FAILED(hr)) |
+ hr = properties_values->GetStringValue(WPD_OBJECT_NAME, &buffer); |
if (SUCCEEDED(hr)) |
result.assign(buffer); |
return result; |
@@ -208,7 +208,7 @@ |
return false; |
*is_directory = IsDirectory(properties_values.get()); |
- *name = GetObjectName(properties_values.get(), *is_directory); |
+ *name = GetObjectName(properties_values.get()); |
if (name->empty()) |
return false; |