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