| 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 #include "chrome/browser/chromeos/system/input_device_settings.h" | 5 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 // Overridden from InputDeviceSettings. | 145 // Overridden from InputDeviceSettings. |
| 146 virtual void TouchpadExists(const DeviceExistsCallback& callback) OVERRIDE; | 146 virtual void TouchpadExists(const DeviceExistsCallback& callback) OVERRIDE; |
| 147 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) | 147 virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) |
| 148 OVERRIDE; | 148 OVERRIDE; |
| 149 virtual void SetTouchpadSensitivity(int value) OVERRIDE; | 149 virtual void SetTouchpadSensitivity(int value) OVERRIDE; |
| 150 virtual void SetTapToClick(bool enabled) OVERRIDE; | 150 virtual void SetTapToClick(bool enabled) OVERRIDE; |
| 151 virtual void SetThreeFingerClick(bool enabled) OVERRIDE; | 151 virtual void SetThreeFingerClick(bool enabled) OVERRIDE; |
| 152 virtual void SetTapDragging(bool enabled) OVERRIDE; | 152 virtual void SetTapDragging(bool enabled) OVERRIDE; |
| 153 virtual void SetNaturalScroll(bool enabled) OVERRIDE; |
| 153 virtual void MouseExists(const DeviceExistsCallback& callback) OVERRIDE; | 154 virtual void MouseExists(const DeviceExistsCallback& callback) OVERRIDE; |
| 154 virtual void UpdateMouseSettings(const MouseSettings& update) OVERRIDE; | 155 virtual void UpdateMouseSettings(const MouseSettings& update) OVERRIDE; |
| 155 virtual void SetMouseSensitivity(int value) OVERRIDE; | 156 virtual void SetMouseSensitivity(int value) OVERRIDE; |
| 156 virtual void SetPrimaryButtonRight(bool right) OVERRIDE; | 157 virtual void SetPrimaryButtonRight(bool right) OVERRIDE; |
| 157 virtual bool ForceKeyboardDrivenUINavigation() OVERRIDE; | 158 virtual bool ForceKeyboardDrivenUINavigation() OVERRIDE; |
| 158 virtual void ReapplyTouchpadSettings() OVERRIDE; | 159 virtual void ReapplyTouchpadSettings() OVERRIDE; |
| 159 virtual void ReapplyMouseSettings() OVERRIDE; | 160 virtual void ReapplyMouseSettings() OVERRIDE; |
| 160 | 161 |
| 161 private: | 162 private: |
| 162 TouchpadSettings current_touchpad_settings_; | 163 TouchpadSettings current_touchpad_settings_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 settings.SetThreeFingerClick(enabled); | 198 settings.SetThreeFingerClick(enabled); |
| 198 UpdateTouchpadSettings(settings); | 199 UpdateTouchpadSettings(settings); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void InputDeviceSettingsImpl::SetTapDragging(bool enabled) { | 202 void InputDeviceSettingsImpl::SetTapDragging(bool enabled) { |
| 202 TouchpadSettings settings; | 203 TouchpadSettings settings; |
| 203 settings.SetTapDragging(enabled); | 204 settings.SetTapDragging(enabled); |
| 204 UpdateTouchpadSettings(settings); | 205 UpdateTouchpadSettings(settings); |
| 205 } | 206 } |
| 206 | 207 |
| 208 void InputDeviceSettingsImpl::SetNaturalScroll(bool enabled) { |
| 209 TouchpadSettings settings; |
| 210 settings.SetNaturalScroll(enabled); |
| 211 UpdateTouchpadSettings(settings); |
| 212 } |
| 213 |
| 207 void InputDeviceSettingsImpl::MouseExists( | 214 void InputDeviceSettingsImpl::MouseExists( |
| 208 const DeviceExistsCallback& callback) { | 215 const DeviceExistsCallback& callback) { |
| 209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 216 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 210 DeviceExists(kMouse, callback); | 217 DeviceExists(kMouse, callback); |
| 211 } | 218 } |
| 212 | 219 |
| 213 void InputDeviceSettingsImpl::UpdateMouseSettings(const MouseSettings& update) { | 220 void InputDeviceSettingsImpl::UpdateMouseSettings(const MouseSettings& update) { |
| 214 std::vector<std::string> argv; | 221 std::vector<std::string> argv; |
| 215 if (current_mouse_settings_.Update(update, &argv)) | 222 if (current_mouse_settings_.Update(update, &argv)) |
| 216 ExecuteScript(argv); | 223 ExecuteScript(argv); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 311 } |
| 305 | 312 |
| 306 void TouchpadSettings::SetTapDragging(bool enabled) { | 313 void TouchpadSettings::SetTapDragging(bool enabled) { |
| 307 tap_dragging_.Set(enabled); | 314 tap_dragging_.Set(enabled); |
| 308 } | 315 } |
| 309 | 316 |
| 310 bool TouchpadSettings::GetTapDragging() const { | 317 bool TouchpadSettings::GetTapDragging() const { |
| 311 return tap_dragging_.value(); | 318 return tap_dragging_.value(); |
| 312 } | 319 } |
| 313 | 320 |
| 321 void TouchpadSettings::SetNaturalScroll(bool enabled) { |
| 322 natural_scroll_.Set(enabled); |
| 323 } |
| 324 |
| 325 bool TouchpadSettings::GetNaturalScroll() const { |
| 326 return natural_scroll_.value(); |
| 327 } |
| 328 |
| 314 bool TouchpadSettings::Update(const TouchpadSettings& settings, | 329 bool TouchpadSettings::Update(const TouchpadSettings& settings, |
| 315 std::vector<std::string>* argv) { | 330 std::vector<std::string>* argv) { |
| 316 if (argv) | 331 if (argv) |
| 317 argv->push_back(kInputControl); | 332 argv->push_back(kInputControl); |
| 318 bool updated = false; | 333 bool updated = false; |
| 319 if (sensitivity_.Update(settings.sensitivity_)) { | 334 if (sensitivity_.Update(settings.sensitivity_)) { |
| 320 updated = true; | 335 updated = true; |
| 321 if (argv) | 336 if (argv) |
| 322 AddSensitivityArguments(kTouchpad, sensitivity_.value(), argv); | 337 AddSensitivityArguments(kTouchpad, sensitivity_.value(), argv); |
| 323 } | 338 } |
| 324 if (tap_to_click_.Update(settings.tap_to_click_)) { | 339 if (tap_to_click_.Update(settings.tap_to_click_)) { |
| 325 updated = true; | 340 updated = true; |
| 326 if (argv) | 341 if (argv) |
| 327 AddTPControlArguments("tapclick", tap_to_click_.value(), argv); | 342 AddTPControlArguments("tapclick", tap_to_click_.value(), argv); |
| 328 } | 343 } |
| 329 if (three_finger_click_.Update(settings.three_finger_click_)) { | 344 if (three_finger_click_.Update(settings.three_finger_click_)) { |
| 330 updated = true; | 345 updated = true; |
| 331 if (argv) | 346 if (argv) |
| 332 AddTPControlArguments("t5r2_three_finger_click", | 347 AddTPControlArguments("t5r2_three_finger_click", |
| 333 three_finger_click_.value(), | 348 three_finger_click_.value(), |
| 334 argv); | 349 argv); |
| 335 } | 350 } |
| 336 if (tap_dragging_.Update(settings.tap_dragging_)) { | 351 if (tap_dragging_.Update(settings.tap_dragging_)) { |
| 337 updated = true; | 352 updated = true; |
| 338 if (argv) | 353 if (argv) |
| 339 AddTPControlArguments("tapdrag", tap_dragging_.value(), argv); | 354 AddTPControlArguments("tapdrag", tap_dragging_.value(), argv); |
| 340 } | 355 } |
| 356 if (natural_scroll_.Update(settings.natural_scroll_)) { |
| 357 updated = true; |
| 358 if (argv) |
| 359 AddTPControlArguments("australian_scrolling", |
| 360 natural_scroll_.value(), argv); |
| 361 } |
| 341 return updated; | 362 return updated; |
| 342 } | 363 } |
| 343 | 364 |
| 344 MouseSettings::MouseSettings() {} | 365 MouseSettings::MouseSettings() {} |
| 345 | 366 |
| 346 MouseSettings& MouseSettings::operator=(const MouseSettings& other) { | 367 MouseSettings& MouseSettings::operator=(const MouseSettings& other) { |
| 347 if (&other != this) { | 368 if (&other != this) { |
| 348 sensitivity_ = other.sensitivity_; | 369 sensitivity_ = other.sensitivity_; |
| 349 primary_button_right_ = other.primary_button_right_; | 370 primary_button_right_ = other.primary_button_right_; |
| 350 } | 371 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 void InputDeviceSettings::SetSettingsForTesting( | 421 void InputDeviceSettings::SetSettingsForTesting( |
| 401 InputDeviceSettings* test_settings) { | 422 InputDeviceSettings* test_settings) { |
| 402 if (g_test_instance_ == test_settings) | 423 if (g_test_instance_ == test_settings) |
| 403 return; | 424 return; |
| 404 delete g_test_instance_; | 425 delete g_test_instance_; |
| 405 g_test_instance_ = test_settings; | 426 g_test_instance_ = test_settings; |
| 406 } | 427 } |
| 407 | 428 |
| 408 } // namespace system | 429 } // namespace system |
| 409 } // namespace chromeos | 430 } // namespace chromeos |
| OLD | NEW |