Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / preferences.h
blob06accf32bbe5cb19fb6dacdcd685c3449251a71f
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_change_registrar.h"
13 #include "base/prefs/pref_member.h"
14 #include "chrome/browser/chromeos/language_preferences.h"
15 #include "chrome/browser/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;
20 class PrefService;
21 class PrefServiceSyncable;
23 class TracingManager;
25 namespace user_prefs {
26 class PrefRegistrySyncable;
29 namespace chromeos {
31 class User;
33 namespace input_method {
34 class InputMethodManager;
35 class InputMethodSyncer;
38 // The Preferences class handles Chrome OS preferences. When the class
39 // is first initialized, it will initialize the OS settings to what's stored in
40 // the preferences. These include touchpad settings, etc.
41 // When the preferences change, we change the settings to reflect the new value.
42 class Preferences : public PrefServiceSyncableObserver,
43 public ash::ShellObserver,
44 public user_manager::UserManager::UserSessionStateObserver {
45 public:
46 Preferences();
47 explicit Preferences(
48 input_method::InputMethodManager* input_method_manager); // for testing
49 ~Preferences() override;
51 // These method will register the prefs associated with Chrome OS settings.
52 static void RegisterPrefs(PrefRegistrySimple* registry);
53 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
55 // This method will initialize Chrome OS settings to values in user prefs.
56 // |user| is the user owning this preferences.
57 void Init(Profile* profile, const user_manager::User* user);
59 void InitUserPrefsForTesting(
60 PrefServiceSyncable* prefs,
61 const user_manager::User* user,
62 scoped_refptr<input_method::InputMethodManager::State> ime_state);
63 void SetInputMethodListForTesting();
65 private:
66 enum ApplyReason {
67 REASON_INITIALIZATION,
68 REASON_ACTIVE_USER_CHANGED,
69 REASON_PREF_CHANGED
72 // Initializes all member prefs.
73 void InitUserPrefs(PrefServiceSyncable* prefs);
75 // Callback method for preference changes.
76 void OnPreferenceChanged(const std::string& pref_name);
78 // This will set the OS settings when the preference changed or user owning
79 // these preferences became active. Also this method is called on
80 // initialization. The reason of call is stored in |reason| parameter.
81 // |pref_name| keeps name of changed preference in |reason| is
82 // |REASON_PREF_CHANGED|, otherwise it is empty.
83 void ApplyPreferences(ApplyReason reason,
84 const std::string& pref_name);
86 // A variant of SetLanguageConfigStringList. You can pass comma-separated
87 // values. Examples of |value|: "", "Control+space,Hiragana"
88 void SetLanguageConfigStringListAsCSV(const char* section,
89 const char* name,
90 const std::string& value);
92 // Restores the user's preferred input method / keyboard layout on signing in.
93 void SetInputMethodList();
95 // Updates the initial key repeat delay and key repeat interval following
96 // current prefs values. We set the delay and interval at once since an
97 // underlying XKB API requires it.
98 void UpdateAutoRepeatRate();
100 // Force natural scroll to on if --enable-natural-scroll-default is specified
101 // on the cmd line.
102 void ForceNaturalScrollDefault();
104 // PrefServiceSyncableObserver implementation.
105 void OnIsSyncingChanged() override;
107 // Overriden from ash::ShellObserver.
108 void OnTouchHudProjectionToggled(bool enabled) override;
110 // Overriden form user_manager::UserManager::UserSessionStateObserver.
111 void ActiveUserChanged(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 BooleanPrefMember wake_on_wifi_ssid_;
145 PrefChangeRegistrar pref_change_registrar_;
147 // User owning these preferences.
148 const user_manager::User* user_;
150 // Whether user is a primary user.
151 bool user_is_primary_;
153 // Input Methods state for this user.
154 scoped_refptr<input_method::InputMethodManager::State> ime_state_;
156 scoped_ptr<input_method::InputMethodSyncer> input_method_syncer_;
158 DISALLOW_COPY_AND_ASSIGN(Preferences);
161 } // namespace chromeos
163 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_