• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PREFERENCES_H_
6 #define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_
7 #pragma once
8 
9 #include <string>
10 #include <vector>
11 
12 #include "chrome/browser/chromeos/language_preferences.h"
13 #include "chrome/browser/prefs/pref_member.h"
14 #include "content/common/notification_observer.h"
15 
16 class PrefService;
17 
18 namespace chromeos {
19 
20 // The Preferences class handles Chrome OS preferences. When the class
21 // is first initialized, it will initialize the OS settings to what's stored in
22 // the preferences. These include touchpad settings, etc.
23 // When the preferences change, we change the settings to reflect the new value.
24 class Preferences : public NotificationObserver {
25  public:
26   Preferences();
27   virtual ~Preferences();
28 
29   // This method will register the prefs associated with Chrome OS settings.
30   static void RegisterUserPrefs(PrefService* prefs);
31 
32   // This method will initialize Chrome OS settings to values in user prefs.
33   void Init(PrefService* prefs);
34 
35   // Overridden from NotificationObserver:
36   virtual void Observe(NotificationType type,
37                        const NotificationSource& source,
38                        const NotificationDetails& details);
39 
40  private:
41   // This will set the OS settings when the preference changes.
42   // If this method is called with NULL, it will set all OS settings to what's
43   // stored in the preferences.
44   void NotifyPrefChanged(const std::string* pref_name);
45 
46   // Writes boolean |value| to the input method (IBus) configuration daemon.
47   // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should
48   // not be NULL.
49   void SetLanguageConfigBoolean(const char* section,
50                                 const char* name,
51                                 bool value);
52 
53   // Writes integer |value| to the input method (IBus) configuration daemon.
54   // |section| and |name| should not be NULL.
55   void SetLanguageConfigInteger(const char* section,
56                                 const char* name,
57                                 int value);
58 
59   // Writes string |value| to the input method (IBus) configuration daemon.
60   // |section| and |name| should not be NULL.
61   void SetLanguageConfigString(const char* section,
62                                const char* name,
63                                const std::string& value);
64 
65   // Writes a string list to the input method (IBus) configuration daemon.
66   // |section| and |name| should not be NULL.
67   void SetLanguageConfigStringList(const char* section,
68                                    const char* name,
69                                    const std::vector<std::string>& values);
70 
71   // A variant of SetLanguageConfigStringList. You can pass comma-separated
72   // values. Examples of |value|: "", "Control+space,Hiragana"
73   void SetLanguageConfigStringListAsCSV(const char* section,
74                                         const char* name,
75                                         const std::string& value);
76 
77   // Updates the mapping of modifier keys following current prefs values.
78   void UpdateModifierKeyMapping();
79 
80   // Updates the initial key repeat delay and key repeat interval following
81   // current prefs values. We set the delay and interval at once since an
82   // underlying XKB API requires it.
83   void UpdateAutoRepeatRate();
84 
85   BooleanPrefMember tap_to_click_enabled_;
86   BooleanPrefMember vert_edge_scroll_enabled_;
87   BooleanPrefMember accessibility_enabled_;
88   IntegerPrefMember speed_factor_;
89   IntegerPrefMember sensitivity_;
90   BooleanPrefMember use_24hour_clock_;
91 
92   // Input method preferences.
93   StringPrefMember language_hotkey_next_engine_in_menu_;
94   StringPrefMember language_hotkey_previous_engine_;
95   StringPrefMember language_preferred_languages_;
96   StringPrefMember language_preload_engines_;
97   BooleanPrefMember language_chewing_boolean_prefs_[
98       language_prefs::kNumChewingBooleanPrefs];
99   StringPrefMember language_chewing_multiple_choice_prefs_[
100       language_prefs::kNumChewingMultipleChoicePrefs];
101   IntegerPrefMember language_chewing_hsu_sel_key_type_;
102   IntegerPrefMember language_chewing_integer_prefs_[
103       language_prefs::kNumChewingIntegerPrefs];
104   StringPrefMember language_hangul_keyboard_;
105   StringPrefMember language_hangul_hanja_keys_;
106   BooleanPrefMember language_pinyin_boolean_prefs_[
107       language_prefs::kNumPinyinBooleanPrefs];
108   IntegerPrefMember language_pinyin_int_prefs_[
109       language_prefs::kNumPinyinIntegerPrefs];
110   IntegerPrefMember language_pinyin_double_pinyin_schema_;
111   BooleanPrefMember language_mozc_boolean_prefs_[
112       language_prefs::kNumMozcBooleanPrefs];
113   StringPrefMember language_mozc_multiple_choice_prefs_[
114       language_prefs::kNumMozcMultipleChoicePrefs];
115   IntegerPrefMember language_mozc_integer_prefs_[
116       language_prefs::kNumMozcIntegerPrefs];
117   IntegerPrefMember language_xkb_remap_search_key_to_;
118   IntegerPrefMember language_xkb_remap_control_key_to_;
119   IntegerPrefMember language_xkb_remap_alt_key_to_;
120   BooleanPrefMember language_xkb_auto_repeat_enabled_;
121   IntegerPrefMember language_xkb_auto_repeat_delay_pref_;
122   IntegerPrefMember language_xkb_auto_repeat_interval_pref_;
123 
124   BooleanPrefMember enable_screen_lock_;
125 
126   DISALLOW_COPY_AND_ASSIGN(Preferences);
127 };
128 
129 }  // namespace chromeos
130 
131 #endif  // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_
132