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