| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 DCHECK(!locale_string.empty()); | 89 DCHECK(!locale_string.empty()); |
| 90 DCHECK(result_path); | 90 DCHECK(result_path); |
| 91 | 91 |
| 92 std::map<std::string, std::string>::const_iterator it = | 92 std::map<std::string, std::string>::const_iterator it = |
| 93 localized_dir_names.find(locale_string); | 93 localized_dir_names.find(locale_string); |
| 94 if (it == localized_dir_names.end()) | 94 if (it == localized_dir_names.end()) |
| 95 return false; | 95 return false; |
| 96 | 96 |
| 97 base::FilePath localized_auto_add_path = | 97 base::FilePath localized_auto_add_path = |
| 98 media_path.Append(base::FilePath::FromUTF8Unsafe(it->second)); | 98 media_path.Append(base::FilePath::FromUTF8Unsafe(it->second)); |
| 99 if (!fileapi::NativeFileUtil::DirectoryExists(localized_auto_add_path)) | 99 if (!storage::NativeFileUtil::DirectoryExists(localized_auto_add_path)) |
| 100 return false; | 100 return false; |
| 101 | 101 |
| 102 *result_path = localized_auto_add_path; | 102 *result_path = localized_auto_add_path; |
| 103 return true; | 103 return true; |
| 104 } | 104 } |
| 105 | 105 |
| 106 // This method is complex because Apple localizes the directory name in versions | 106 // This method is complex because Apple localizes the directory name in versions |
| 107 // of iTunes before 10.6. | 107 // of iTunes before 10.6. |
| 108 base::FilePath GetAutoAddPath(const base::FilePath& library_path) { | 108 base::FilePath GetAutoAddPath(const base::FilePath& library_path) { |
| 109 const char kiTunesMediaDir[] = "iTunes Media"; | 109 const char kiTunesMediaDir[] = "iTunes Media"; |
| 110 base::FilePath media_path = | 110 base::FilePath media_path = |
| 111 library_path.DirName().AppendASCII(kiTunesMediaDir); | 111 library_path.DirName().AppendASCII(kiTunesMediaDir); |
| 112 | 112 |
| 113 // Test 'universal' path first. | 113 // Test 'universal' path first. |
| 114 base::FilePath universal_auto_add_path = | 114 base::FilePath universal_auto_add_path = |
| 115 media_path.AppendASCII("Automatically Add to iTunes.localized"); | 115 media_path.AppendASCII("Automatically Add to iTunes.localized"); |
| 116 if (fileapi::NativeFileUtil::DirectoryExists(universal_auto_add_path)) | 116 if (storage::NativeFileUtil::DirectoryExists(universal_auto_add_path)) |
| 117 return universal_auto_add_path; | 117 return universal_auto_add_path; |
| 118 | 118 |
| 119 // Test user locale. Localized directory names encoded in UTF-8. | 119 // Test user locale. Localized directory names encoded in UTF-8. |
| 120 std::map<std::string, std::string> localized_dir_names; | 120 std::map<std::string, std::string> localized_dir_names; |
| 121 localized_dir_names["nl"] = "Voeg automatisch toe aan iTunes"; | 121 localized_dir_names["nl"] = "Voeg automatisch toe aan iTunes"; |
| 122 localized_dir_names["en"] = "Automatically Add to iTunes"; | 122 localized_dir_names["en"] = "Automatically Add to iTunes"; |
| 123 localized_dir_names["fr"] = "Ajouter automatiquement \xC3\xA0 iTunes"; | 123 localized_dir_names["fr"] = "Ajouter automatiquement \xC3\xA0 iTunes"; |
| 124 localized_dir_names["de"] = "Automatisch zu iTunes hinzuf\xC3\xBCgen"; | 124 localized_dir_names["de"] = "Automatisch zu iTunes hinzuf\xC3\xBCgen"; |
| 125 localized_dir_names["it"] = "Aggiungi automaticamente a iTunes"; | 125 localized_dir_names["it"] = "Aggiungi automaticamente a iTunes"; |
| 126 localized_dir_names["ja"] = "iTunes \xE3\x81\xAB\xE8\x87\xAA\xE5\x8B\x95\xE7" | 126 localized_dir_names["ja"] = "iTunes \xE3\x81\xAB\xE8\x87\xAA\xE5\x8B\x95\xE7" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 std::string album_name = SanitizeName(album_it->first); | 293 std::string album_name = SanitizeName(album_it->first); |
| 294 library_[artist_name][album_name] = | 294 library_[artist_name][album_name] = |
| 295 MakeUniqueTrackNames(album_it->second); | 295 MakeUniqueTrackNames(album_it->second); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 ready_callback.Run(valid()); | 299 ready_callback.Run(valid()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 } // namespace itunes | 302 } // namespace itunes |
| OLD | NEW |