Chromium Code Reviews| Index: chrome/browser/ui/webui/options/chromeos/system_options_handler.cc |
| =================================================================== |
| --- chrome/browser/ui/webui/options/chromeos/system_options_handler.cc (revision 115229) |
| +++ chrome/browser/ui/webui/options/chromeos/system_options_handler.cc (working copy) |
| @@ -44,12 +44,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 +133,37 @@ |
| web_ui_->CallJavascriptFunction( |
| "options.SystemOptions.SetAccessibilityCheckboxState", checked); |
| + chromeos::XInputHierarchyChangedEventListener::GetInstance() |
| + ->AddObserver(this); |
| + DeviceChanged(); |
| +} |
| + |
| +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"); |
| + web_ui_->CallJavascriptFunction("options.SystemOptions.showTouchpadControls", |
| + base::FundamentalValue(*exists)); |
|
xiyuan
2011/12/21 03:38:24
Think clang would bark on this and ask you to to d
achuithb
2011/12/21 22:15:01
That's unfortunate. Looks like this is part of the
|
| delete exists; |
| } |
| +void SystemOptionsHandler::MouseExists(bool* exists) { |
| + web_ui_->CallJavascriptFunction("options.SystemOptions.showMouseControls", |
| + base::FundamentalValue(*exists)); |
| + delete exists; |
| +} |
| + |
| void SystemOptionsHandler::RegisterMessages() { |
| DCHECK(web_ui_); |
| web_ui_->RegisterMessageCallback("accessibilityChange", |
| @@ -153,6 +178,11 @@ |
| base::Unretained(this))); |
| } |
| +void SystemOptionsHandler::DeviceChanged() { |
| + CheckMouseExists(); |
| + CheckTouchpadExists(); |
| +} |
| + |
| void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { |
| std::string checked_str; |
| args->GetString(0, &checked_str); |