Chromium Code Reviews| Index: chrome/utility/media_galleries/iphoto_library_parser.cc |
| diff --git a/chrome/utility/media_galleries/iphoto_library_parser.cc b/chrome/utility/media_galleries/iphoto_library_parser.cc |
| index 011bf007007e981f38cfdf206e9049bd7c0fee03..d723f47ce04f11f6e6ad2f4f114aa5014d9e588e 100644 |
| --- a/chrome/utility/media_galleries/iphoto_library_parser.cc |
| +++ b/chrome/utility/media_galleries/iphoto_library_parser.cc |
| @@ -21,6 +21,8 @@ struct PhotoInfo { |
| uint64 id; |
| std::string guid; |
| base::FilePath location; |
| + base::FilePath original_location; |
| + base::Time time; |
| std::string type; |
| }; |
| @@ -43,11 +45,8 @@ bool GetPhotoInfoFromDict(XmlReader* reader, PhotoInfo* result) { |
| if (!reader->Read()) |
| return false; |
| - bool found_guid = false; |
| bool found_location = false; |
| - bool found_type = false; |
| - while (reader->Depth() >= dict_content_depth && |
| - !(found_guid && found_location && found_type)) { |
| + while (reader->Depth() >= dict_content_depth) { |
| if (!iapps::SeekToNodeAtCurrentDepth(reader, "key")) |
| break; |
| std::string found_key; |
| @@ -56,17 +55,11 @@ bool GetPhotoInfoFromDict(XmlReader* reader, PhotoInfo* result) { |
| DCHECK_EQ(dict_content_depth, reader->Depth()); |
| if (found_key == "GUID") { |
| - if (found_guid) |
| - break; |
| if (!iapps::ReadString(reader, &result->guid)) |
| break; |
| - found_guid = true; |
| } else if (found_key == "MediaType") { |
| - if (found_type) |
| - break; |
| if (!iapps::ReadString(reader, &result->type)) |
| break; |
| - found_type = true; |
| } else if (found_key == "ImagePath") { |
| if (found_location) |
| break; |
| @@ -75,6 +68,20 @@ bool GetPhotoInfoFromDict(XmlReader* reader, PhotoInfo* result) { |
| break; |
| result->location = base::FilePath(value); |
| found_location = true; |
| + } else if (found_key == "OriginalPath") { |
| + std::string value; |
| + if (!iapps::ReadString(reader, &value)) |
| + break; |
| + result->original_location = base::FilePath(value); |
| + } else if (found_key == "DateAsTimerIntervalGMT") { |
| + std::string value; |
| + if (!iapps::ReadString(reader, &value)) |
| + break; |
| + double time_double = 0.0; |
| + if (!base::StringToDouble(value, &time_double)) |
| + break; |
| + // Add offset from Mac time (2001-based) to 1970-based. |
| + result->time = base::Time::FromDoubleT(time_double + 978307200.0); |
| } else { |
| if (!iapps::SkipToNextElement(reader)) |
| break; |
| @@ -229,7 +236,8 @@ bool ParseAllPhotos(XmlReader* reader, |
| break; |
| } |
| - parser::Photo photo(photo_info.id, photo_info.location); |
| + parser::Photo photo(photo_info.id, photo_info.location, |
| + photo_info.original_location, photo_info.time); |
| all_photos->insert(photo); |
| } |
| @@ -286,10 +294,15 @@ bool IPhotoLibraryParser::Parse(const std::string& library_xml) { |
| if (GetAlbumInfoFromDict(&reader, &album_info)) { |
| parser::Album album; |
| album = album_info.photo_ids; |
| - // Strip / from album name. |
| + // Strip / from album name and dedupe any collisions. |
| std::string name; |
| ReplaceChars(album_info.name, "//", " ", &name); |
| - library_.albums[name] = album; |
| + if (!ContainsKey(library_.albums, name)) { |
| + library_.albums[name] = album; |
|
vandebo (ex-Chrome)
2013/10/31 20:53:43
So first in the xml file wins? Maybe we should tr
Greg Billock
2013/10/31 22:34:24
Sounds good.
vandebo (ex-Chrome)
2013/11/01 18:50:33
Should we keep a separate list of dup album names
|
| + } else { |
| + library_.albums[name+"("+base::Uint64ToString(album_info.id)+")"] = |
|
vandebo (ex-Chrome)
2013/10/31 20:53:43
Date might be a more useful uniquifier, is there a
Greg Billock
2013/10/31 22:34:24
No, there's no real good signal. There's a GUID, a
|
| + album; |
| + } |
| } |
| } |
| } else if (found_key == "Master Image List") { |