| 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" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 private: | 148 private: |
| 149 internal::Optional<int> sensitivity_; | 149 internal::Optional<int> sensitivity_; |
| 150 internal::Optional<bool> primary_button_right_; | 150 internal::Optional<bool> primary_button_right_; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 // Interface for configuring input device settings. | 153 // Interface for configuring input device settings. |
| 154 class CHROMEOS_EXPORT InputDeviceSettings { | 154 class CHROMEOS_EXPORT InputDeviceSettings { |
| 155 public: | 155 public: |
| 156 typedef base::Callback<void(bool)> DeviceExistsCallback; | 156 typedef base::Callback<void(bool)> DeviceExistsCallback; |
| 157 | 157 |
| 158 // Interface for faking touchpad and mouse. Accessed through |
| 159 // GetFakeInterface(), implemented only in FakeInputDeviceSettings. |
| 160 class FakeInterface { |
| 161 public: |
| 162 virtual void set_touchpad_exists(bool exists) = 0; |
| 163 virtual void set_mouse_exists(bool exists) = 0; |
| 164 virtual const TouchpadSettings& current_touchpad_settings() const = 0; |
| 165 virtual const MouseSettings& current_mouse_settings() const = 0; |
| 166 }; |
| 167 |
| 158 virtual ~InputDeviceSettings() {} | 168 virtual ~InputDeviceSettings() {} |
| 159 | 169 |
| 160 // Returns current instance of InputDeviceSettings. | 170 // Returns current instance of InputDeviceSettings. |
| 161 static InputDeviceSettings* Get(); | 171 static InputDeviceSettings* Get(); |
| 162 | 172 |
| 163 // Replaces current instance with |test_settings|. Takes ownership of | |
| 164 // |test_settings|. Default implementation could be returned back by passing | |
| 165 // NULL to this method. | |
| 166 static void SetSettingsForTesting(InputDeviceSettings* test_settings); | |
| 167 | |
| 168 // Returns true if UI should implement enhanced keyboard support for cases | 173 // Returns true if UI should implement enhanced keyboard support for cases |
| 169 // where other input devices like mouse are absent. | 174 // where other input devices like mouse are absent. |
| 170 static bool ForceKeyboardDrivenUINavigation(); | 175 static bool ForceKeyboardDrivenUINavigation(); |
| 171 | 176 |
| 172 // Registers local pref names for touchpad and touch screen statuses. | 177 // Registers local pref names for touchpad and touch screen statuses. |
| 173 static void RegisterPrefs(PrefRegistrySimple* registry); | 178 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 174 | 179 |
| 175 void InitTouchDevicesStatusFromLocalPrefs(); | 180 void InitTouchDevicesStatusFromLocalPrefs(); |
| 176 | 181 |
| 177 // Toggles the status of Touchscreen/Touchpad on or off and updates the local | 182 // Toggles the status of Touchscreen/Touchpad on or off and updates the local |
| 178 // prefs. | 183 // prefs. |
| 179 void ToggleTouchscreen(); | 184 void ToggleTouchscreen(); |
| 180 void ToggleTouchpad(); | 185 void ToggleTouchpad(); |
| 181 | 186 |
| 182 // Calls |callback| asynchronously after determining if a touchpad is | 187 // Calls |callback|, possibly asynchronously, after determining if a touchpad |
| 183 // connected. | 188 // is connected. |
| 184 virtual void TouchpadExists(const DeviceExistsCallback& callback) = 0; | 189 virtual void TouchpadExists(const DeviceExistsCallback& callback) = 0; |
| 185 | 190 |
| 186 // Updates several touchpad settings at a time. Updates only settings that | 191 // 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 | 192 // 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. | 193 // update several settings then calling Set* methods one by one. |
| 189 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) = 0; | 194 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) = 0; |
| 190 | 195 |
| 191 // Sets the touchpad sensitivity in the range [kMinPointerSensitivity, | 196 // Sets the touchpad sensitivity in the range [kMinPointerSensitivity, |
| 192 // kMaxPointerSensitivity]. | 197 // kMaxPointerSensitivity]. |
| 193 virtual void SetTouchpadSensitivity(int value) = 0; | 198 virtual void SetTouchpadSensitivity(int value) = 0; |
| 194 | 199 |
| 195 // Turns tap to click on/off. | 200 // Turns tap to click on/off. |
| 196 virtual void SetTapToClick(bool enabled) = 0; | 201 virtual void SetTapToClick(bool enabled) = 0; |
| 197 | 202 |
| 198 // Switch for three-finger click. | 203 // Switch for three-finger click. |
| 199 virtual void SetThreeFingerClick(bool enabled) = 0; | 204 virtual void SetThreeFingerClick(bool enabled) = 0; |
| 200 | 205 |
| 201 // Turns tap-dragging on/off. | 206 // Turns tap-dragging on/off. |
| 202 virtual void SetTapDragging(bool enabled) = 0; | 207 virtual void SetTapDragging(bool enabled) = 0; |
| 203 | 208 |
| 204 // Turns natural scrolling on/off for all devices except wheel mice | 209 // Turns natural scrolling on/off for all devices except wheel mice |
| 205 virtual void SetNaturalScroll(bool enabled) = 0; | 210 virtual void SetNaturalScroll(bool enabled) = 0; |
| 206 | 211 |
| 207 // Calls |callback| asynchronously after determining if a mouse is connected. | 212 // Calls |callback|, possibly asynchronously, after determining if a mouse is |
| 213 // connected. |
| 208 virtual void MouseExists(const DeviceExistsCallback& callback) = 0; | 214 virtual void MouseExists(const DeviceExistsCallback& callback) = 0; |
| 209 | 215 |
| 210 // Updates several mouse settings at a time. Updates only settings that | 216 // 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 | 217 // 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. | 218 // update several settings then calling Set* methods one by one. |
| 213 virtual void UpdateMouseSettings(const MouseSettings& settings) = 0; | 219 virtual void UpdateMouseSettings(const MouseSettings& settings) = 0; |
| 214 | 220 |
| 215 // Sets the mouse sensitivity in the range [kMinPointerSensitivity, | 221 // Sets the mouse sensitivity in the range [kMinPointerSensitivity, |
| 216 // kMaxPointerSensitivity]. | 222 // kMaxPointerSensitivity]. |
| 217 virtual void SetMouseSensitivity(int value) = 0; | 223 virtual void SetMouseSensitivity(int value) = 0; |
| 218 | 224 |
| 219 // Sets the primary mouse button to the right button if |right| is true. | 225 // Sets the primary mouse button to the right button if |right| is true. |
| 220 virtual void SetPrimaryButtonRight(bool right) = 0; | 226 virtual void SetPrimaryButtonRight(bool right) = 0; |
| 221 | 227 |
| 222 // Reapplies previously set touchpad settings. | 228 // Reapplies previously set touchpad settings. |
| 223 virtual void ReapplyTouchpadSettings() = 0; | 229 virtual void ReapplyTouchpadSettings() = 0; |
| 224 | 230 |
| 225 // Reapplies previously set mouse settings. | 231 // Reapplies previously set mouse settings. |
| 226 virtual void ReapplyMouseSettings() = 0; | 232 virtual void ReapplyMouseSettings() = 0; |
| 227 | 233 |
| 234 // Returns an interface for faking settings, or nullptr. |
| 235 virtual FakeInterface* GetFakeInterface() = 0; |
| 236 |
| 228 private: | 237 private: |
| 229 virtual void SetInternalTouchpadEnabled(bool enabled) {} | 238 virtual void SetInternalTouchpadEnabled(bool enabled) {} |
| 230 virtual void SetTouchscreensEnabled(bool enabled) {} | 239 virtual void SetTouchscreensEnabled(bool enabled) {} |
| 231 }; | 240 }; |
| 232 | 241 |
| 233 } // namespace system | 242 } // namespace system |
| 234 } // namespace chromeos | 243 } // namespace chromeos |
| 235 | 244 |
| 236 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ | 245 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ |
| OLD | NEW |