Commit bd36e178 authored by dzhioev@chromium.org's avatar dzhioev@chromium.org

InputDeviceSettings refactoring.

Standalone functions replaced with InputDeviceSettings interface and
singleton implementation InputDeviceSettingsImpl.
Changing of input device settings became more efficient for two reasons:
1) InputDeviceSettingsImpl caches previously set values and doesn't
call tpcontrol/mousecontrol if client tries to set same values twice.
2) New methods for changing several settings at a time was implemented. For
example, If client wants to change several touchpad settings at a time,
he can use UpdateTouchpadSettings method that will result in one (or
zero) invocation of tpcontrol.

Implemented FakeInputDeviceSettings for use in tests.

These changes are needed for upcoming changes in chromeos::Preferences.

BUG=325564
TEST=manually
TBR=scheib

Review URL: https://codereview.chromium.org/147133003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251399 0039d316-1c4b-4281-b951-d872f2087c98
parent 8aae9e05
...@@ -21,7 +21,8 @@ const int kModifierMask = ui::EF_SHIFT_DOWN; ...@@ -21,7 +21,8 @@ const int kModifierMask = ui::EF_SHIFT_DOWN;
bool ShouldStripModifiersForArrowKeysAndEnter() { bool ShouldStripModifiersForArrowKeysAndEnter() {
if (UserManager::IsInitialized() && if (UserManager::IsInitialized() &&
!UserManager::Get()->IsUserLoggedIn()) { !UserManager::Get()->IsUserLoggedIn()) {
return system::keyboard_settings::ForceKeyboardDrivenUINavigation(); return system::InputDeviceSettings::Get()
->ForceKeyboardDrivenUINavigation();
} }
return false; return false;
......
...@@ -958,7 +958,7 @@ void LoginDisplayHostImpl::InitLoginWindowAndView() { ...@@ -958,7 +958,7 @@ void LoginDisplayHostImpl::InitLoginWindowAndView() {
if (login_window_) if (login_window_)
return; return;
if (system::keyboard_settings::ForceKeyboardDrivenUINavigation()) { if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation()) {
views::FocusManager::set_arrow_key_traversal_enabled(true); views::FocusManager::set_arrow_key_traversal_enabled(true);
focus_ring_controller_.reset(new FocusRingController); focus_ring_controller_.reset(new FocusRingController);
...@@ -1083,10 +1083,10 @@ void ShowLoginWizard(const std::string& first_screen_name) { ...@@ -1083,10 +1083,10 @@ void ShowLoginWizard(const std::string& first_screen_name) {
PrefService* prefs = g_browser_process->local_state(); PrefService* prefs = g_browser_process->local_state();
// Apply owner preferences for tap-to-click and mouse buttons swap for // Apply owner preferences for tap-to-click and mouse buttons swap for
// login screen. // login screen.
system::mouse_settings::SetPrimaryButtonRight( system::InputDeviceSettings::Get()->SetPrimaryButtonRight(
prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight));
system::touchpad_settings::SetTapToClick( system::InputDeviceSettings::Get()->SetTapToClick(
prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); prefs->GetBoolean(prefs::kOwnerTapToClickEnabled));
} }
ui::SetNaturalScroll(CommandLine::ForCurrentProcess()->HasSwitch( ui::SetNaturalScroll(CommandLine::ForCurrentProcess()->HasSwitch(
......
...@@ -407,6 +407,8 @@ void Preferences::OnPreferenceChanged(const std::string& pref_name) { ...@@ -407,6 +407,8 @@ void Preferences::OnPreferenceChanged(const std::string& pref_name) {
} }
void Preferences::NotifyPrefChanged(const std::string* pref_name) { void Preferences::NotifyPrefChanged(const std::string* pref_name) {
system::TouchpadSettings touchpad_settings;
system::MouseSettings mouse_settings;
if (!pref_name || *pref_name == prefs::kPerformanceTracingEnabled) { if (!pref_name || *pref_name == prefs::kPerformanceTracingEnabled) {
const bool enabled = performance_tracing_enabled_.GetValue(); const bool enabled = performance_tracing_enabled_.GetValue();
if (enabled) if (enabled)
...@@ -417,7 +419,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -417,7 +419,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
if ((!pref_name && is_primary_user_prefs_) || if ((!pref_name && is_primary_user_prefs_) ||
(pref_name && *pref_name == prefs::kTapToClickEnabled)) { (pref_name && *pref_name == prefs::kTapToClickEnabled)) {
const bool enabled = tap_to_click_enabled_.GetValue(); const bool enabled = tap_to_click_enabled_.GetValue();
system::touchpad_settings::SetTapToClick(enabled); touchpad_settings.SetTapToClick(enabled);
if (pref_name) if (pref_name)
UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Changed", enabled); UMA_HISTOGRAM_BOOLEAN("Touchpad.TapToClick.Changed", enabled);
else else
...@@ -433,7 +435,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -433,7 +435,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
if ((!pref_name && is_primary_user_prefs_) || if ((!pref_name && is_primary_user_prefs_) ||
(pref_name && *pref_name == prefs::kTapDraggingEnabled)) { (pref_name && *pref_name == prefs::kTapDraggingEnabled)) {
const bool enabled = tap_dragging_enabled_.GetValue(); const bool enabled = tap_dragging_enabled_.GetValue();
system::touchpad_settings::SetTapDragging(enabled); touchpad_settings.SetTapDragging(enabled);
if (pref_name) if (pref_name)
UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Changed", enabled); UMA_HISTOGRAM_BOOLEAN("Touchpad.TapDragging.Changed", enabled);
else else
...@@ -442,7 +444,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -442,7 +444,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
if ((!pref_name && is_primary_user_prefs_) || if ((!pref_name && is_primary_user_prefs_) ||
(pref_name && *pref_name == prefs::kEnableTouchpadThreeFingerClick)) { (pref_name && *pref_name == prefs::kEnableTouchpadThreeFingerClick)) {
const bool enabled = three_finger_click_enabled_.GetValue(); const bool enabled = three_finger_click_enabled_.GetValue();
system::touchpad_settings::SetThreeFingerClick(enabled); touchpad_settings.SetThreeFingerClick(enabled);
if (pref_name) if (pref_name)
UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled); UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerClick.Changed", enabled);
else else
...@@ -465,7 +467,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -465,7 +467,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
if ((!pref_name && is_primary_user_prefs_) || if ((!pref_name && is_primary_user_prefs_) ||
(pref_name && *pref_name == prefs::kMouseSensitivity)) { (pref_name && *pref_name == prefs::kMouseSensitivity)) {
const int sensitivity = mouse_sensitivity_.GetValue(); const int sensitivity = mouse_sensitivity_.GetValue();
system::mouse_settings::SetSensitivity(sensitivity); mouse_settings.SetSensitivity(sensitivity);
if (pref_name) { if (pref_name) {
UMA_HISTOGRAM_ENUMERATION("Mouse.PointerSensitivity.Changed", UMA_HISTOGRAM_ENUMERATION("Mouse.PointerSensitivity.Changed",
sensitivity, sensitivity,
...@@ -479,7 +481,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -479,7 +481,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
if ((!pref_name && is_primary_user_prefs_) || if ((!pref_name && is_primary_user_prefs_) ||
(pref_name && *pref_name == prefs::kTouchpadSensitivity)) { (pref_name && *pref_name == prefs::kTouchpadSensitivity)) {
const int sensitivity = touchpad_sensitivity_.GetValue(); const int sensitivity = touchpad_sensitivity_.GetValue();
system::touchpad_settings::SetSensitivity(sensitivity); touchpad_settings.SetSensitivity(sensitivity);
if (pref_name) { if (pref_name) {
UMA_HISTOGRAM_ENUMERATION("Touchpad.PointerSensitivity.Changed", UMA_HISTOGRAM_ENUMERATION("Touchpad.PointerSensitivity.Changed",
sensitivity, sensitivity,
...@@ -493,7 +495,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -493,7 +495,7 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
if ((!pref_name && is_primary_user_prefs_) || if ((!pref_name && is_primary_user_prefs_) ||
(pref_name && *pref_name == prefs::kPrimaryMouseButtonRight)) { (pref_name && *pref_name == prefs::kPrimaryMouseButtonRight)) {
const bool right = primary_mouse_button_right_.GetValue(); const bool right = primary_mouse_button_right_.GetValue();
system::mouse_settings::SetPrimaryButtonRight(right); mouse_settings.SetPrimaryButtonRight(right);
if (pref_name) if (pref_name)
UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right); UMA_HISTOGRAM_BOOLEAN("Mouse.PrimaryButtonRight.Changed", right);
else else
...@@ -556,6 +558,8 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -556,6 +558,8 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
input_method_manager_->SetEnabledExtensionImes(&split_values); input_method_manager_->SetEnabledExtensionImes(&split_values);
} }
system::InputDeviceSettings::Get()->UpdateTouchpadSettings(touchpad_settings);
system::InputDeviceSettings::Get()->UpdateMouseSettings(mouse_settings);
} }
void Preferences::OnIsSyncingChanged() { void Preferences::OnIsSyncingChanged() {
......
...@@ -4,11 +4,7 @@ ...@@ -4,11 +4,7 @@
#include "chrome/browser/chromeos/system/device_change_handler.h" #include "chrome/browser/chromeos/system/device_change_handler.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
namespace chromeos { namespace chromeos {
namespace system { namespace system {
...@@ -27,55 +23,20 @@ DeviceChangeHandler::~DeviceChangeHandler() { ...@@ -27,55 +23,20 @@ DeviceChangeHandler::~DeviceChangeHandler() {
pointer_device_observer_->RemoveObserver(this); pointer_device_observer_->RemoveObserver(this);
} }
// When we detect a touchpad is attached, apply touchpad settings of the // When we detect a touchpad is attached, apply touchpad settings that was
// primary profile. // cached inside InputDeviceSettings.
void DeviceChangeHandler::TouchpadExists(bool exists) { void DeviceChangeHandler::TouchpadExists(bool exists) {
if (!exists) if (!exists)
return; return;
system::InputDeviceSettings::Get()->ReapplyTouchpadSettings();
// Using GetPrimaryUserProfile here because this is a system setting which can
// only be set by the user which starts the session.
PrefService* prefs = ProfileManager::GetPrimaryUserProfile()->GetPrefs();
const bool tap_dragging = prefs->GetBoolean(prefs::kTapDraggingEnabled);
system::touchpad_settings::SetTapDragging(tap_dragging);
const bool three_finger_click =
prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerClick);
system::touchpad_settings::SetThreeFingerClick(three_finger_click);
const int sensitivity = prefs->GetInteger(prefs::kTouchpadSensitivity);
system::touchpad_settings::SetSensitivity(sensitivity);
// If we are not logged in, use owner preferences.
PrefService* local_prefs = g_browser_process->local_state();
const bool tap_to_click =
g_browser_process->profile_manager()->IsLoggedIn() ?
prefs->GetBoolean(prefs::kTapToClickEnabled) :
local_prefs->GetBoolean(prefs::kOwnerTapToClickEnabled);
system::touchpad_settings::SetTapToClick(tap_to_click);
} }
// When we detect a mouse is attached, apply mouse settings of the primary // When we detect a mouse is attached, apply mouse settings that was cached
// profile. // inside InputDeviceSettings.
void DeviceChangeHandler::MouseExists(bool exists) { void DeviceChangeHandler::MouseExists(bool exists) {
if (!exists) if (!exists)
return; return;
system::InputDeviceSettings::Get()->ReapplyMouseSettings();
// Using GetPrimaryUserProfile here because this is the property which can
// only be set by the user which starts the session.
PrefService* prefs = ProfileManager::GetPrimaryUserProfile()->GetPrefs();
const int sensitivity = prefs->GetInteger(prefs::kMouseSensitivity);
system::mouse_settings::SetSensitivity(sensitivity);
// If we are not logged in, use owner preferences.
PrefService* local_prefs = g_browser_process->local_state();
const bool primary_button_right =
g_browser_process->profile_manager()->IsLoggedIn() ?
prefs->GetBoolean(prefs::kPrimaryMouseButtonRight) :
local_prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight);
system::mouse_settings::SetPrimaryButtonRight(primary_button_right);
} }
} // namespace system } // namespace system
......
...@@ -12,7 +12,7 @@ namespace chromeos { ...@@ -12,7 +12,7 @@ namespace chromeos {
namespace system { namespace system {
// Observes changes in device hierarchy. When a new touchpad/mouse is attached, // Observes changes in device hierarchy. When a new touchpad/mouse is attached,
// applies the last used profile's touchpad/mouse settings to the system. // applies the last used touchpad/mouse settings to the system.
class DeviceChangeHandler : public PointerDeviceObserver::Observer { class DeviceChangeHandler : public PointerDeviceObserver::Observer {
public: public:
DeviceChangeHandler(); DeviceChangeHandler();
...@@ -27,7 +27,7 @@ class DeviceChangeHandler : public PointerDeviceObserver::Observer { ...@@ -27,7 +27,7 @@ class DeviceChangeHandler : public PointerDeviceObserver::Observer {
}; };
} // namespace system } // namespace system
} // namesspace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_CHANGE_HANDLER_H_ #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_CHANGE_HANDLER_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/system/fake_input_device_settings.h"
namespace chromeos {
namespace system {
FakeInputDeviceSettings::FakeInputDeviceSettings() {}
FakeInputDeviceSettings::~FakeInputDeviceSettings() {}
// Overriden from InputDeviceSettings.
void FakeInputDeviceSettings::TouchpadExists(
const DeviceExistsCallback& callback) {
callback.Run(true);
}
void FakeInputDeviceSettings::UpdateTouchpadSettings(
const TouchpadSettings& settings) {
current_touchpad_settings_.Update(settings, NULL);
}
void FakeInputDeviceSettings::SetTouchpadSensitivity(int value) {
TouchpadSettings settings;
settings.SetSensitivity(value);
UpdateTouchpadSettings(settings);
}
void FakeInputDeviceSettings::SetTapToClick(bool enabled) {
TouchpadSettings settings;
settings.SetTapToClick(enabled);
UpdateTouchpadSettings(settings);
}
void FakeInputDeviceSettings::SetThreeFingerClick(bool enabled) {
TouchpadSettings settings;
settings.SetThreeFingerClick(enabled);
UpdateTouchpadSettings(settings);
}
void FakeInputDeviceSettings::SetTapDragging(bool enabled) {
TouchpadSettings settings;
settings.SetTapDragging(enabled);
UpdateTouchpadSettings(settings);
}
void FakeInputDeviceSettings::MouseExists(
const DeviceExistsCallback& callback) {
callback.Run(false);
}
void FakeInputDeviceSettings::UpdateMouseSettings(
const MouseSettings& settings) {
current_mouse_settings_.Update(settings, NULL);
}
void FakeInputDeviceSettings::SetMouseSensitivity(int value) {
MouseSettings settings;
settings.SetSensitivity(value);
UpdateMouseSettings(settings);
}
void FakeInputDeviceSettings::SetPrimaryButtonRight(bool right) {
MouseSettings settings;
settings.SetPrimaryButtonRight(right);
UpdateMouseSettings(settings);
}
bool FakeInputDeviceSettings::ForceKeyboardDrivenUINavigation() {
return false;
}
void FakeInputDeviceSettings::ReapplyTouchpadSettings() {
}
void FakeInputDeviceSettings::ReapplyMouseSettings() {
}
} // namespace system
} // namespace chromeos
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_FAKE_INPUT_DEVICE_SETTINGS_H_
#define CHROME_BROWSER_CHROMEOS_SYSTEM_FAKE_INPUT_DEVICE_SETTINGS_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
namespace chromeos {
namespace system {
// This fake just memorizes current values of input devices settings.
class FakeInputDeviceSettings : public InputDeviceSettings {
public:
FakeInputDeviceSettings();
virtual ~FakeInputDeviceSettings();
// Overridden from InputDeviceSettings.
virtual void TouchpadExists(const DeviceExistsCallback& callback) OVERRIDE;
virtual void UpdateTouchpadSettings(const TouchpadSettings& settings)
OVERRIDE;
virtual void SetTouchpadSensitivity(int value) OVERRIDE;
virtual void SetTapToClick(bool enabled) OVERRIDE;
virtual void SetThreeFingerClick(bool enabled) OVERRIDE;
virtual void SetTapDragging(bool enabled) OVERRIDE;
virtual void MouseExists(const DeviceExistsCallback& callback) OVERRIDE;
virtual void UpdateMouseSettings(const MouseSettings& settings) OVERRIDE;
virtual void SetMouseSensitivity(int value) OVERRIDE;
virtual void SetPrimaryButtonRight(bool right) OVERRIDE;
virtual bool ForceKeyboardDrivenUINavigation() OVERRIDE;
virtual void ReapplyTouchpadSettings() OVERRIDE;
virtual void ReapplyMouseSettings() OVERRIDE;
const TouchpadSettings& current_touchpad_settings() const {
return current_touchpad_settings_;
}
const MouseSettings& current_mouse_settings() const {
return current_mouse_settings_;
}
private:
TouchpadSettings current_touchpad_settings_;
MouseSettings current_mouse_settings_;
DISALLOW_COPY_AND_ASSIGN(FakeInputDeviceSettings);
};
} // namespace system
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SYSTEM_FAKE_INPUT_DEVICE_SETTINGS_H_
...@@ -5,57 +5,199 @@ ...@@ -5,57 +5,199 @@
#ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_
#define CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_ #define CHROME_BROWSER_CHROMEOS_SYSTEM_INPUT_DEVICE_SETTINGS_H_
#include <string>
#include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "base/logging.h"
namespace chromeos { namespace chromeos {
namespace system { namespace system {
namespace internal {
// Objects of this class are intended to store values of type T, but might have
// "unset" state. Object will be in "unset" state until Set is called first
// time.
template <typename T>
class Optional {
public:
Optional()
: value_(),
is_set_(false) {
}
Optional& operator=(const Optional& other) {
if (&other != this) {
value_ = other.value_;
is_set_ = other.is_set_;
}
return *this;
}
void Set(const T& value) {
is_set_ = true;
value_ = value;
}
bool is_set() const {
return is_set_;
}
T value() const {
DCHECK(is_set());
return value_;
}
// Tries to update |this| with |update|. If |update| is unset or has same
// value as |this| method returns false. Otherwise |this| takes value of
// |update| and returns true.
bool Update(const Optional& update) {
if (update.is_set_ && (!is_set_ || value_ != update.value_)) {
value_ = update.value_;
is_set_ = true;
return true;
}
return false;
}
private:
T value_;
bool is_set_;
};
} // namespace internal
// Min/max possible pointer sensitivity values. Defined in CrOS inputcontrol // Min/max possible pointer sensitivity values. Defined in CrOS inputcontrol
// scripts (see kTpControl/kMouseControl in the source file). // scripts (see kTpControl/kMouseControl in the source file).
const int kMinPointerSensitivity = 1; const int kMinPointerSensitivity = 1;
const int kMaxPointerSensitivity = 5; const int kMaxPointerSensitivity = 5;
typedef base::Callback<void(bool)> DeviceExistsCallback; // Auxiliary class used to update several touchpad settings at a time. User
// should set any number of settings and pass object to UpdateTouchpadSettings
namespace touchpad_settings { // method of InputDeviceSettings.
// Objects of this class have no default values for settings, so it is error
// Calls |callback| asynchronously after determining if a touchpad is connected. // to call Get* method before calling corresponding Set* method at least
void TouchpadExists(const DeviceExistsCallback& callback); // once.
class TouchpadSettings {
// Sets the touchpad sensitivity in the range [1, 5]. public:
void SetSensitivity(int value); TouchpadSettings();
TouchpadSettings& operator=(const TouchpadSettings& other);
// Turns tap to click on/off.
void SetTapToClick(bool enabled); void SetSensitivity(int value);
int GetSensitivity() const;
// Switch for three-finger click.
void SetThreeFingerClick(bool enabled); void SetTapToClick(bool enabled);
bool GetTapToClick() const;
// Turns tap-dragging on/off.
void SetTapDragging(bool enabled); void SetThreeFingerClick(bool enabled);
bool GetThreeFingerClick() const;
} // namespace touchpad_settings
void SetTapDragging(bool enabled);
namespace mouse_settings { bool GetTapDragging() const;
// Calls |callback| asynchronously after determining if a mouse is connected. // Updates |this| with |settings|. If at least one setting was updated returns
void MouseExists(const DeviceExistsCallback& callback); // true.
// |argv| is filled with arguments of script, that should be launched in order
// Sets the mouse sensitivity in the range [1, 5]. // to apply update. This argument is optional and could be NULL.
void SetSensitivity(int value); bool Update(const TouchpadSettings& settings, std::vector<std::string>* argv);
// Sets the primary mouse button to the right button if |right| is true. private:
void SetPrimaryButtonRight(bool right); internal::Optional<int> sensitivity_;
internal::Optional<bool> tap_to_click_;
} // namespace mouse_settings internal::Optional<bool> three_finger_click_;
internal::Optional<bool> tap_dragging_;
namespace keyboard_settings { };
// Returns true if UI should implement enhanced keyboard support for cases where // Auxiliary class used to update several mouse settings at a time. User
// other input devices like mouse are absent. // should set any number of settings and pass object to UpdateMouseSettings
bool ForceKeyboardDrivenUINavigation(); // method of InputDeviceSettings.
// Objects of this class have no default values for settings, so it is error
} // namespace keyboard_settings // to call Get* method before calling corresponding Set* method at least
// once.
class MouseSettings {
public:
MouseSettings();
MouseSettings& operator=(const MouseSettings& other);
void SetSensitivity(int value);
int GetSensitivity() const;
void SetPrimaryButtonRight(bool right);
bool GetPrimaryButtonRight() const;
// Updates |this| with |settings|. If at least one setting was updated returns
// true.
// |argv| is filled with arguments of script, that should be launched in order
// to apply update. This argument is optional and could be NULL.
bool Update(const MouseSettings& update, std::vector<std::string>* argv);
private:
internal::Optional<int> sensitivity_;
internal::Optional<bool> primary_button_right_;
};
class InputDeviceSettings {
public:
typedef base::Callback<void(bool)> DeviceExistsCallback;
virtual ~InputDeviceSettings() {}
// Returns current instance of InputDeviceSettings.
static InputDeviceSettings* Get();
// Replaces current instance with |test_settings|. Takes ownership of
// |test_settings|. Default implementation could be returned back by passing
// NULL to this method.
static void SetSettingsForTesting(InputDeviceSettings* test_settings);
// Calls |callback| asynchronously after determining if a touchpad is
// connected.
virtual void TouchpadExists(const DeviceExistsCallback& callback) = 0;
// Updates several touchpad settings at a time. Updates only settings that
// are set in |settings| object. It is more efficient to use this method to
// update several settings then calling Set* methods one by one.
virtual void UpdateTouchpadSettings(const TouchpadSettings& settings) = 0;
// Sets the touchpad sensitivity in the range [kMinPointerSensitivity,
// kMaxPointerSensitivity].
virtual void SetTouchpadSensitivity(int value) = 0;
// Turns tap to click on/off.
virtual void SetTapToClick(bool enabled) = 0;
// Switch for three-finger click.
virtual void SetThreeFingerClick(bool enabled) = 0;
// Turns tap-dragging on/off.
virtual void SetTapDragging(bool enabled) = 0;
// Calls |callback| asynchronously after determining if a mouse is connected.
virtual void MouseExists(const DeviceExistsCallback& callback) = 0;
// Updates several mouse settings at a time. Updates only settings that
// are set in |settings| object. It is more efficient to use this method to
// update several settings then calling Set* methods one by one.
virtual void UpdateMouseSettings(const MouseSettings& settings) = 0;
// Sets the mouse sensitivity in the range [kMinPointerSensitivity,
// kMaxPointerSensitivity].
virtual void SetMouseSensitivity(int value) = 0;
// Sets the primary mouse button to the right button if |right| is true.
virtual void SetPrimaryButtonRight(bool right) = 0;
// Returns true if UI should implement enhanced keyboard support for cases
// where other input devices like mouse are absent.
virtual bool ForceKeyboardDrivenUINavigation() = 0;
// Reapplies previously set touchpad settings.
virtual void ReapplyTouchpadSettings() = 0;
// Reapplies previously set mouse settings.
virtual void ReapplyMouseSettings() = 0;
};
} // namespace system } // namespace system
} // namespace chromeos } // namespace chromeos
......
...@@ -48,13 +48,13 @@ void PointerDeviceObserver::DeviceHierarchyChanged() { ...@@ -48,13 +48,13 @@ void PointerDeviceObserver::DeviceHierarchyChanged() {
} }
void PointerDeviceObserver::CheckTouchpadExists() { void PointerDeviceObserver::CheckTouchpadExists() {
touchpad_settings::TouchpadExists( InputDeviceSettings::Get()->TouchpadExists(
base::Bind(&PointerDeviceObserver::OnTouchpadExists, base::Bind(&PointerDeviceObserver::OnTouchpadExists,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void PointerDeviceObserver::CheckMouseExists() { void PointerDeviceObserver::CheckMouseExists() {
mouse_settings::MouseExists( InputDeviceSettings::Get()->MouseExists(
base::Bind(&PointerDeviceObserver::OnMouseExists, base::Bind(&PointerDeviceObserver::OnMouseExists,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
......
...@@ -61,10 +61,12 @@ void LoadGaiaAuthExtension(Profile* profile) { ...@@ -61,10 +61,12 @@ void LoadGaiaAuthExtension(Profile* profile) {
} }
int manifest_resource_id = IDR_GAIA_AUTH_MANIFEST; int manifest_resource_id = IDR_GAIA_AUTH_MANIFEST;
if (chromeos::system::keyboard_settings::ForceKeyboardDrivenUINavigation()) if (chromeos::system::InputDeviceSettings::Get()
->ForceKeyboardDrivenUINavigation()) {
manifest_resource_id = IDR_GAIA_AUTH_KEYBOARD_MANIFEST; manifest_resource_id = IDR_GAIA_AUTH_KEYBOARD_MANIFEST;
else if (!command_line->HasSwitch(chromeos::switches::kDisableSamlSignin)) } else if (!command_line->HasSwitch(chromeos::switches::kDisableSamlSignin)) {
manifest_resource_id = IDR_GAIA_AUTH_SAML_MANIFEST; manifest_resource_id = IDR_GAIA_AUTH_SAML_MANIFEST;
}
#else #else
int manifest_resource_id = IDR_GAIA_AUTH_INLINE_MANIFEST; int manifest_resource_id = IDR_GAIA_AUTH_INLINE_MANIFEST;
#endif #endif
......
...@@ -300,7 +300,7 @@ void CoreOobeHandler::UpdateOobeUIVisibility() { ...@@ -300,7 +300,7 @@ void CoreOobeHandler::UpdateOobeUIVisibility() {
} }
CallJS("showVersion", should_show_version); CallJS("showVersion", should_show_version);
CallJS("showOobeUI", show_oobe_ui_); CallJS("showOobeUI", show_oobe_ui_);
if (system::keyboard_settings::ForceKeyboardDrivenUINavigation()) if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation())
CallJS("enableKeyboardFlow", true); CallJS("enableKeyboardFlow", true);
} }
......
...@@ -127,7 +127,7 @@ void NetworkScreenHandler::EnableContinue(bool enabled) { ...@@ -127,7 +127,7 @@ void NetworkScreenHandler::EnableContinue(bool enabled) {
void NetworkScreenHandler::DeclareLocalizedValues( void NetworkScreenHandler::DeclareLocalizedValues(
LocalizedValuesBuilder* builder) { LocalizedValuesBuilder* builder) {
if (system::keyboard_settings::ForceKeyboardDrivenUINavigation()) if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation())
builder->Add("networkScreenGreeting", IDS_REMORA_CONFIRM_MESSAGE); builder->Add("networkScreenGreeting", IDS_REMORA_CONFIRM_MESSAGE);
else else
builder->Add("networkScreenGreeting", IDS_WELCOME_SCREEN_GREETING); builder->Add("networkScreenGreeting", IDS_WELCOME_SCREEN_GREETING);
......
...@@ -375,7 +375,7 @@ void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) { ...@@ -375,7 +375,7 @@ void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
} }
bool keyboard_driven_oobe = bool keyboard_driven_oobe =
system::keyboard_settings::ForceKeyboardDrivenUINavigation(); system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation();
localized_strings->SetString("highlightStrength", localized_strings->SetString("highlightStrength",
keyboard_driven_oobe ? "strong" : "normal"); keyboard_driven_oobe ? "strong" : "normal");
......
...@@ -100,7 +100,7 @@ ProxySettingsUI::ProxySettingsUI(content::WebUI* web_ui) ...@@ -100,7 +100,7 @@ ProxySettingsUI::ProxySettingsUI(content::WebUI* web_ui)
proxy_handler_->GetLocalizedValues(localized_strings); proxy_handler_->GetLocalizedValues(localized_strings);
bool keyboard_driven_oobe = bool keyboard_driven_oobe =
system::keyboard_settings::ForceKeyboardDrivenUINavigation(); system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation();
localized_strings->SetString("highlightStrength", localized_strings->SetString("highlightStrength",
keyboard_driven_oobe ? "strong" : "normal"); keyboard_driven_oobe ? "strong" : "normal");
......
...@@ -69,7 +69,7 @@ void ProxyHandler::InitializePage() { ...@@ -69,7 +69,7 @@ void ProxyHandler::InitializePage() {
::options::OptionsPageUIHandler::InitializePage(); ::options::OptionsPageUIHandler::InitializePage();
bool keyboard_driven_oobe = bool keyboard_driven_oobe =
system::keyboard_settings::ForceKeyboardDrivenUINavigation(); system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation();
if (keyboard_driven_oobe) { if (keyboard_driven_oobe) {
web_ui()->CallJavascriptFunction( web_ui()->CallJavascriptFunction(
"DetailsInternetPage.initializeKeyboardFlow"); "DetailsInternetPage.initializeKeyboardFlow");
......
...@@ -110,6 +110,8 @@ ...@@ -110,6 +110,8 @@
'browser/chromeos/settings/device_settings_test_helper.h', 'browser/chromeos/settings/device_settings_test_helper.h',
'browser/chromeos/settings/mock_owner_key_util.cc', 'browser/chromeos/settings/mock_owner_key_util.cc',
'browser/chromeos/settings/mock_owner_key_util.h', 'browser/chromeos/settings/mock_owner_key_util.h',
'browser/chromeos/system/fake_input_device_settings.cc',
'browser/chromeos/system/fake_input_device_settings.h',
# The only thing used from browser is Browser::Type. # The only thing used from browser is Browser::Type.
'browser/download/download_test_file_activity_observer.cc', 'browser/download/download_test_file_activity_observer.cc',
'browser/download/download_test_file_activity_observer.h', 'browser/download/download_test_file_activity_observer.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment