language_preferences.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
6#define CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
7#pragma once
8
9#include <stddef.h>  // For size_t
10
11// This file defines types and declare variables used in "Languages and
12// Input" settings in Chromium OS.
13namespace chromeos {
14namespace language_prefs {
15
16// The struct is used for preferences consisting of multiple choices, like
17// punctuation types used in Japanese input method.
18template <typename DataType>
19struct LanguageMultipleChoicePreference {
20  const char* pref_name;  // Chrome preference name.
21  DataType default_pref_value;
22  const char* ibus_config_name;
23  // Currently we have 10 combobox items at most.
24  static const size_t kMaxItems = 11;
25  struct {
26    DataType ibus_config_value;
27    int item_message_id;  // Resource grd ID for the combobox item.
28  } values_and_ids[kMaxItems];
29  int label_message_id;  // Resource grd ID for the label.
30};
31
32// The struct is used for preferences of boolean values, like switches to
33// enable or disable particular features.
34struct LanguageBooleanPrefs {
35  const char* pref_name;  // Chrome preference name.
36  bool default_pref_value;
37  const char* ibus_config_name;
38  int message_id;
39};
40
41// The struct is used for preferences of integer range values, like the
42// key repeat rate.
43struct LanguageIntegerRangePreference {
44  const char* pref_name;  // Chrome preference name.
45  int default_pref_value;
46  int min_pref_value;
47  int max_pref_value;
48  const char* ibus_config_name;
49  int message_id;
50};
51
52// ---------------------------------------------------------------------------
53// For ibus-daemon
54// ---------------------------------------------------------------------------
55extern const char kGeneralSectionName[];
56extern const char kHotKeySectionName[];
57extern const char kPreloadEnginesConfigName[];
58extern const char kNextEngineInMenuConfigName[];
59extern const char kPreviousEngineConfigName[];
60extern const char kHotkeyNextEngineInMenu[];
61extern const char kHotkeyPreviousEngine[];
62
63// ---------------------------------------------------------------------------
64// For Traditional Chinese input method (ibus-chewing)
65// ---------------------------------------------------------------------------
66extern const char kChewingSectionName[];
67
68extern const LanguageBooleanPrefs kChewingBooleanPrefs[];
69// This is not ideal, but we should hard-code the number here as the value
70// is referenced in other header files as array sizes. We have a
71// COMPILE_ASSERT in .cc to ensure that the number is correct.
72const size_t kNumChewingBooleanPrefs = 8;
73
74extern const LanguageIntegerRangePreference kChewingIntegerPrefs[];
75// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
76const size_t kNumChewingIntegerPrefs = 2;
77const int kChewingMaxChiSymbolLenIndex = 0;
78const int kChewingCandPerPageIndex = 1;
79
80extern const LanguageMultipleChoicePreference<const char*>
81    kChewingMultipleChoicePrefs[];
82// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
83const size_t kNumChewingMultipleChoicePrefs = 2;
84
85extern const LanguageMultipleChoicePreference<int> kChewingHsuSelKeyType;
86
87// ---------------------------------------------------------------------------
88// For Korean input method (ibus-hangul)
89// ---------------------------------------------------------------------------
90extern const char kHangulSectionName[];
91extern const char kHangulKeyboardConfigName[];
92extern const char kHangulHanjaKeysConfigName[];
93extern const char kHangulHanjaKeys[];
94
95struct HangulKeyboardNameIDPair {
96  int message_id;
97  const char* keyboard_id;
98};
99
100extern const HangulKeyboardNameIDPair kHangulKeyboardNameIDPairs[];
101// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
102const size_t kNumHangulKeyboardNameIDPairs = 4;
103
104// ---------------------------------------------------------------------------
105// For Simplified Chinese input method (ibus-pinyin)
106// ---------------------------------------------------------------------------
107extern const char kPinyinSectionName[];
108
109extern const LanguageBooleanPrefs kPinyinBooleanPrefs[];
110// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
111const size_t kNumPinyinBooleanPrefs = 11;
112
113extern const LanguageMultipleChoicePreference<int> kPinyinDoublePinyinSchema;
114
115struct PinyinIntegerPref {
116  const char* pref_name;  // Chrome preference name.
117  int default_pref_value;
118  const char* ibus_config_name;
119  // TODO(yusukes): Add message_id if needed.
120};
121
122extern const PinyinIntegerPref kPinyinIntegerPrefs[];
123const size_t kNumPinyinIntegerPrefs = 1;
124
125// ---------------------------------------------------------------------------
126// For Japanese input method (ibus-mozc)
127// ---------------------------------------------------------------------------
128extern const char kMozcSectionName[];
129
130extern const LanguageBooleanPrefs kMozcBooleanPrefs[];
131// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
132const size_t kNumMozcBooleanPrefs = 8;
133
134extern const LanguageMultipleChoicePreference<const char*>
135    kMozcMultipleChoicePrefs[];
136// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
137const size_t kNumMozcMultipleChoicePrefs = 8;
138
139extern const LanguageIntegerRangePreference kMozcIntegerPrefs[];
140// See comments at kNumChewingBooleanPrefs for why we hard-code this here.
141const size_t kNumMozcIntegerPrefs = 1;
142
143// ---------------------------------------------------------------------------
144// For keyboard stuff
145// ---------------------------------------------------------------------------
146// TODO(yusukes): Temporary solution for View version of modifier key remapper.
147// Remove RemapType and kXkbModifierMultipleChoicePrefs when we finish to
148// migrate to DOMUI.
149enum RemapType {
150  kNoRemap = 0,
151  kSwapCtrlAndAlt = 1,
152  kSwapSearchAndCtrl = 2,
153};
154extern const LanguageMultipleChoicePreference<int>
155    kXkbModifierMultipleChoicePrefs;
156
157// A delay between the first and the start of the rest.
158extern const int kXkbAutoRepeatDelayInMs;
159// An interval between the repeated keys.
160extern const int kXkbAutoRepeatIntervalInMs;
161
162// A string Chrome preference (Local State) of the preferred keyboard layout in
163// the login screen.
164extern const char kPreferredKeyboardLayout[];
165
166}  // language_prefs
167}  // chromeos
168
169#endif  // CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
170