Chromium Code Reviews| 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_SYSTEM_INPUT_DEVICE_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chromeos/chromeos_export.h" | 10 #include "chromeos/chromeos_export.h" |
| 11 | 11 |
| 12 class PrefRegistrySimple; | 12 class PrefRegistrySimple; |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 namespace system { | 15 namespace system { |
| 16 | 16 |
| 17 class FakeInputDeviceSettings; | |
| 17 class InputDeviceSettings; | 18 class InputDeviceSettings; |
| 18 | 19 |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 // Objects of this class are intended to store values of type T, but might have | 22 // Objects of this class are intended to store values of type T, but might have |
| 22 // "unset" state. Object will be in "unset" state until Set is called first | 23 // "unset" state. Object will be in "unset" state until Set is called first |
| 23 // time. | 24 // time. |
| 24 template <typename T> | 25 template <typename T> |
| 25 class Optional { | 26 class Optional { |
| 26 public: | 27 public: |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 // Interface for configuring input device settings. | 154 // Interface for configuring input device settings. |
| 154 class CHROMEOS_EXPORT InputDeviceSettings { | 155 class CHROMEOS_EXPORT InputDeviceSettings { |
| 155 public: | 156 public: |
| 156 typedef base::Callback<void(bool)> DeviceExistsCallback; | 157 typedef base::Callback<void(bool)> DeviceExistsCallback; |
| 157 | 158 |
| 158 virtual ~InputDeviceSettings() {} | 159 virtual ~InputDeviceSettings() {} |
| 159 | 160 |
| 160 // Returns current instance of InputDeviceSettings. | 161 // Returns current instance of InputDeviceSettings. |
| 161 static InputDeviceSettings* Get(); | 162 static InputDeviceSettings* Get(); |
| 162 | 163 |
| 164 // Returns test instance of InputDeviceSettings. | |
| 165 static FakeInputDeviceSettings* GetForTesting(); | |
|
stevenjb
2016/06/30 00:17:30
See my comment in the other CL, this should be mer
michaelpg
2016/07/01 22:01:48
I would have to git try that to make sure it doesn
stevenjb
2016/07/02 00:28:26
I agree we shouldn't create a new / additional Fak
michaelpg
2016/07/07 22:16:54
Done, created InputDeviceSettings::FakeInterface.
| |
| 166 | |
| 163 // Replaces current instance with |test_settings|. Takes ownership of | 167 // Replaces current instance with |test_settings|. Takes ownership of |
| 164 // |test_settings|. Default implementation could be returned back by passing | 168 // |test_settings|. Default implementation could be returned back by passing |
| 165 // NULL to this method. | 169 // NULL to this method. |
| 166 static void SetSettingsForTesting(InputDeviceSettings* test_settings); | 170 static void SetSettingsForTesting(FakeInputDeviceSettings* test_settings); |
| 167 | 171 |
| 168 // Returns true if UI should implement enhanced keyboard support for cases | 172 // Returns true if UI should implement enhanced keyboard support for cases |
| 169 // where other input devices like mouse are absent. | 173 // where other input devices like mouse are absent. |
| 170 static bool ForceKeyboardDrivenUINavigation(); | 174 static bool ForceKeyboardDrivenUINavigation(); |
| 171 | 175 |
| 172 // Registers local pref names for touchpad and touch screen statuses. | 176 // Registers local pref names for touchpad and touch screen statuses. |
| 173 static void RegisterPrefs(PrefRegistrySimple* registry); | 177 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 174 | 178 |
| 175 void InitTouchDevicesStatusFromLocalPrefs(); | 179 void InitTouchDevicesStatusFromLocalPrefs(); |
| 176 | 180 |
| 177 // Toggles the status of Touchscreen/Touchpad on or off and updates the local | 181 // Toggles the status of Touchscreen/Touchpad on or off and updates the local |
| 178 // prefs. | 182 // prefs. |
| 179 void ToggleTouchscreen(); | 183 void ToggleTouchscreen(); |
| 180 void ToggleTouchpad(); | 184 void ToggleTouchpad(); |
| 181 | 185 |
| 182 // Calls |callback| asynchronously after determining if a touchpad is | 186 // Calls |callback|, possibly asynchronously, after determining if a touchpad |
| 183 // connected. | 187 // is connected. |
| 184 virtual void TouchpadExists(const DeviceExistsCallback& callback) = 0; | 188 virtual void TouchpadExists(const DeviceExistsCallback& callback) = 0; |
| 185 | 189 |
| 186 // Updates several touchpad settings at a time. Updates only settings that | 190 // Updates several touchpad settings at a time. Updates only settings that |
| 187 // are set in |settings| object. It is more efficient to use this method to | 191 // are set in |settings| object. It is more efficient to use this method to |
| 188 // update several settings then calling Set* methods one by one. | 192 // update several settings then calling Set* methods one by one. |
| 189 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) = 0; | 193 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) = 0; |
| 190 | 194 |
| 191 // Sets the touchpad sensitivity in the range [kMinPointerSensitivity, | 195 // Sets the touchpad sensitivity in the range [kMinPointerSensitivity, |
| 192 // kMaxPointerSensitivity]. | 196 // kMaxPointerSensitivity]. |
| 193 virtual void SetTouchpadSensitivity(int value) = 0; | 197 virtual void SetTouchpadSensitivity(int value) = 0; |
| 194 | 198 |
| 195 // Turns tap to click on/off. | 199 // Turns tap to click on/off. |
| 196 virtual void SetTapToClick(bool enabled) = 0; | 200 virtual void SetTapToClick(bool enabled) = 0; |
| 197 | 201 |
| 198 // Switch for three-finger click. | 202 // Switch for three-finger click. |
| 199 virtual void SetThreeFingerClick(bool enabled) = 0; | 203 virtual void SetThreeFingerClick(bool enabled) = 0; |
| 200 | 204 |
| 201 // Turns tap-dragging on/off. | 205 // Turns tap-dragging on/off. |
| 202 virtual void SetTapDragging(bool enabled) = 0; | 206 virtual void SetTapDragging(bool enabled) = 0; |
| 203 | 207 |
| 204 // Turns natural scrolling on/off for all devices except wheel mice | 208 // Turns natural scrolling on/off for all devices except wheel mice |
| 205 virtual void SetNaturalScroll(bool enabled) = 0; | 209 virtual void SetNaturalScroll(bool enabled) = 0; |
| 206 | 210 |
| 207 // Calls |callback| asynchronously after determining if a mouse is connected. | 211 // Calls |callback|, possibly asynchronously, after determining if a mouse is |
| 212 // connected. | |
| 208 virtual void MouseExists(const DeviceExistsCallback& callback) = 0; | 213 virtual void MouseExists(const DeviceExistsCallback& callback) = 0; |
| 209 | 214 |
| 210 // Updates several mouse settings at a time. Updates only settings that | 215 // Updates several mouse settings at a time. Updates only settings that |
| 211 // are set in |settings| object. It is more efficient to use this method to | 216 // are set in |settings| object. It is more efficient to use this method to |
| 212 // update several settings then calling Set* methods one by one. | 217 // update several settings then calling Set* methods one by one. |
| 213 virtual void UpdateMouseSettings(const MouseSettings& settings) = 0; | 218 virtual void UpdateMouseSettings(const MouseSettings& settings) = 0; |
| 214 | 219 |
| 215 // Sets the mouse sensitivity in the range [kMinPointerSensitivity, | 220 // Sets the mouse sensitivity in the range [kMinPointerSensitivity, |
| 216 // kMaxPointerSensitivity]. | 221 // kMaxPointerSensitivity]. |
| 217 virtual void SetMouseSensitivity(int value) = 0; | 222 virtual void SetMouseSensitivity(int value) = 0; |
| 218 | 223 |
| 219 // Sets the primary mouse button to the right button if |right| is true. | 224 // Sets the primary mouse button to the right button if |right| is true. |
| 220 virtual void SetPrimaryButtonRight(bool right) = 0; | 225 virtual void SetPrimaryButtonRight(bool right) = 0; |
| 221 | 226 |
| 222 // Reapplies previously set touchpad settings. | 227 // Reapplies previously set touchpad settings. |
| 223 virtual void ReapplyTouchpadSettings() = 0; | 228 virtual void ReapplyTouchpadSettings() = 0; |
| 224 | 229 |
| 225 // Reapplies previously set mouse settings. | 230 // Reapplies previously set mouse settings. |
| 226 virtual void ReapplyMouseSettings() = 0; | 231 virtual void ReapplyMouseSettings() = 0; |
| 227 | 232 |
| 228 private: | 233 private: |
| 229 virtual void SetInternalTouchpadEnabled(bool enabled) {} | 234 virtual void SetInternalTouchpadEnabled(bool enabled) {} |
| 230 virtual void SetTouchscreensEnabled(bool enabled) {} | 235 virtual void SetTouchscreensEnabled(bool enabled) {} |
| 231 }; | 236 }; |
| 232 | 237 |
| 233 } // namespace system | 238 } // namespace system |
| 234 } // namespace chromeos | 239 } // namespace chromeos |
| 235 | 240 |
| 236 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ | 241 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ |
| OLD | NEW |