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

Side by Side 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698