Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7896)

Unified Diff: chrome/browser/ui/webui/options/chromeos/system_options_handler.cc

Issue 8965070: Change system settings based on when mouse/touchpad is connected/disconnected. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/chromeos/system_options_handler.cc
===================================================================
--- chrome/browser/ui/webui/options/chromeos/system_options_handler.cc (revision 115428)
+++ chrome/browser/ui/webui/options/chromeos/system_options_handler.cc (working copy)
@@ -22,6 +22,7 @@
#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
+#include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -44,12 +45,19 @@
void TouchpadExistsFileThread(bool* exists) {
*exists = chromeos::system::touchpad_settings::TouchpadExists();
}
+
+void MouseExistsFileThread(bool* exists) {
+ *exists = chromeos::system::mouse_settings::MouseExists();
}
+} // namespace
+
SystemOptionsHandler::SystemOptionsHandler() {
}
SystemOptionsHandler::~SystemOptionsHandler() {
+ chromeos::XInputHierarchyChangedEventListener::GetInstance()
+ ->RemoveObserver(this);
}
void SystemOptionsHandler::GetLocalizedValues(
@@ -126,19 +134,39 @@
web_ui_->CallJavascriptFunction(
"options.SystemOptions.SetAccessibilityCheckboxState", checked);
+ chromeos::XInputHierarchyChangedEventListener::GetInstance()
+ ->AddObserver(this);
+ DeviceHierarchyChanged();
+}
+
+void SystemOptionsHandler::CheckTouchpadExists() {
bool* exists = new bool;
BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
base::Bind(&TouchpadExistsFileThread, exists),
base::Bind(&SystemOptionsHandler::TouchpadExists, AsWeakPtr(), exists));
}
+void SystemOptionsHandler::CheckMouseExists() {
+ bool* exists = new bool;
+ BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&MouseExistsFileThread, exists),
+ base::Bind(&SystemOptionsHandler::MouseExists, AsWeakPtr(), exists));
+}
+
void SystemOptionsHandler::TouchpadExists(bool* exists) {
- if (*exists)
- web_ui_->CallJavascriptFunction(
- "options.SystemOptions.showTouchpadControls");
+ base::FundamentalValue val(*exists);
+ web_ui_->CallJavascriptFunction("options.SystemOptions.showTouchpadControls",
+ val);
delete exists;
}
+void SystemOptionsHandler::MouseExists(bool* exists) {
+ base::FundamentalValue val(*exists);
+ web_ui_->CallJavascriptFunction("options.SystemOptions.showMouseControls",
+ val);
+ delete exists;
+}
+
void SystemOptionsHandler::RegisterMessages() {
DCHECK(web_ui_);
web_ui_->RegisterMessageCallback("accessibilityChange",
@@ -153,6 +181,11 @@
base::Unretained(this)));
}
+void SystemOptionsHandler::DeviceHierarchyChanged() {
+ CheckMouseExists();
+ CheckTouchpadExists();
+}
+
void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) {
std::string checked_str;
args->GetString(0, &checked_str);

Powered by Google App Engine
This is Rietveld 408576698