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

Unified Diff: chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc

Issue 2644713002: cros: Use runtime stylus detection for ash palette. (Closed)
Patch Set: Add listeners to options and settings Created 3 years, 10 months 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/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

Powered by Google App Engine
This is Rietveld 408576698