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/browser/media_galleries/fileapi/itunes_data_provider.h" | 5 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "third_party/icu/source/common/unicode/locid.h" | 24 #include "third_party/icu/source/common/unicode/locid.h" |
25 #include "webkit/browser/fileapi/native_file_util.h" | 25 #include "webkit/browser/fileapi/native_file_util.h" |
26 | 26 |
27 namespace itunes { | 27 namespace itunes { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Colon and slash are not allowed in filenames, replace them with underscore. | 31 // Colon and slash are not allowed in filenames, replace them with underscore. |
32 std::string EscapeBadCharacters(const std::string& input) { | 32 std::string EscapeBadCharacters(const std::string& input) { |
33 std::string result; | 33 std::string result; |
34 ReplaceChars(input, ":/", "_", &result); | 34 base::ReplaceChars(input, ":/", "_", &result); |
35 return result; | 35 return result; |
36 } | 36 } |
37 | 37 |
38 ITunesDataProvider::Album MakeUniqueTrackNames(const parser::Album& album) { | 38 ITunesDataProvider::Album MakeUniqueTrackNames(const parser::Album& album) { |
39 // TODO(vandebo): It would be nice to ensure that names returned from here | 39 // TODO(vandebo): It would be nice to ensure that names returned from here |
40 // are stable, but aside from persisting every name returned, it's not | 40 // are stable, but aside from persisting every name returned, it's not |
41 // obvious how to do that (without including the track id in every name). | 41 // obvious how to do that (without including the track id in every name). |
42 typedef std::set<const parser::Track*> TrackRefs; | 42 typedef std::set<const parser::Track*> TrackRefs; |
43 typedef std::map<ITunesDataProvider::TrackName, TrackRefs> AlbumInfo; | 43 typedef std::map<ITunesDataProvider::TrackName, TrackRefs> AlbumInfo; |
44 | 44 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 std::string album_name = EscapeBadCharacters(album_it->first); | 294 std::string album_name = EscapeBadCharacters(album_it->first); |
295 library_[artist_name][album_name] = | 295 library_[artist_name][album_name] = |
296 MakeUniqueTrackNames(album_it->second); | 296 MakeUniqueTrackNames(album_it->second); |
297 } | 297 } |
298 } | 298 } |
299 } | 299 } |
300 ready_callback.Run(valid()); | 300 ready_callback.Run(valid()); |
301 } | 301 } |
302 | 302 |
303 } // namespace itunes | 303 } // namespace itunes |
OLD | NEW |