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/itunes_library_parser.h" | 5 #include "chrome/utility/media_galleries/itunes_library_parser.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 base::FilePath location; | 25 base::FilePath location; |
26 std::string artist; | 26 std::string artist; |
27 std::string album; | 27 std::string album; |
28 }; | 28 }; |
29 | 29 |
30 class TrackInfoXmlDictReader : public iapps::XmlDictReader { | 30 class TrackInfoXmlDictReader : public iapps::XmlDictReader { |
31 public: | 31 public: |
32 TrackInfoXmlDictReader(XmlReader* reader, TrackInfo* track_info) : | 32 TrackInfoXmlDictReader(XmlReader* reader, TrackInfo* track_info) : |
33 iapps::XmlDictReader(reader), track_info_(track_info) {} | 33 iapps::XmlDictReader(reader), track_info_(track_info) {} |
34 | 34 |
35 virtual bool ShouldLoop() OVERRIDE { | 35 virtual bool ShouldLoop() override { |
36 return !(Found("Track ID") && Found("Location") && | 36 return !(Found("Track ID") && Found("Location") && |
37 Found("Album Artist") && Found("Album")); | 37 Found("Album Artist") && Found("Album")); |
38 } | 38 } |
39 | 39 |
40 virtual bool HandleKeyImpl(const std::string& key) OVERRIDE { | 40 virtual bool HandleKeyImpl(const std::string& key) override { |
41 if (key == "Track ID") { | 41 if (key == "Track ID") { |
42 return iapps::ReadInteger(reader_, &track_info_->id); | 42 return iapps::ReadInteger(reader_, &track_info_->id); |
43 } else if (key == "Location") { | 43 } else if (key == "Location") { |
44 std::string value; | 44 std::string value; |
45 if (!iapps::ReadString(reader_, &value)) | 45 if (!iapps::ReadString(reader_, &value)) |
46 return false; | 46 return false; |
47 GURL url(value); | 47 GURL url(value); |
48 if (!url.SchemeIsFile()) | 48 if (!url.SchemeIsFile()) |
49 return false; | 49 return false; |
50 url::RawCanonOutputW<1024> decoded_location; | 50 url::RawCanonOutputW<1024> decoded_location; |
(...skipping 17 matching lines...) Expand all Loading... |
68 track_info_->artist.clear(); | 68 track_info_->artist.clear(); |
69 return iapps::ReadString(reader_, &track_info_->artist); | 69 return iapps::ReadString(reader_, &track_info_->artist); |
70 } else if (key == "Album") { | 70 } else if (key == "Album") { |
71 return iapps::ReadString(reader_, &track_info_->album); | 71 return iapps::ReadString(reader_, &track_info_->album); |
72 } else if (!SkipToNext()) { | 72 } else if (!SkipToNext()) { |
73 return false; | 73 return false; |
74 } | 74 } |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 virtual bool FinishedOk() OVERRIDE { | 78 virtual bool FinishedOk() override { |
79 return Found("Track ID") && Found("Location"); | 79 return Found("Track ID") && Found("Location"); |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 TrackInfo* track_info_; | 83 TrackInfo* track_info_; |
84 }; | 84 }; |
85 | 85 |
86 // Walk through a dictionary filling in |result| with track information. Return | 86 // Walk through a dictionary filling in |result| with track information. Return |
87 // true if at least the id and location where found (artist and album may be | 87 // true if at least the id and location where found (artist and album may be |
88 // empty). In either case, the cursor is advanced out of the dictionary. | 88 // empty). In either case, the cursor is advanced out of the dictionary. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 track_found = true; | 155 track_found = true; |
156 } else { | 156 } else { |
157 no_errors = false; | 157 no_errors = false; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 return track_found || no_errors; | 161 return track_found || no_errors; |
162 } | 162 } |
163 | 163 |
164 } // namespace itunes | 164 } // namespace itunes |
OLD | NEW |