| Index: chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
|
| diff --git a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6878636514d9ff40f095bb3fc2549f53afd9e3b0
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
|
| @@ -0,0 +1,50 @@
|
| +// Copyright 2017 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/ui/webui/settings/chromeos/device_stylus_handler.h"
|
| +
|
| +#include "ash/common/system/chromeos/palette/palette_utils.h"
|
| +#include "base/bind.h"
|
| +#include "ui/events/devices/input_device_manager.h"
|
| +
|
| +namespace chromeos {
|
| +namespace settings {
|
| +
|
| +StylusHandler::StylusHandler() {
|
| + ui::InputDeviceManager::GetInstance()->AddObserver(this);
|
| +}
|
| +
|
| +StylusHandler::~StylusHandler() {
|
| + ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
|
| +}
|
| +
|
| +void StylusHandler::RegisterMessages() {
|
| + web_ui()->RegisterMessageCallback(
|
| + "initializeStylusSettings",
|
| + base::Bind(&StylusHandler::HandleInitialize, base::Unretained(this)));
|
| +}
|
| +
|
| +void StylusHandler::OnJavascriptAllowed() {}
|
| +
|
| +void StylusHandler::OnJavascriptDisallowed() {}
|
| +
|
| +void StylusHandler::OnDeviceListsComplete() {
|
| + SendHasStylus();
|
| +}
|
| +
|
| +void StylusHandler::HandleInitialize(const base::ListValue* args) {
|
| + AllowJavascript();
|
| + if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete())
|
| + SendHasStylus();
|
| +}
|
| +
|
| +void StylusHandler::SendHasStylus() {
|
| + DCHECK(ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete());
|
| + CallJavascriptFunction("cr.webUIListenerCallback",
|
| + base::StringValue("has-stylus-changed"),
|
| + base::FundamentalValue(ash::HasStylusInput()));
|
| +}
|
| +
|
| +} // namespace settings
|
| +} // namespace chromeos
|
|
|