OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/utility/media_galleries/picasa_albums_indexer.h" | 5 #include "chrome/utility/media_galleries/picasa_albums_indexer.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/ini_parser.h" | 9 #include "base/ini_parser.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // [.album:*] sections ignored as we get that data from the PMP files. | 36 // [.album:*] sections ignored as we get that data from the PMP files. |
37 if (section.find(kAlbumSectionHeader) == 0) | 37 if (section.find(kAlbumSectionHeader) == 0) |
38 return; | 38 return; |
39 | 39 |
40 std::vector<std::string> containing_albums; | 40 std::vector<std::string> containing_albums; |
41 base::SplitString(value, ',', &containing_albums); | 41 base::SplitString(value, ',', &containing_albums); |
42 for (std::vector<std::string>::iterator it = containing_albums.begin(); | 42 for (std::vector<std::string>::iterator it = containing_albums.begin(); |
43 it != containing_albums.end(); ++it) { | 43 it != containing_albums.end(); ++it) { |
44 AlbumImagesMap::iterator album_map_it = albums_images_->find(*it); | 44 AlbumImagesMap::iterator album_map_it = albums_images_->find(*it); |
45 | 45 |
46 // Ignore entry if the album UUID is not listed among in |album_uuids| | 46 // Ignore entry if the album uid is not listed among in |album_uids| |
47 // in the constructor. Happens if the PMP and INI files are inconsistent. | 47 // in the constructor. Happens if the PMP and INI files are inconsistent. |
48 if (album_map_it == albums_images_->end()) | 48 if (album_map_it == albums_images_->end()) |
49 continue; | 49 continue; |
50 | 50 |
51 album_map_it->second.insert( | 51 album_map_it->second.insert( |
52 folder_path_.Append(base::FilePath::FromUTF8Unsafe(section))); | 52 folder_path_.Append(base::FilePath::FromUTF8Unsafe(section))); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 const base::FilePath folder_path_; | 56 const base::FilePath folder_path_; |
57 AlbumImagesMap* const albums_images_; | 57 AlbumImagesMap* const albums_images_; |
58 }; | 58 }; |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 PicasaAlbumsIndexer::PicasaAlbumsIndexer( | 62 PicasaAlbumsIndexer::PicasaAlbumsIndexer(const AlbumUIDSet& album_uids) { |
63 const AlbumUUIDSet& album_uuids) { | 63 // Create an entry in the map for the valid album uids. |
64 // Create an entry in the map for the valid album uuids. | 64 for (AlbumUIDSet::const_iterator it = album_uids.begin(); |
65 for (AlbumUUIDSet::const_iterator it = album_uuids.begin(); | 65 it != album_uids.end(); ++it) { |
66 it != album_uuids.end(); ++it) { | |
67 albums_images_[*it] = AlbumImages(); | 66 albums_images_[*it] = AlbumImages(); |
68 } | 67 } |
69 } | 68 } |
70 | 69 |
71 PicasaAlbumsIndexer::~PicasaAlbumsIndexer() {} | 70 PicasaAlbumsIndexer::~PicasaAlbumsIndexer() {} |
72 | 71 |
73 void PicasaAlbumsIndexer::ParseFolderINI( | 72 void PicasaAlbumsIndexer::ParseFolderINI( |
74 const base::FilePath& folder_path, const std::string& ini_contents) { | 73 const base::FilePath& folder_path, const std::string& ini_contents) { |
75 PicasaINIParser parser(folder_path, &albums_images_); | 74 PicasaINIParser parser(folder_path, &albums_images_); |
76 parser.Parse(ini_contents); | 75 parser.Parse(ini_contents); |
77 } | 76 } |
78 | 77 |
79 } // namespace picasa | 78 } // namespace picasa |
OLD | NEW |