OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "chrome/browser/chromeos/language_preferences.h" | 13 #include "chrome/browser/chromeos/language_preferences.h" |
14 #include "chrome/browser/prefs/pref_member.h" | 14 #include "chrome/browser/prefs/pref_member.h" |
15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
16 | 16 |
17 class PrefService; | 17 class PrefService; |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
| 20 namespace input_method { |
| 21 class InputMethodManager; |
| 22 } // namespace input_method |
20 | 23 |
21 // The Preferences class handles Chrome OS preferences. When the class | 24 // The Preferences class handles Chrome OS preferences. When the class |
22 // is first initialized, it will initialize the OS settings to what's stored in | 25 // is first initialized, it will initialize the OS settings to what's stored in |
23 // the preferences. These include touchpad settings, etc. | 26 // the preferences. These include touchpad settings, etc. |
24 // When the preferences change, we change the settings to reflect the new value. | 27 // When the preferences change, we change the settings to reflect the new value. |
25 class Preferences : public content::NotificationObserver { | 28 class Preferences : public content::NotificationObserver { |
26 public: | 29 public: |
27 Preferences(); | 30 Preferences(); |
| 31 explicit Preferences( |
| 32 input_method::InputMethodManager* input_method_manager); // for testing |
28 virtual ~Preferences(); | 33 virtual ~Preferences(); |
29 | 34 |
30 // This method will register the prefs associated with Chrome OS settings. | 35 // This method will register the prefs associated with Chrome OS settings. |
31 static void RegisterUserPrefs(PrefService* prefs); | 36 static void RegisterUserPrefs(PrefService* prefs); |
32 | 37 |
33 // This method is called when kLanguagePreferredVirtualKeyboard is updated to | 38 // This method is called when kLanguagePreferredVirtualKeyboard is updated to |
34 // change the virtual keyboard settings to reflect the new value. | 39 // change the virtual keyboard settings to reflect the new value. |
35 static void UpdateVirturalKeyboardPreference(PrefService* prefs); | 40 static void UpdateVirturalKeyboardPreference(PrefService* prefs); |
36 | 41 |
37 // This method will initialize Chrome OS settings to values in user prefs. | 42 // This method will initialize Chrome OS settings to values in user prefs. |
38 void Init(PrefService* prefs); | 43 void Init(PrefService* prefs); |
39 | 44 |
40 // Overridden from content::NotificationObserver: | 45 // Overridden from content::NotificationObserver: |
41 virtual void Observe(int type, | 46 virtual void Observe(int type, |
42 const content::NotificationSource& source, | 47 const content::NotificationSource& source, |
43 const content::NotificationDetails& details) OVERRIDE; | 48 const content::NotificationDetails& details) OVERRIDE; |
44 | 49 |
| 50 void InitUserPrefsForTesting(PrefService* prefs); |
| 51 void SetInputMethodListForTesting(); |
| 52 |
45 private: | 53 private: |
| 54 // Initializes all member prefs. |
| 55 void InitUserPrefs(PrefService* prefs); |
| 56 |
46 // This will set the OS settings when the preference changes. | 57 // This will set the OS settings when the preference changes. |
47 // If this method is called with NULL, it will set all OS settings to what's | 58 // If this method is called with NULL, it will set all OS settings to what's |
48 // stored in the preferences. | 59 // stored in the preferences. |
49 void NotifyPrefChanged(const std::string* pref_name); | 60 void NotifyPrefChanged(const std::string* pref_name); |
50 | 61 |
51 // Writes boolean |value| to the input method (IBus) configuration daemon. | 62 // Writes boolean |value| to the input method (IBus) configuration daemon. |
52 // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should | 63 // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should |
53 // not be NULL. | 64 // not be NULL. |
54 void SetLanguageConfigBoolean(const char* section, | 65 void SetLanguageConfigBoolean(const char* section, |
55 const char* name, | 66 const char* name, |
(...skipping 16 matching lines...) Expand all Loading... |
72 void SetLanguageConfigStringList(const char* section, | 83 void SetLanguageConfigStringList(const char* section, |
73 const char* name, | 84 const char* name, |
74 const std::vector<std::string>& values); | 85 const std::vector<std::string>& values); |
75 | 86 |
76 // A variant of SetLanguageConfigStringList. You can pass comma-separated | 87 // A variant of SetLanguageConfigStringList. You can pass comma-separated |
77 // values. Examples of |value|: "", "Control+space,Hiragana" | 88 // values. Examples of |value|: "", "Control+space,Hiragana" |
78 void SetLanguageConfigStringListAsCSV(const char* section, | 89 void SetLanguageConfigStringListAsCSV(const char* section, |
79 const char* name, | 90 const char* name, |
80 const std::string& value); | 91 const std::string& value); |
81 | 92 |
| 93 // Restores the user's preferred input method / keyboard layout on signing in. |
| 94 void SetInputMethodList(); |
| 95 |
82 // Updates the mapping of modifier keys following current prefs values. | 96 // Updates the mapping of modifier keys following current prefs values. |
83 void UpdateModifierKeyMapping(); | 97 void UpdateModifierKeyMapping(); |
84 | 98 |
85 // Updates the initial key repeat delay and key repeat interval following | 99 // Updates the initial key repeat delay and key repeat interval following |
86 // current prefs values. We set the delay and interval at once since an | 100 // current prefs values. We set the delay and interval at once since an |
87 // underlying XKB API requires it. | 101 // underlying XKB API requires it. |
88 void UpdateAutoRepeatRate(); | 102 void UpdateAutoRepeatRate(); |
89 | 103 |
| 104 input_method::InputMethodManager* input_method_manager_; |
| 105 |
90 BooleanPrefMember tap_to_click_enabled_; | 106 BooleanPrefMember tap_to_click_enabled_; |
91 BooleanPrefMember natural_scroll_; | 107 BooleanPrefMember natural_scroll_; |
92 BooleanPrefMember vert_edge_scroll_enabled_; | 108 BooleanPrefMember vert_edge_scroll_enabled_; |
93 BooleanPrefMember accessibility_enabled_; | 109 BooleanPrefMember accessibility_enabled_; |
94 IntegerPrefMember speed_factor_; | 110 IntegerPrefMember speed_factor_; |
95 IntegerPrefMember mouse_sensitivity_; | 111 IntegerPrefMember mouse_sensitivity_; |
96 IntegerPrefMember touchpad_sensitivity_; | 112 IntegerPrefMember touchpad_sensitivity_; |
97 BooleanPrefMember primary_mouse_button_right_; | 113 BooleanPrefMember primary_mouse_button_right_; |
98 BooleanPrefMember use_24hour_clock_; | 114 BooleanPrefMember use_24hour_clock_; |
99 BooleanPrefMember disable_gdata_; | 115 BooleanPrefMember disable_gdata_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 IntegerPrefMember xkb_auto_repeat_interval_pref_; | 153 IntegerPrefMember xkb_auto_repeat_interval_pref_; |
138 | 154 |
139 BooleanPrefMember enable_screen_lock_; | 155 BooleanPrefMember enable_screen_lock_; |
140 | 156 |
141 DISALLOW_COPY_AND_ASSIGN(Preferences); | 157 DISALLOW_COPY_AND_ASSIGN(Preferences); |
142 }; | 158 }; |
143 | 159 |
144 } // namespace chromeos | 160 } // namespace chromeos |
145 | 161 |
146 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ | 162 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
OLD | NEW |