1 // Copyright (c) 2011 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/browser/ui/webui/options/chromeos/language_mozc_handler.h"
6
7 #include "base/string_number_conversions.h"
8 #include "base/utf_string_conversions.h"
9 #include "base/values.h"
10 #include "chrome/browser/chromeos/language_preferences.h"
11 #include "chrome/browser/ui/webui/options/chromeos/language_options_util.h"
12 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
14
15 namespace {
16 const char kI18nPrefix[] = "mozc_";
17 } // namespace
18
19 namespace chromeos {
20
LanguageMozcHandler()21 LanguageMozcHandler::LanguageMozcHandler() {
22 }
23
~LanguageMozcHandler()24 LanguageMozcHandler::~LanguageMozcHandler() {
25 }
26
GetLocalizedValues(DictionaryValue * localized_strings)27 void LanguageMozcHandler::GetLocalizedValues(
28 DictionaryValue* localized_strings) {
29 DCHECK(localized_strings);
30
31 RegisterTitle(localized_strings, "languageMozcPage",
32 IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE);
33
34 for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) {
35 localized_strings->SetString(
36 GetI18nContentValue(language_prefs::kMozcBooleanPrefs[i], kI18nPrefix),
37 l10n_util::GetStringUTF16(
38 language_prefs::kMozcBooleanPrefs[i].message_id));
39 }
40
41 for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) {
42 const language_prefs::LanguageMultipleChoicePreference<const char*>&
43 preference = language_prefs::kMozcMultipleChoicePrefs[i];
44 localized_strings->SetString(
45 GetI18nContentValue(preference, kI18nPrefix),
46 l10n_util::GetStringUTF16(preference.label_message_id));
47 localized_strings->Set(GetTemplateDataPropertyName(preference, kI18nPrefix),
48 CreateMultipleChoiceList(preference));
49 }
50
51 for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) {
52 const language_prefs::LanguageIntegerRangePreference& preference =
53 language_prefs::kMozcIntegerPrefs[i];
54 localized_strings->SetString(
55 GetI18nContentValue(preference, kI18nPrefix),
56 l10n_util::GetStringUTF16(preference.message_id));
57 ListValue* list_value = new ListValue();
58 for (int j = preference.min_pref_value; j <= preference.max_pref_value;
59 ++j) {
60 ListValue* option = new ListValue();
61 option->Append(CreateValue(j));
62 option->Append(CreateValue(j));
63 list_value->Append(option);
64 }
65 localized_strings->Set(GetTemplateDataPropertyName(preference, kI18nPrefix),
66 list_value);
67 }
68 }
69
70 } // namespace chromeos
71