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

Unified Diff: chrome/browser/media_galleries/win/mtp_device_operations_util.cc

Issue 195813008: Media Galleries: Properly retrieve file names on MTP devices on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698