Index: chrome/browser/media_galleries/win/mtp_device_operations_util.cc |
diff --git a/chrome/browser/media_galleries/win/mtp_device_operations_util.cc b/chrome/browser/media_galleries/win/mtp_device_operations_util.cc |
index 8b03b109f6dc9868befc0cb04280e7301c131926..5027f00f9ec61ac1570982ce10fd0f74ff4e7fc9 100644 |
--- a/chrome/browser/media_galleries/win/mtp_device_operations_util.cc |
+++ b/chrome/browser/media_galleries/win/mtp_device_operations_util.cc |
@@ -131,6 +131,18 @@ bool GetLastModifiedTime(IPortableDeviceValues* properties_values, |
return false; |
bool last_modified_time_set = (last_modified_date.get().vt == VT_DATE); |
+ |
+ // Some PTP devices don't provide an mtime. Try using the ctime instead. |
Lei Zhang
2014/06/18 00:54:26
s/an mtime/a mtime/
tommycli
2014/06/18 16:28:50
I think "an" for vowel sounds?
|
+ if (!last_modified_time_set) { |
+ last_modified_date.Reset(); |
+ HRESULT hr = properties_values->GetValue(WPD_OBJECT_DATE_CREATED, |
+ last_modified_date.Receive()); |
+ if (FAILED(hr)) |
+ return false; |
+ |
+ last_modified_time_set = (last_modified_date.get().vt == VT_DATE); |
+ } |
+ |
if (last_modified_time_set) { |
SYSTEMTIME system_time; |
FILETIME file_time; |
@@ -161,7 +173,8 @@ bool GetObjectSize(IPortableDeviceValues* properties_values, int64* size) { |
// Gets the details of the object specified by the |object_id| given the media |
// transfer protocol |device|. On success, returns true and fills in |name|, |
-// |is_directory|, |size| and |last_modified_time|. |
+// |is_directory|, |size|. |last_modified_time| will be filled in if possible, |
+// but failure to get it doesn't prevent success. |
bool GetObjectDetails(IPortableDevice* device, |
const base::string16 object_id, |
base::string16* name, |
@@ -197,6 +210,7 @@ bool GetObjectDetails(IPortableDevice* device, |
FAILED(properties_to_read->Add(WPD_OBJECT_ORIGINAL_FILE_NAME)) || |
FAILED(properties_to_read->Add(WPD_OBJECT_NAME)) || |
FAILED(properties_to_read->Add(WPD_OBJECT_DATE_MODIFIED)) || |
+ FAILED(properties_to_read->Add(WPD_OBJECT_DATE_CREATED)) || |
FAILED(properties_to_read->Add(WPD_OBJECT_SIZE))) |
return false; |
@@ -219,8 +233,11 @@ bool GetObjectDetails(IPortableDevice* device, |
*last_modified_time = base::Time(); |
return true; |
} |
- return (GetObjectSize(properties_values.get(), size) && |
- GetLastModifiedTime(properties_values.get(), last_modified_time)); |
+ |
+ // Try to get the last modified time, but don't fail if we can't. |
+ GetLastModifiedTime(properties_values.get(), last_modified_time); |
Lei Zhang
2014/06/18 00:54:26
This is the only caller. Just change the return ty
tommycli
2014/06/18 16:28:50
Done. I also changed the method's flow a bit since
|
+ |
+ return GetObjectSize(properties_values.get(), size); |
} |
// Creates an MTP device object entry for the given |device| and |object_id|. |