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/unpacker.h" | 5 #include "chrome/common/extensions/unpacker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_enumerator.h" |
10 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
11 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
12 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
13 #include "base/memory/scoped_handle.h" | 14 #include "base/memory/scoped_handle.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 19 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 121 } |
121 | 122 |
122 return static_cast<DictionaryValue*>(root.release()); | 123 return static_cast<DictionaryValue*>(root.release()); |
123 } | 124 } |
124 | 125 |
125 bool Unpacker::ReadAllMessageCatalogs(const std::string& default_locale) { | 126 bool Unpacker::ReadAllMessageCatalogs(const std::string& default_locale) { |
126 base::FilePath locales_path = | 127 base::FilePath locales_path = |
127 temp_install_dir_.Append(kLocaleFolder); | 128 temp_install_dir_.Append(kLocaleFolder); |
128 | 129 |
129 // Not all folders under _locales have to be valid locales. | 130 // Not all folders under _locales have to be valid locales. |
130 file_util::FileEnumerator locales(locales_path, | 131 base::FileEnumerator locales(locales_path, |
131 false, | 132 false, |
132 file_util::FileEnumerator::DIRECTORIES); | 133 base::FileEnumerator::DIRECTORIES); |
133 | 134 |
134 std::set<std::string> all_locales; | 135 std::set<std::string> all_locales; |
135 extension_l10n_util::GetAllLocales(&all_locales); | 136 extension_l10n_util::GetAllLocales(&all_locales); |
136 base::FilePath locale_path; | 137 base::FilePath locale_path; |
137 while (!(locale_path = locales.Next()).empty()) { | 138 while (!(locale_path = locales.Next()).empty()) { |
138 if (extension_l10n_util::ShouldSkipValidation(locales_path, locale_path, | 139 if (extension_l10n_util::ShouldSkipValidation(locales_path, locale_path, |
139 all_locales)) | 140 all_locales)) |
140 continue; | 141 continue; |
141 | 142 |
142 base::FilePath messages_path = locale_path.Append(kMessagesFilename); | 143 base::FilePath messages_path = locale_path.Append(kMessagesFilename); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 336 |
336 void Unpacker::SetError(const std::string &error) { | 337 void Unpacker::SetError(const std::string &error) { |
337 SetUTF16Error(UTF8ToUTF16(error)); | 338 SetUTF16Error(UTF8ToUTF16(error)); |
338 } | 339 } |
339 | 340 |
340 void Unpacker::SetUTF16Error(const string16 &error) { | 341 void Unpacker::SetUTF16Error(const string16 &error) { |
341 error_message_ = error; | 342 error_message_ = error; |
342 } | 343 } |
343 | 344 |
344 } // namespace extensions | 345 } // namespace extensions |
OLD | NEW |