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); |