Roll src/third_party/WebKit 8b42d1d:744641d (svn 186770:186771)
[chromium-blink-merge.git] / chrome / browser / chromeos / preferences.h
blob88d861a91ab0774416cc89c0595d34acebf4312a
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_
8 #include <string>
10 #include "ash/shell_observer.h"
11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_member.h"
13 #include "chrome/browser/chromeos/language_preferences.h"
14 #include "chrome/browser/prefs/pref_service_syncable_observer.h"
15 #include "components/user_manager/user_manager.h"
16 #include "ui/base/ime/chromeos/input_method_manager.h"
18 class PrefRegistrySimple;
19 class PrefService;
20 class PrefServiceSyncable;
22 class TracingManager;
24 namespace user_prefs {
25 class PrefRegistrySyncable;
28 namespace chromeos {
30 class User;
32 namespace input_method {
33 class InputMethodManager;
34 class InputMethodSyncer;
37 // The Preferences class handles Chrome OS preferences. When the class
38 // is first initialized, it will initialize the OS settings to what's stored in
39 // the preferences. These include touchpad settings, etc.
40 // When the preferences change, we change the settings to reflect the new value.
41 class Preferences : public PrefServiceSyncableObserver,
42 public ash::ShellObserver,
43 public user_manager::UserManager::UserSessionStateObserver {
44 public:
45 Preferences();
46 explicit Preferences(
47 input_method::InputMethodManager* input_method_manager); // for testing
48 virtual ~Preferences();
50 // These method will register the prefs associated with Chrome OS settings.
51 static void RegisterPrefs(PrefRegistrySimple* registry);
52 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
54 // This method will initialize Chrome OS settings to values in user prefs.
55 // |user| is the user owning this preferences.
56 void Init(Profile* profile, const user_manager::User* user);
58 void InitUserPrefsForTesting(
59 PrefServiceSyncable* prefs,
60 const user_manager::User* user,
61 scoped_refptr<input_method::InputMethodManager::State> ime_state);
62 void SetInputMethodListForTesting();
64 private:
65 enum ApplyReason {
66 REASON_INITIALIZATION,
67 REASON_ACTIVE_USER_CHANGED,
68 REASON_PREF_CHANGED
71 // Initializes all member prefs.
72 void InitUserPrefs(PrefServiceSyncable* prefs);
74 // Callback method for preference changes.
75 void OnPreferenceChanged(const std::string& pref_name);
77 // This will set the OS settings when the preference changed or user owning
78 // these preferences became active. Also this method is called on
79 // initialization. The reason of call is stored in |reason| parameter.
80 // |pref_name| keeps name of changed preference in |reason| is
81 // |REASON_PREF_CHANGED|, otherwise it is empty.
82 void ApplyPreferences(ApplyReason reason,
83 const std::string& pref_name);
85 // A variant of SetLanguageConfigStringList. You can pass comma-separated
86 // values. Examples of |value|: "", "Control+space,Hiragana"
87 void SetLanguageConfigStringListAsCSV(const char* section,
88 const char* name,
89 const std::string& value);
91 // Restores the user's preferred input method / keyboard layout on signing in.
92 void SetInputMethodList();
94 // Updates the initial key repeat delay and key repeat interval following
95 // current prefs values. We set the delay and interval at once since an
96 // underlying XKB API requires it.
97 void UpdateAutoRepeatRate();
99 // Force natural scroll to on if --enable-natural-scroll-default is specified
100 // on the cmd line.
101 void ForceNaturalScrollDefault();
103 // PrefServiceSyncableObserver implementation.
104 virtual void OnIsSyncingChanged() override;
106 // Overriden from ash::ShellObserver.
107 virtual void OnTouchHudProjectionToggled(bool enabled) override;
109 // Overriden form user_manager::UserManager::UserSessionStateObserver.
110 virtual void ActiveUserChanged(
111 const user_manager::User* active_user) override;
113 void ActivateInputMethods(const user_manager::User* active_user);
115 PrefServiceSyncable* prefs_;
117 input_method::InputMethodManager* input_method_manager_;
118 scoped_ptr<TracingManager> tracing_manager_;
120 BooleanPrefMember performance_tracing_enabled_;
121 BooleanPrefMember tap_to_click_enabled_;
122 BooleanPrefMember tap_dragging_enabled_;
123 BooleanPrefMember three_finger_click_enabled_;
124 BooleanPrefMember natural_scroll_;
125 BooleanPrefMember vert_edge_scroll_enabled_;
126 IntegerPrefMember speed_factor_;
127 IntegerPrefMember mouse_sensitivity_;
128 IntegerPrefMember touchpad_sensitivity_;
129 BooleanPrefMember primary_mouse_button_right_;
130 FilePathPrefMember download_default_directory_;
131 BooleanPrefMember touch_hud_projection_enabled_;
133 // Input method preferences.
134 StringPrefMember preload_engines_;
135 StringPrefMember current_input_method_;
136 StringPrefMember previous_input_method_;
137 StringPrefMember enabled_extension_imes_;
139 BooleanPrefMember xkb_auto_repeat_enabled_;
140 IntegerPrefMember xkb_auto_repeat_delay_pref_;
141 IntegerPrefMember xkb_auto_repeat_interval_pref_;
143 IntegerPrefMember wake_on_wifi_enabled_;
145 // User owning these preferences.
146 const user_manager::User* user_;
148 // Whether user is a primary user.
149 bool user_is_primary_;
151 // Input Methods state for this user.
152 scoped_refptr<input_method::InputMethodManager::State> ime_state_;
154 scoped_ptr<input_method::InputMethodSyncer> input_method_syncer_;
156 DISALLOW_COPY_AND_ASSIGN(Preferences);
159 } // namespace chromeos
161 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_