Home | History | Annotate | Download | only in chromeos
      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 #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.
     13 namespace chromeos {
     14 namespace language_prefs {
     15 
     16 // The struct is used for preferences consisting of multiple choices, like
     17 // punctuation types used in Japanese input method.
     18 template <typename DataType>
     19 struct 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.
     34 struct 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.
     43 struct 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 // ---------------------------------------------------------------------------
     55 extern const char kGeneralSectionName[];
     56 extern const char kHotKeySectionName[];
     57 extern const char kPreloadEnginesConfigName[];
     58 extern const char kNextEngineInMenuConfigName[];
     59 extern const char kPreviousEngineConfigName[];
     60 extern const char kHotkeyNextEngineInMenu[];
     61 extern const char kHotkeyPreviousEngine[];
     62 
     63 // ---------------------------------------------------------------------------
     64 // For Traditional Chinese input method (ibus-chewing)
     65 // ---------------------------------------------------------------------------
     66 extern const char kChewingSectionName[];
     67 
     68 extern 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.
     72 const size_t kNumChewingBooleanPrefs = 8 - 2; // -2 is for crosbug.com/14185
     73 
     74 extern const LanguageIntegerRangePreference kChewingIntegerPrefs[];
     75 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
     76 const size_t kNumChewingIntegerPrefs = 2;
     77 const int kChewingMaxChiSymbolLenIndex = 0;
     78 const int kChewingCandPerPageIndex = 1;
     79 
     80 extern const LanguageMultipleChoicePreference<const char*>
     81     kChewingMultipleChoicePrefs[];
     82 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
     83 const size_t kNumChewingMultipleChoicePrefs = 2;
     84 
     85 extern const LanguageMultipleChoicePreference<int> kChewingHsuSelKeyType;
     86 
     87 // ---------------------------------------------------------------------------
     88 // For Korean input method (ibus-hangul)
     89 // ---------------------------------------------------------------------------
     90 extern const char kHangulSectionName[];
     91 extern const char kHangulKeyboardConfigName[];
     92 extern const char kHangulHanjaKeysConfigName[];
     93 extern const char kHangulHanjaKeys[];
     94 
     95 struct HangulKeyboardNameIDPair {
     96   int message_id;
     97   const char* keyboard_id;
     98 };
     99 
    100 extern const HangulKeyboardNameIDPair kHangulKeyboardNameIDPairs[];
    101 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
    102 const size_t kNumHangulKeyboardNameIDPairs = 4;
    103 
    104 // ---------------------------------------------------------------------------
    105 // For Simplified Chinese input method (ibus-pinyin)
    106 // ---------------------------------------------------------------------------
    107 extern const char kPinyinSectionName[];
    108 
    109 extern const LanguageBooleanPrefs kPinyinBooleanPrefs[];
    110 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
    111 const size_t kNumPinyinBooleanPrefs = 11;
    112 
    113 extern const LanguageMultipleChoicePreference<int> kPinyinDoublePinyinSchema;
    114 
    115 struct 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 
    122 extern const PinyinIntegerPref kPinyinIntegerPrefs[];
    123 const size_t kNumPinyinIntegerPrefs = 1;
    124 
    125 // ---------------------------------------------------------------------------
    126 // For Japanese input method (ibus-mozc)
    127 // ---------------------------------------------------------------------------
    128 extern const char kMozcSectionName[];
    129 
    130 extern const LanguageBooleanPrefs kMozcBooleanPrefs[];
    131 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
    132 const size_t kNumMozcBooleanPrefs = 8;
    133 
    134 extern const LanguageMultipleChoicePreference<const char*>
    135     kMozcMultipleChoicePrefs[];
    136 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
    137 const size_t kNumMozcMultipleChoicePrefs = 8;
    138 
    139 extern const LanguageIntegerRangePreference kMozcIntegerPrefs[];
    140 // See comments at kNumChewingBooleanPrefs for why we hard-code this here.
    141 const 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 WebUI.
    149 enum RemapType {
    150   kNoRemap = 0,
    151   kSwapCtrlAndAlt = 1,
    152   kSwapSearchAndCtrl = 2,
    153 };
    154 extern const LanguageMultipleChoicePreference<int>
    155     kXkbModifierMultipleChoicePrefs;
    156 
    157 // A delay between the first and the start of the rest.
    158 extern const int kXkbAutoRepeatDelayInMs;
    159 // An interval between the repeated keys.
    160 extern const int kXkbAutoRepeatIntervalInMs;
    161 
    162 // A string Chrome preference (Local State) of the preferred keyboard layout in
    163 // the login screen.
    164 extern const char kPreferredKeyboardLayout[];
    165 
    166 }  // language_prefs
    167 }  // chromeos
    168 
    169 #endif  // CHROME_BROWSER_CHROMEOS_LANGUAGE_PREFERENCES_H_
    170