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.
5 #ifndef CHROME_BROWSER_CHROMEOS_PREFERENCES_H_
6 #define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_
10 #include "ash/shell_observer.h"
11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_change_registrar.h"
13 #include "base/prefs/pref_member.h"
14 #include "chrome/browser/chromeos/language_preferences.h"
15 #include "components/syncable_prefs/pref_service_syncable_observer.h"
16 #include "components/user_manager/user_manager.h"
17 #include "ui/base/ime/chromeos/input_method_manager.h"
19 class PrefRegistrySimple
;
23 namespace syncable_prefs
{
24 class PrefServiceSyncable
;
27 namespace user_prefs
{
28 class PrefRegistrySyncable
;
35 namespace input_method
{
36 class InputMethodManager
;
37 class InputMethodSyncer
;
40 // The Preferences class handles Chrome OS preferences. When the class
41 // is first initialized, it will initialize the OS settings to what's stored in
42 // the preferences. These include touchpad settings, etc.
43 // When the preferences change, we change the settings to reflect the new value.
44 class Preferences
: public syncable_prefs::PrefServiceSyncableObserver
,
45 public ash::ShellObserver
,
46 public user_manager::UserManager::UserSessionStateObserver
{
50 input_method::InputMethodManager
* input_method_manager
); // for testing
51 ~Preferences() override
;
53 // These method will register the prefs associated with Chrome OS settings.
54 static void RegisterPrefs(PrefRegistrySimple
* registry
);
55 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
57 // This method will initialize Chrome OS settings to values in user prefs.
58 // |user| is the user owning this preferences.
59 void Init(Profile
* profile
, const user_manager::User
* user
);
61 void InitUserPrefsForTesting(
62 syncable_prefs::PrefServiceSyncable
* prefs
,
63 const user_manager::User
* user
,
64 scoped_refptr
<input_method::InputMethodManager::State
> ime_state
);
65 void SetInputMethodListForTesting();
69 REASON_INITIALIZATION
,
70 REASON_ACTIVE_USER_CHANGED
,
74 // Initializes all member prefs.
75 void InitUserPrefs(syncable_prefs::PrefServiceSyncable
* prefs
);
77 // Callback method for preference changes.
78 void OnPreferenceChanged(const std::string
& pref_name
);
80 // This will set the OS settings when the preference changed or the user
81 // owning these preferences became active. Also this method is called on
82 // initialization. The reason of the call is stored as the |reason| parameter.
83 // |pref_name| is the name of the changed preference if the |reason| is
84 // |REASON_PREF_CHANGED|, otherwise it is empty.
85 void ApplyPreferences(ApplyReason reason
,
86 const std::string
& pref_name
);
88 // A variant of SetLanguageConfigStringList. You can pass comma-separated
89 // values. Examples of |value|: "", "Control+space,Hiragana"
90 void SetLanguageConfigStringListAsCSV(const char* section
,
92 const std::string
& value
);
94 // Restores the user's preferred input method / keyboard layout on signing in.
95 void SetInputMethodList();
97 // Updates the initial key repeat delay and key repeat interval following
98 // current prefs values. We set the delay and interval at once since an
99 // underlying XKB API requires it.
100 void UpdateAutoRepeatRate();
102 // Force natural scroll to on if --enable-natural-scroll-default is specified
104 void ForceNaturalScrollDefault();
106 // syncable_prefs::PrefServiceSyncableObserver implementation.
107 void OnIsSyncingChanged() override
;
109 // Overriden from ash::ShellObserver.
110 void OnTouchHudProjectionToggled(bool enabled
) override
;
112 // Overriden form user_manager::UserManager::UserSessionStateObserver.
113 void ActiveUserChanged(const user_manager::User
* active_user
) override
;
115 void ActivateInputMethods(const user_manager::User
* active_user
);
117 syncable_prefs::PrefServiceSyncable
* prefs_
;
119 input_method::InputMethodManager
* input_method_manager_
;
120 scoped_ptr
<TracingManager
> tracing_manager_
;
122 BooleanPrefMember performance_tracing_enabled_
;
123 BooleanPrefMember tap_to_click_enabled_
;
124 BooleanPrefMember tap_dragging_enabled_
;
125 BooleanPrefMember three_finger_click_enabled_
;
126 BooleanPrefMember unified_desktop_enabled_by_default_
;
127 BooleanPrefMember natural_scroll_
;
128 BooleanPrefMember vert_edge_scroll_enabled_
;
129 IntegerPrefMember speed_factor_
;
130 IntegerPrefMember mouse_sensitivity_
;
131 IntegerPrefMember touchpad_sensitivity_
;
132 BooleanPrefMember primary_mouse_button_right_
;
133 FilePathPrefMember download_default_directory_
;
134 BooleanPrefMember touch_hud_projection_enabled_
;
136 // Input method preferences.
137 StringPrefMember preload_engines_
;
138 StringPrefMember current_input_method_
;
139 StringPrefMember previous_input_method_
;
140 StringPrefMember enabled_extension_imes_
;
142 BooleanPrefMember xkb_auto_repeat_enabled_
;
143 IntegerPrefMember xkb_auto_repeat_delay_pref_
;
144 IntegerPrefMember xkb_auto_repeat_interval_pref_
;
146 BooleanPrefMember wake_on_wifi_ssid_
;
148 PrefChangeRegistrar pref_change_registrar_
;
150 // User owning these preferences.
151 const user_manager::User
* user_
;
153 // Whether user is a primary user.
154 bool user_is_primary_
;
156 // Input Methods state for this user.
157 scoped_refptr
<input_method::InputMethodManager::State
> ime_state_
;
159 scoped_ptr
<input_method::InputMethodSyncer
> input_method_syncer_
;
161 DISALLOW_COPY_AND_ASSIGN(Preferences
);
164 } // namespace chromeos
166 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_