OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h" |
| 6 |
| 7 #include "ash/common/system/chromeos/palette/palette_utils.h" |
| 8 #include "base/bind.h" |
| 9 #include "ui/events/devices/input_device_manager.h" |
| 10 |
| 11 namespace chromeos { |
| 12 namespace settings { |
| 13 |
| 14 StylusHandler::StylusHandler() { |
| 15 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
| 16 } |
| 17 |
| 18 StylusHandler::~StylusHandler() { |
| 19 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
| 20 } |
| 21 |
| 22 void StylusHandler::RegisterMessages() { |
| 23 web_ui()->RegisterMessageCallback( |
| 24 "initializeStylusSettings", |
| 25 base::Bind(&StylusHandler::HandleInitialize, base::Unretained(this))); |
| 26 } |
| 27 |
| 28 void StylusHandler::OnJavascriptAllowed() {} |
| 29 |
| 30 void StylusHandler::OnJavascriptDisallowed() {} |
| 31 |
| 32 void StylusHandler::OnDeviceListsComplete() { |
| 33 SendHasStylus(); |
| 34 } |
| 35 |
| 36 void StylusHandler::HandleInitialize(const base::ListValue* args) { |
| 37 AllowJavascript(); |
| 38 if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()) |
| 39 SendHasStylus(); |
| 40 } |
| 41 |
| 42 void StylusHandler::SendHasStylus() { |
| 43 DCHECK(ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()); |
| 44 CallJavascriptFunction("cr.webUIListenerCallback", |
| 45 base::StringValue("has-stylus-changed"), |
| 46 base::FundamentalValue(ash::HasStylusInput())); |
| 47 } |
| 48 |
| 49 } // namespace settings |
| 50 } // namespace chromeos |
OLD | NEW |