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

Side by Side Diff: chrome/common/extensions/api/i18n/default_locale_handler.cc

Issue 12025010: Move default_locale out of Extension class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extension_service_unittest fixed Created 7 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "chrome/common/extensions/extension_manifest_constants.h"
12 #include "chrome/common/extensions/manifest.h"
13 #include "ui/base/l10n/l10n_util.h"
14
15 namespace keys = extension_manifest_keys;
16
17 namespace extensions {
18
19 // static
20 const std::string& LocaleInfo::GetDefaultLocale(const Extension* extension) {
21 LocaleInfo* info = static_cast<LocaleInfo*>(
22 extension->GetManifestData(keys::kDefaultLocale));
23 return info ? info->default_locale : EmptyString();
24 }
25
26 DefaultLocaleHandler::DefaultLocaleHandler() {
27 }
28
29 DefaultLocaleHandler::~DefaultLocaleHandler() {
30 }
31
32 bool DefaultLocaleHandler::Parse(Extension* extension, string16* error) {
33 scoped_ptr<LocaleInfo> info(new LocaleInfo);
34 if (!extension->manifest()->GetString(keys::kDefaultLocale,
35 &info->default_locale) ||
36 !l10n_util::IsValidLocaleSyntax(info->default_locale)) {
37 *error = ASCIIToUTF16(extension_manifest_errors::kInvalidDefaultLocale);
38 return false;
39 }
40 extension->SetManifestData(keys::kDefaultLocale, info.release());
41 return true;
42 }
43
44 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698