Commit 235a5051 authored by achuith@chromium.org's avatar achuith@chromium.org

Use helper DeviceChangeHandler to call mousecontrol/tpcontrol whenever a device is attached.

BUG=240819
TEST=manual

Review URL: https://chromiumcodereview.appspot.com/15381003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203868 0039d316-1c4b-4281-b951-d872f2087c98
parent 4a2a50cb
......@@ -73,6 +73,7 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/chromeos/settings/owner_key_util.h"
#include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
#include "chrome/browser/chromeos/system/device_change_handler.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/browser/chromeos/system_key_event_listener.h"
#include "chrome/browser/chromeos/upgrade_detector_chromeos.h"
......@@ -697,6 +698,9 @@ void ChromeBrowserMainPartsChromeos::PostProfileInit() {
// available.
idle_action_warning_observer_.reset(new IdleActionWarningObserver());
// Listen to changes in device hierarchy.
device_change_handler_.reset(new system::DeviceChangeHandler());
ChromeBrowserMainPartsLinux::PostProfileInit();
}
......
......@@ -45,6 +45,7 @@ class DBusServices;
namespace system {
class AutomaticRebootManager;
class DeviceChangeHandler;
}
class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
......@@ -89,6 +90,7 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
scoped_ptr<StorageMonitorCros> storage_monitor_;
scoped_ptr<system::AutomaticRebootManager> automatic_reboot_manager_;
scoped_ptr<IdleActionWarningObserver> idle_action_warning_observer_;
scoped_ptr<system::DeviceChangeHandler> device_change_handler_;
scoped_ptr<internal::DBusServices> dbus_services_;
......
......@@ -42,7 +42,6 @@
#include "chrome/browser/chromeos/mobile_config.h"
#include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/browser/chromeos/system/timezone_settings.h"
#include "chrome/browser/lifetime/application_lifetime.h"
......@@ -848,13 +847,6 @@ void ShowLoginWizard(const std::string& first_screen_name) {
manager->GetInputMethodUtil()->GetHardwareInputMethodId();
}
manager->EnableLayouts(locale, initial_input_method_id);
// Apply owner preferences for tap-to-click and mouse buttons swap for
// login screen.
system::mouse_settings::SetPrimaryButtonRight(
prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight));
system::touchpad_settings::SetTapToClick(
prefs->GetBoolean(prefs::kOwnerTapToClickEnabled));
}
ui::SetNaturalScroll(CommandLine::ForCurrentProcess()->HasSwitch(
......
// Copyright 2013 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/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/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
namespace chromeos {
namespace system {
DeviceChangeHandler::DeviceChangeHandler()
: pointer_device_observer_(new PointerDeviceObserver) {
pointer_device_observer_->AddObserver(this);
pointer_device_observer_->Init();
// Apply settings on startup.
TouchpadExists(true);
MouseExists(true);
}
DeviceChangeHandler::~DeviceChangeHandler() {
pointer_device_observer_->RemoveObserver(this);
}
// When we detect a touchpad is attached, apply touchpad settings of the last
// used profile.
void DeviceChangeHandler::TouchpadExists(bool exists) {
if (!exists)
return;
// Using GetDefaultProfile here because GetLastUsedProfile returns the
// LoginManager profile in browser tests.
PrefService* prefs =
g_browser_process->profile_manager()->GetDefaultProfile()->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 bool three_finger_swipe =
prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerSwipe);
system::touchpad_settings::SetThreeFingerSwipe(three_finger_swipe);
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 last
// used profile.
void DeviceChangeHandler::MouseExists(bool exists) {
if (!exists)
return;
// Using GetDefaultProfile here because GetLastUsedProfile returns the
// LoginManager profile in browser tests.
PrefService* prefs =
g_browser_process->profile_manager()->GetDefaultProfile()->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 chromeos
// Copyright 2013 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_DEVICE_CHANGE_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_CHANGE_HANDLER_H_
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/system/pointer_device_observer.h"
namespace chromeos {
namespace system {
// Observes changes in device hierarchy. When a new touchpad/mouse is attached,
// applies the last used profile's touchpad/mouse settings to the system.
class DeviceChangeHandler : public PointerDeviceObserver::Observer {
public:
DeviceChangeHandler();
virtual ~DeviceChangeHandler();
private:
// PointerDeviceObserver::Observer implementation.
virtual void TouchpadExists(bool exists) OVERRIDE;
virtual void MouseExists(bool exists) OVERRIDE;
scoped_ptr<PointerDeviceObserver> pointer_device_observer_;
};
} // namespace system
} // namesspace chromeos
#endif // CHROME_BROWSER_CHROMEOS_SYSTEM_DEVICE_CHANGE_HANDLER_H_
......@@ -717,6 +717,8 @@
'browser/chromeos/system/ash_system_tray_delegate.h',
'browser/chromeos/system/automatic_reboot_manager.cc',
'browser/chromeos/system/automatic_reboot_manager.h',
'browser/chromeos/system/device_change_handler.cc',
'browser/chromeos/system/device_change_handler.h',
'browser/chromeos/system/input_device_settings.cc',
'browser/chromeos/system/input_device_settings.h',
'browser/chromeos/system/pointer_device_observer.cc',
......
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