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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc

Issue 2110833003: MD Settings: Add mouse settings, update pointer settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PointersFake
Patch Set: Created 4 years, 5 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 2016 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_pointer_handler.h"
6
7 #include "base/bind.h"
8 #include "base/sys_info.h"
9 #include "base/values.h"
10 #include "chrome/browser/chromeos/system/fake_input_device_settings.h"
11 #include "content/public/browser/web_ui.h"
12
13 namespace chromeos {
14 namespace settings {
15
16 PointerHandler::PointerHandler()
17 : has_touchpad_(false),
18 has_mouse_(false) {}
19
20 PointerHandler::~PointerHandler() {}
21
22 void PointerHandler::RegisterMessages() {
23 web_ui()->RegisterMessageCallback(
24 "initializePointerSettings",
25 base::Bind(&PointerHandler::HandleInitialize,
26 base::Unretained(this)));
27 }
28
29 void PointerHandler::OnJavascriptAllowed() {
30 // If the handler is being reused, no need to re-create the observer.
31 if (!pointer_device_observer_) {
32 if (!base::SysInfo::IsRunningOnChromeOS() &&
33 !system::InputDeviceSettings::DidSetSettingsForTesting()) {
34 // Create a fake InputDeviceSettings in order to show pointer settings.
35 system::InputDeviceSettings::GetForTesting();
stevenjb 2016/06/30 00:07:49 We should move this logic to system::InputDeviceSe
michaelpg 2016/07/09 04:11:30 Done.
36 }
37
38 pointer_device_observer_.reset(
39 new system::PointerDeviceObserver());
40 pointer_device_observer_->Init();
41 }
42
43 pointer_device_observer_->AddObserver(this);
44 pointer_device_observer_->CheckDevices();
45 }
46
47 void PointerHandler::OnJavascriptDisallowed() {
48 pointer_device_observer_->RemoveObserver(this);
49 }
50
51 void PointerHandler::TouchpadExists(bool exists) {
52 has_touchpad_ = exists;
stevenjb 2016/06/30 00:07:49 Where are these members actually used? i.e. why no
michaelpg 2016/07/09 04:11:30 Vestigial from older patches, removed, thanks!
53 CallJavascriptFunction("cr.webUIListenerCallback",
54 base::StringValue("has-touchpad-changed"),
55 base::FundamentalValue(has_touchpad_));
stevenjb 2016/06/30 00:07:49 Sigh. At some point we're going to need to move th
michaelpg 2016/07/09 04:11:30 cr.sendWithPromise is supposed to be the new way o
stevenjb 2016/07/11 17:43:35 Maybe, but some day we will will want this API ava
56 }
57
58 void PointerHandler::MouseExists(bool exists) {
59 has_mouse_ = exists;
60 CallJavascriptFunction("cr.webUIListenerCallback",
61 base::StringValue("has-mouse-changed"),
62 base::FundamentalValue(has_mouse_));
63 }
64
65 void PointerHandler::HandleInitialize(const base::ListValue* args) {
66 AllowJavascript();
67 }
68
69 } // namespace settings
70 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698