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_
11 #include "ash/shell_observer.h"
12 #include "base/compiler_specific.h"
13 #include "base/prefs/pref_member.h"
14 #include "chrome/browser/chromeos/language_preferences.h"
15 #include "chrome/browser/chromeos/login/user_manager.h"
16 #include "chrome/browser/prefs/pref_service_syncable_observer.h"
18 class PrefRegistrySimple
;
20 class PrefServiceSyncable
;
24 namespace user_prefs
{
25 class PrefRegistrySyncable
;
32 namespace input_method
{
33 class InputMethodManager
;
36 // The Preferences class handles Chrome OS preferences. When the class
37 // is first initialized, it will initialize the OS settings to what's stored in
38 // the preferences. These include touchpad settings, etc.
39 // When the preferences change, we change the settings to reflect the new value.
40 class Preferences
: public PrefServiceSyncableObserver
,
41 public ash::ShellObserver
,
42 public UserManager::UserSessionStateObserver
{
46 input_method::InputMethodManager
* input_method_manager
); // for testing
47 virtual ~Preferences();
49 // These method will register the prefs associated with Chrome OS settings.
50 static void RegisterPrefs(PrefRegistrySimple
* registry
);
51 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
53 // This method will initialize Chrome OS settings to values in user prefs.
54 // |user| is the user owning this preferences.
55 void Init(PrefServiceSyncable
* prefs
, const User
* user
);
57 void InitUserPrefsForTesting(PrefServiceSyncable
* prefs
, const User
* user
);
58 void SetInputMethodListForTesting();
62 REASON_INITIALIZATION
,
63 REASON_ACTIVE_USER_CHANGED
,
67 // Initializes all member prefs.
68 void InitUserPrefs(PrefServiceSyncable
* prefs
);
70 // Callback method for preference changes.
71 void OnPreferenceChanged(const std::string
& pref_name
);
73 // This will set the OS settings when the preference changed or user owning
74 // these preferences became active. Also this method is called on
75 // initialization. The reason of call is stored in |reason| parameter.
76 // |pref_name| keeps name of changed preference in |reason| is
77 // |REASON_PREF_CHANGED|, otherwise it is empty.
78 void ApplyPreferences(ApplyReason reason
,
79 const std::string
& pref_name
);
81 // A variant of SetLanguageConfigStringList. You can pass comma-separated
82 // values. Examples of |value|: "", "Control+space,Hiragana"
83 void SetLanguageConfigStringListAsCSV(const char* section
,
85 const std::string
& value
);
87 // Restores the user's preferred input method / keyboard layout on signing in.
88 void SetInputMethodList();
90 // Updates the initial key repeat delay and key repeat interval following
91 // current prefs values. We set the delay and interval at once since an
92 // underlying XKB API requires it.
93 void UpdateAutoRepeatRate();
95 // Force natural scroll to on if --enable-natural-scroll-default is specified
97 void ForceNaturalScrollDefault();
99 // PrefServiceSyncableObserver implementation.
100 virtual void OnIsSyncingChanged() OVERRIDE
;
102 // Overriden from ash::ShellObserver.
103 virtual void OnTouchHudProjectionToggled(bool enabled
) OVERRIDE
;
105 // Overriden form UserManager::UserSessionStateObserver.
106 virtual void ActiveUserChanged(const User
* active_user
) OVERRIDE
;
108 PrefServiceSyncable
* prefs_
;
110 input_method::InputMethodManager
* input_method_manager_
;
111 scoped_ptr
<TracingManager
> tracing_manager_
;
113 BooleanPrefMember performance_tracing_enabled_
;
114 BooleanPrefMember tap_to_click_enabled_
;
115 BooleanPrefMember tap_dragging_enabled_
;
116 BooleanPrefMember three_finger_click_enabled_
;
117 BooleanPrefMember natural_scroll_
;
118 BooleanPrefMember vert_edge_scroll_enabled_
;
119 IntegerPrefMember speed_factor_
;
120 IntegerPrefMember mouse_sensitivity_
;
121 IntegerPrefMember touchpad_sensitivity_
;
122 BooleanPrefMember primary_mouse_button_right_
;
123 FilePathPrefMember download_default_directory_
;
124 BooleanPrefMember touch_hud_projection_enabled_
;
126 // Input method preferences.
127 StringPrefMember preload_engines_
;
128 StringPrefMember current_input_method_
;
129 StringPrefMember previous_input_method_
;
130 StringPrefMember enabled_extension_imes_
;
132 BooleanPrefMember xkb_auto_repeat_enabled_
;
133 IntegerPrefMember xkb_auto_repeat_delay_pref_
;
134 IntegerPrefMember xkb_auto_repeat_interval_pref_
;
136 // User owning these preferences.
139 // Whether user is a primary user.
140 bool user_is_primary_
;
142 DISALLOW_COPY_AND_ASSIGN(Preferences
);
145 } // namespace chromeos
147 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_