OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/common/extensions/api/i18n/default_locale_handler.h" | 5 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_enumerator.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/common/extensions/extension_l10n_util.h" | 14 #include "chrome/common/extensions/extension_l10n_util.h" |
14 #include "chrome/common/extensions/extension_manifest_constants.h" | 15 #include "chrome/common/extensions/extension_manifest_constants.h" |
15 #include "chrome/common/extensions/manifest.h" | 16 #include "chrome/common/extensions/manifest.h" |
16 #include "extensions/common/constants.h" | 17 #include "extensions/common/constants.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (default_locale.empty() && path_exists) { | 65 if (default_locale.empty() && path_exists) { |
65 *error = l10n_util::GetStringUTF8( | 66 *error = l10n_util::GetStringUTF8( |
66 IDS_EXTENSION_LOCALES_NO_DEFAULT_LOCALE_SPECIFIED); | 67 IDS_EXTENSION_LOCALES_NO_DEFAULT_LOCALE_SPECIFIED); |
67 return false; | 68 return false; |
68 } else if (!default_locale.empty() && !path_exists) { | 69 } else if (!default_locale.empty() && !path_exists) { |
69 *error = errors::kLocalesTreeMissing; | 70 *error = errors::kLocalesTreeMissing; |
70 return false; | 71 return false; |
71 } | 72 } |
72 | 73 |
73 // Treat all folders under _locales as valid locales. | 74 // Treat all folders under _locales as valid locales. |
74 file_util::FileEnumerator locales(path, | 75 base::FileEnumerator locales(path, false, base::FileEnumerator::DIRECTORIES); |
75 false, | |
76 file_util::FileEnumerator::DIRECTORIES); | |
77 | 76 |
78 std::set<std::string> all_locales; | 77 std::set<std::string> all_locales; |
79 extension_l10n_util::GetAllLocales(&all_locales); | 78 extension_l10n_util::GetAllLocales(&all_locales); |
80 const base::FilePath default_locale_path = path.AppendASCII(default_locale); | 79 const base::FilePath default_locale_path = path.AppendASCII(default_locale); |
81 bool has_default_locale_message_file = false; | 80 bool has_default_locale_message_file = false; |
82 | 81 |
83 base::FilePath locale_path; | 82 base::FilePath locale_path; |
84 while (!(locale_path = locales.Next()).empty()) { | 83 while (!(locale_path = locales.Next()).empty()) { |
85 if (extension_l10n_util::ShouldSkipValidation(path, locale_path, | 84 if (extension_l10n_util::ShouldSkipValidation(path, locale_path, |
86 all_locales)) | 85 all_locales)) |
(...skipping 24 matching lines...) Expand all Loading... |
111 bool DefaultLocaleHandler::AlwaysValidateForType(Manifest::Type type) const { | 110 bool DefaultLocaleHandler::AlwaysValidateForType(Manifest::Type type) const { |
112 // Required to validate _locales directory; see Validate. | 111 // Required to validate _locales directory; see Validate. |
113 return true; | 112 return true; |
114 } | 113 } |
115 | 114 |
116 const std::vector<std::string> DefaultLocaleHandler::Keys() const { | 115 const std::vector<std::string> DefaultLocaleHandler::Keys() const { |
117 return SingleKey(keys::kDefaultLocale); | 116 return SingleKey(keys::kDefaultLocale); |
118 } | 117 } |
119 | 118 |
120 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |