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

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

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 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
« no previous file with comments | « extensions/browser/image_loader_unittest.cc ('k') | extensions/common/file_util.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/extension_l10n_util.h" 5 #include "extensions/common/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>
(...skipping 20 matching lines...) Expand all
31 namespace { 31 namespace {
32 32
33 // Loads contents of the messages file for given locale. If file is not found, 33 // Loads contents of the messages file for given locale. If file is not found,
34 // or there was parsing error we return NULL and set |error|. 34 // or there was parsing error we return NULL and set |error|.
35 // Caller owns the returned object. 35 // Caller owns the returned object.
36 base::DictionaryValue* LoadMessageFile(const base::FilePath& locale_path, 36 base::DictionaryValue* LoadMessageFile(const base::FilePath& locale_path,
37 const std::string& locale, 37 const std::string& locale,
38 std::string* error) { 38 std::string* error) {
39 base::FilePath file = 39 base::FilePath file =
40 locale_path.AppendASCII(locale).Append(extensions::kMessagesFilename); 40 locale_path.AppendASCII(locale).Append(extensions::kMessagesFilename);
41 JSONFileValueSerializer messages_serializer(file); 41 JSONFileValueDeserializer messages_deserializer(file);
42 base::Value* dictionary = messages_serializer.Deserialize(NULL, error); 42 base::Value* dictionary = messages_deserializer.Deserialize(NULL, error);
43 if (!dictionary) { 43 if (!dictionary) {
44 if (error->empty()) { 44 if (error->empty()) {
45 // JSONFileValueSerializer just returns NULL if file cannot be found. It 45 // JSONFileValueSerializer just returns NULL if file cannot be found. It
46 // doesn't set the error, so we have to do it. 46 // doesn't set the error, so we have to do it.
47 *error = base::StringPrintf("Catalog file is missing for locale %s.", 47 *error = base::StringPrintf("Catalog file is missing for locale %s.",
48 locale.c_str()); 48 locale.c_str());
49 } else { 49 } else {
50 *error = extensions::ErrorUtils::FormatErrorMessage( 50 *error = extensions::ErrorUtils::FormatErrorMessage(
51 errors::kLocalesInvalidLocale, 51 errors::kLocalesInvalidLocale,
52 base::UTF16ToUTF8(file.LossyDisplayName()), 52 base::UTF16ToUTF8(file.LossyDisplayName()),
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) 453 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale)
454 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { 454 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) {
455 extension_l10n_util::SetProcessLocale(locale); 455 extension_l10n_util::SetProcessLocale(locale);
456 } 456 }
457 457
458 ScopedLocaleForTest::~ScopedLocaleForTest() { 458 ScopedLocaleForTest::~ScopedLocaleForTest() {
459 extension_l10n_util::SetProcessLocale(locale_); 459 extension_l10n_util::SetProcessLocale(locale_);
460 } 460 }
461 461
462 } // namespace extension_l10n_util 462 } // namespace extension_l10n_util
OLDNEW
« no previous file with comments | « extensions/browser/image_loader_unittest.cc ('k') | extensions/common/file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698