Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/common/extensions/extension_l10n_util.cc

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/extension_file_util.cc ('k') | chrome/common/extensions/unpacker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
16 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chrome/common/extensions/extension_manifest_constants.h" 19 #include "chrome/common/extensions/extension_manifest_constants.h"
19 #include "chrome/common/extensions/extension_file_util.h" 20 #include "chrome/common/extensions/extension_file_util.h"
20 #include "chrome/common/extensions/message_bundle.h" 21 #include "chrome/common/extensions/message_bundle.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "extensions/common/constants.h" 23 #include "extensions/common/constants.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 all_fallback_locales->push_back(default_locale); 252 all_fallback_locales->push_back(default_locale);
252 } 253 }
253 254
254 bool GetValidLocales(const base::FilePath& locale_path, 255 bool GetValidLocales(const base::FilePath& locale_path,
255 std::set<std::string>* valid_locales, 256 std::set<std::string>* valid_locales,
256 std::string* error) { 257 std::string* error) {
257 std::set<std::string> chrome_locales; 258 std::set<std::string> chrome_locales;
258 GetAllLocales(&chrome_locales); 259 GetAllLocales(&chrome_locales);
259 260
260 // Enumerate all supplied locales in the extension. 261 // Enumerate all supplied locales in the extension.
261 file_util::FileEnumerator locales(locale_path, 262 base::FileEnumerator locales(locale_path,
262 false, 263 false,
263 file_util::FileEnumerator::DIRECTORIES); 264 base::FileEnumerator::DIRECTORIES);
264 base::FilePath locale_folder; 265 base::FilePath locale_folder;
265 while (!(locale_folder = locales.Next()).empty()) { 266 while (!(locale_folder = locales.Next()).empty()) {
266 std::string locale_name = locale_folder.BaseName().MaybeAsASCII(); 267 std::string locale_name = locale_folder.BaseName().MaybeAsASCII();
267 if (locale_name.empty()) { 268 if (locale_name.empty()) {
268 NOTREACHED(); 269 NOTREACHED();
269 continue; // Not ASCII. 270 continue; // Not ASCII.
270 } 271 }
271 if (!AddLocale(chrome_locales, 272 if (!AddLocale(chrome_locales,
272 locale_folder, 273 locale_folder,
273 locale_name, 274 locale_name,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) 366 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale)
366 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { 367 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) {
367 extension_l10n_util::SetProcessLocale(locale); 368 extension_l10n_util::SetProcessLocale(locale);
368 } 369 }
369 370
370 ScopedLocaleForTest::~ScopedLocaleForTest() { 371 ScopedLocaleForTest::~ScopedLocaleForTest() {
371 extension_l10n_util::SetProcessLocale(locale_); 372 extension_l10n_util::SetProcessLocale(locale_);
372 } 373 }
373 374
374 } // namespace extension_l10n_util 375 } // namespace extension_l10n_util
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_file_util.cc ('k') | chrome/common/extensions/unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698