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