| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/common/shell_observer.h" | 10 #include "ash/common/shell_observer.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/chromeos/language_preferences.h" | 13 #include "chrome/browser/chromeos/language_preferences.h" |
| 14 #include "components/prefs/pref_change_registrar.h" | 14 #include "components/prefs/pref_change_registrar.h" |
| 15 #include "components/prefs/pref_member.h" | 15 #include "components/prefs/pref_member.h" |
| 16 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 16 #include "components/sync_preferences/pref_service_syncable_observer.h" |
| 17 #include "components/user_manager/user_manager.h" | 17 #include "components/user_manager/user_manager.h" |
| 18 #include "ui/base/ime/chromeos/input_method_manager.h" | 18 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 19 | 19 |
| 20 class PrefRegistrySimple; | 20 class PrefRegistrySimple; |
| 21 class PrefService; | 21 class PrefService; |
| 22 class TracingManager; | 22 class TracingManager; |
| 23 | 23 |
| 24 namespace syncable_prefs { | 24 namespace sync_preferences { |
| 25 class PrefServiceSyncable; | 25 class PrefServiceSyncable; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace user_prefs { | 28 namespace user_prefs { |
| 29 class PrefRegistrySyncable; | 29 class PrefRegistrySyncable; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace chromeos { | 32 namespace chromeos { |
| 33 | 33 |
| 34 class User; | 34 class User; |
| 35 | 35 |
| 36 namespace input_method { | 36 namespace input_method { |
| 37 class InputMethodManager; | 37 class InputMethodManager; |
| 38 class InputMethodSyncer; | 38 class InputMethodSyncer; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // The Preferences class handles Chrome OS preferences. When the class | 41 // The Preferences class handles Chrome OS preferences. When the class |
| 42 // is first initialized, it will initialize the OS settings to what's stored in | 42 // is first initialized, it will initialize the OS settings to what's stored in |
| 43 // the preferences. These include touchpad settings, etc. | 43 // the preferences. These include touchpad settings, etc. |
| 44 // When the preferences change, we change the settings to reflect the new value. | 44 // When the preferences change, we change the settings to reflect the new value. |
| 45 class Preferences : public syncable_prefs::PrefServiceSyncableObserver, | 45 class Preferences : public sync_preferences::PrefServiceSyncableObserver, |
| 46 public ash::ShellObserver, | 46 public ash::ShellObserver, |
| 47 public user_manager::UserManager::UserSessionStateObserver { | 47 public user_manager::UserManager::UserSessionStateObserver { |
| 48 public: | 48 public: |
| 49 Preferences(); | 49 Preferences(); |
| 50 explicit Preferences( | 50 explicit Preferences( |
| 51 input_method::InputMethodManager* input_method_manager); // for testing | 51 input_method::InputMethodManager* input_method_manager); // for testing |
| 52 ~Preferences() override; | 52 ~Preferences() override; |
| 53 | 53 |
| 54 // These method will register the prefs associated with Chrome OS settings. | 54 // These method will register the prefs associated with Chrome OS settings. |
| 55 static void RegisterPrefs(PrefRegistrySimple* registry); | 55 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 56 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 56 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 57 | 57 |
| 58 // This method will initialize Chrome OS settings to values in user prefs. | 58 // This method will initialize Chrome OS settings to values in user prefs. |
| 59 // |user| is the user owning this preferences. | 59 // |user| is the user owning this preferences. |
| 60 void Init(Profile* profile, const user_manager::User* user); | 60 void Init(Profile* profile, const user_manager::User* user); |
| 61 | 61 |
| 62 void InitUserPrefsForTesting( | 62 void InitUserPrefsForTesting( |
| 63 syncable_prefs::PrefServiceSyncable* prefs, | 63 sync_preferences::PrefServiceSyncable* prefs, |
| 64 const user_manager::User* user, | 64 const user_manager::User* user, |
| 65 scoped_refptr<input_method::InputMethodManager::State> ime_state); | 65 scoped_refptr<input_method::InputMethodManager::State> ime_state); |
| 66 void SetInputMethodListForTesting(); | 66 void SetInputMethodListForTesting(); |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 enum ApplyReason { | 69 enum ApplyReason { |
| 70 REASON_INITIALIZATION, | 70 REASON_INITIALIZATION, |
| 71 REASON_ACTIVE_USER_CHANGED, | 71 REASON_ACTIVE_USER_CHANGED, |
| 72 REASON_PREF_CHANGED | 72 REASON_PREF_CHANGED |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 // Initializes all member prefs. | 75 // Initializes all member prefs. |
| 76 void InitUserPrefs(syncable_prefs::PrefServiceSyncable* prefs); | 76 void InitUserPrefs(sync_preferences::PrefServiceSyncable* prefs); |
| 77 | 77 |
| 78 // Callback method for preference changes. | 78 // Callback method for preference changes. |
| 79 void OnPreferenceChanged(const std::string& pref_name); | 79 void OnPreferenceChanged(const std::string& pref_name); |
| 80 | 80 |
| 81 // This will set the OS settings when the preference changed or the user | 81 // This will set the OS settings when the preference changed or the user |
| 82 // owning these preferences became active. Also this method is called on | 82 // owning these preferences became active. Also this method is called on |
| 83 // initialization. The reason of the call is stored as the |reason| parameter. | 83 // initialization. The reason of the call is stored as the |reason| parameter. |
| 84 // |pref_name| is the name of the changed preference if the |reason| is | 84 // |pref_name| is the name of the changed preference if the |reason| is |
| 85 // |REASON_PREF_CHANGED|, otherwise it is empty. | 85 // |REASON_PREF_CHANGED|, otherwise it is empty. |
| 86 void ApplyPreferences(ApplyReason reason, | 86 void ApplyPreferences(ApplyReason reason, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 | 97 |
| 98 // Updates the initial key repeat delay and key repeat interval following | 98 // Updates the initial key repeat delay and key repeat interval following |
| 99 // current prefs values. We set the delay and interval at once since an | 99 // current prefs values. We set the delay and interval at once since an |
| 100 // underlying XKB API requires it. | 100 // underlying XKB API requires it. |
| 101 void UpdateAutoRepeatRate(); | 101 void UpdateAutoRepeatRate(); |
| 102 | 102 |
| 103 // Force natural scroll to on if --enable-natural-scroll-default is specified | 103 // Force natural scroll to on if --enable-natural-scroll-default is specified |
| 104 // on the cmd line. | 104 // on the cmd line. |
| 105 void ForceNaturalScrollDefault(); | 105 void ForceNaturalScrollDefault(); |
| 106 | 106 |
| 107 // syncable_prefs::PrefServiceSyncableObserver implementation. | 107 // sync_preferences::PrefServiceSyncableObserver implementation. |
| 108 void OnIsSyncingChanged() override; | 108 void OnIsSyncingChanged() override; |
| 109 | 109 |
| 110 // Overriden from ash::ShellObserver. | 110 // Overriden from ash::ShellObserver. |
| 111 void OnTouchHudProjectionToggled(bool enabled) override; | 111 void OnTouchHudProjectionToggled(bool enabled) override; |
| 112 | 112 |
| 113 // Overriden form user_manager::UserManager::UserSessionStateObserver. | 113 // Overriden form user_manager::UserManager::UserSessionStateObserver. |
| 114 void ActiveUserChanged(const user_manager::User* active_user) override; | 114 void ActiveUserChanged(const user_manager::User* active_user) override; |
| 115 | 115 |
| 116 void ActivateInputMethods(const user_manager::User* active_user); | 116 void ActivateInputMethods(const user_manager::User* active_user); |
| 117 | 117 |
| 118 syncable_prefs::PrefServiceSyncable* prefs_; | 118 sync_preferences::PrefServiceSyncable* prefs_; |
| 119 | 119 |
| 120 input_method::InputMethodManager* input_method_manager_; | 120 input_method::InputMethodManager* input_method_manager_; |
| 121 std::unique_ptr<TracingManager> tracing_manager_; | 121 std::unique_ptr<TracingManager> tracing_manager_; |
| 122 | 122 |
| 123 BooleanPrefMember performance_tracing_enabled_; | 123 BooleanPrefMember performance_tracing_enabled_; |
| 124 BooleanPrefMember tap_to_click_enabled_; | 124 BooleanPrefMember tap_to_click_enabled_; |
| 125 BooleanPrefMember tap_dragging_enabled_; | 125 BooleanPrefMember tap_dragging_enabled_; |
| 126 BooleanPrefMember three_finger_click_enabled_; | 126 BooleanPrefMember three_finger_click_enabled_; |
| 127 BooleanPrefMember unified_desktop_enabled_by_default_; | 127 BooleanPrefMember unified_desktop_enabled_by_default_; |
| 128 BooleanPrefMember natural_scroll_; | 128 BooleanPrefMember natural_scroll_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 159 scoped_refptr<input_method::InputMethodManager::State> ime_state_; | 159 scoped_refptr<input_method::InputMethodManager::State> ime_state_; |
| 160 | 160 |
| 161 std::unique_ptr<input_method::InputMethodSyncer> input_method_syncer_; | 161 std::unique_ptr<input_method::InputMethodSyncer> input_method_syncer_; |
| 162 | 162 |
| 163 DISALLOW_COPY_AND_ASSIGN(Preferences); | 163 DISALLOW_COPY_AND_ASSIGN(Preferences); |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 } // namespace chromeos | 166 } // namespace chromeos |
| 167 | 167 |
| 168 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ | 168 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
| OLD | NEW |