OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/extension_l10n_util.h" | 5 #include "chrome/common/extensions/extension_l10n_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file_enumerator.h" |
13 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
16 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/common/extensions/extension_manifest_constants.h" | 19 #include "chrome/common/extensions/extension_manifest_constants.h" |
19 #include "chrome/common/extensions/extension_file_util.h" | 20 #include "chrome/common/extensions/extension_file_util.h" |
20 #include "chrome/common/extensions/message_bundle.h" | 21 #include "chrome/common/extensions/message_bundle.h" |
21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
22 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 all_fallback_locales->push_back(default_locale); | 280 all_fallback_locales->push_back(default_locale); |
280 } | 281 } |
281 | 282 |
282 bool GetValidLocales(const base::FilePath& locale_path, | 283 bool GetValidLocales(const base::FilePath& locale_path, |
283 std::set<std::string>* valid_locales, | 284 std::set<std::string>* valid_locales, |
284 std::string* error) { | 285 std::string* error) { |
285 std::set<std::string> chrome_locales; | 286 std::set<std::string> chrome_locales; |
286 GetAllLocales(&chrome_locales); | 287 GetAllLocales(&chrome_locales); |
287 | 288 |
288 // Enumerate all supplied locales in the extension. | 289 // Enumerate all supplied locales in the extension. |
289 file_util::FileEnumerator locales(locale_path, | 290 base::FileEnumerator locales(locale_path, |
290 false, | 291 false, |
291 file_util::FileEnumerator::DIRECTORIES); | 292 base::FileEnumerator::DIRECTORIES); |
292 base::FilePath locale_folder; | 293 base::FilePath locale_folder; |
293 while (!(locale_folder = locales.Next()).empty()) { | 294 while (!(locale_folder = locales.Next()).empty()) { |
294 std::string locale_name = locale_folder.BaseName().MaybeAsASCII(); | 295 std::string locale_name = locale_folder.BaseName().MaybeAsASCII(); |
295 if (locale_name.empty()) { | 296 if (locale_name.empty()) { |
296 NOTREACHED(); | 297 NOTREACHED(); |
297 continue; // Not ASCII. | 298 continue; // Not ASCII. |
298 } | 299 } |
299 if (!AddLocale(chrome_locales, | 300 if (!AddLocale(chrome_locales, |
300 locale_folder, | 301 locale_folder, |
301 locale_name, | 302 locale_name, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) | 394 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) |
394 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { | 395 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { |
395 extension_l10n_util::SetProcessLocale(locale); | 396 extension_l10n_util::SetProcessLocale(locale); |
396 } | 397 } |
397 | 398 |
398 ScopedLocaleForTest::~ScopedLocaleForTest() { | 399 ScopedLocaleForTest::~ScopedLocaleForTest() { |
399 extension_l10n_util::SetProcessLocale(locale_); | 400 extension_l10n_util::SetProcessLocale(locale_); |
400 } | 401 } |
401 | 402 |
402 } // namespace extension_l10n_util | 403 } // namespace extension_l10n_util |
OLD | NEW |