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