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

Side by Side Diff: services/ui/public/cpp/input_devices/input_device_client.cc

Issue 2162653002: Switch input_devices mojom to use_new_wrapper_types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/public/cpp/input_devices/input_device_client.h" 5 #include "services/ui/public/cpp/input_devices/input_device_client.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 InputDeviceClient::InputDeviceClient() : binding_(this) { 11 InputDeviceClient::InputDeviceClient() : binding_(this) {
12 InputDeviceManager::SetInstance(this); 12 InputDeviceManager::SetInstance(this);
13 } 13 }
14 14
15 InputDeviceClient::~InputDeviceClient() { 15 InputDeviceClient::~InputDeviceClient() {
16 InputDeviceManager::ClearInstance(); 16 InputDeviceManager::ClearInstance();
17 } 17 }
18 18
19 void InputDeviceClient::Connect(mojom::InputDeviceServerPtr server) { 19 void InputDeviceClient::Connect(mojom::InputDeviceServerPtr server) {
20 DCHECK(server.is_bound()); 20 DCHECK(server.is_bound());
21 21
22 server->AddObserver(binding_.CreateInterfacePtrAndBind()); 22 server->AddObserver(binding_.CreateInterfacePtrAndBind());
23 } 23 }
24 24
25 void InputDeviceClient::OnKeyboardDeviceConfigurationChanged( 25 void InputDeviceClient::OnKeyboardDeviceConfigurationChanged(
26 mojo::Array<ui::InputDevice> devices) { 26 const std::vector<ui::InputDevice>& devices) {
27 keyboard_devices_ = devices.To<std::vector<ui::InputDevice>>(); 27 keyboard_devices_ = devices;
28 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_, 28 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
29 OnKeyboardDeviceConfigurationChanged()); 29 OnKeyboardDeviceConfigurationChanged());
30 } 30 }
31 31
32 void InputDeviceClient::OnTouchscreenDeviceConfigurationChanged( 32 void InputDeviceClient::OnTouchscreenDeviceConfigurationChanged(
33 mojo::Array<ui::TouchscreenDevice> devices) { 33 const std::vector<ui::TouchscreenDevice>& devices) {
34 touchscreen_devices_ = devices.To<std::vector<ui::TouchscreenDevice>>(); 34 touchscreen_devices_ = devices;
35 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_, 35 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
36 OnTouchscreenDeviceConfigurationChanged()); 36 OnTouchscreenDeviceConfigurationChanged());
37 } 37 }
38 38
39 void InputDeviceClient::OnMouseDeviceConfigurationChanged( 39 void InputDeviceClient::OnMouseDeviceConfigurationChanged(
40 mojo::Array<ui::InputDevice> devices) { 40 const std::vector<ui::InputDevice>& devices) {
41 mouse_devices_ = devices.To<std::vector<ui::InputDevice>>(); 41 mouse_devices_ = devices;
42 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_, 42 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
43 OnMouseDeviceConfigurationChanged()); 43 OnMouseDeviceConfigurationChanged());
44 } 44 }
45 45
46 void InputDeviceClient::OnTouchpadDeviceConfigurationChanged( 46 void InputDeviceClient::OnTouchpadDeviceConfigurationChanged(
47 mojo::Array<ui::InputDevice> devices) { 47 const std::vector<ui::InputDevice>& devices) {
48 touchpad_devices_ = devices.To<std::vector<ui::InputDevice>>(); 48 touchpad_devices_ = devices;
49 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_, 49 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
50 OnTouchpadDeviceConfigurationChanged()); 50 OnTouchpadDeviceConfigurationChanged());
51 } 51 }
52 52
53 void InputDeviceClient::OnDeviceListsComplete( 53 void InputDeviceClient::OnDeviceListsComplete(
54 mojo::Array<ui::InputDevice> keyboard_devices, 54 const std::vector<ui::InputDevice>& keyboard_devices,
55 mojo::Array<ui::TouchscreenDevice> touchscreen_devices, 55 const std::vector<ui::TouchscreenDevice>& touchscreen_devices,
56 mojo::Array<ui::InputDevice> mouse_devices, 56 const std::vector<ui::InputDevice>& mouse_devices,
57 mojo::Array<ui::InputDevice> touchpad_devices) { 57 const std::vector<ui::InputDevice>& touchpad_devices) {
58 // Update the cached device lists if the received list isn't empty. 58 // Update the cached device lists if the received list isn't empty.
59 if (!keyboard_devices.empty()) 59 if (!keyboard_devices.empty())
60 OnKeyboardDeviceConfigurationChanged(std::move(keyboard_devices)); 60 OnKeyboardDeviceConfigurationChanged(keyboard_devices);
61 if (!touchscreen_devices.empty()) 61 if (!touchscreen_devices.empty())
62 OnTouchscreenDeviceConfigurationChanged(std::move(touchscreen_devices)); 62 OnTouchscreenDeviceConfigurationChanged(touchscreen_devices);
63 if (!mouse_devices.empty()) 63 if (!mouse_devices.empty())
64 OnMouseDeviceConfigurationChanged(std::move(mouse_devices)); 64 OnMouseDeviceConfigurationChanged(mouse_devices);
65 if (!touchpad_devices.empty()) 65 if (!touchpad_devices.empty())
66 OnTouchpadDeviceConfigurationChanged(std::move(touchpad_devices)); 66 OnTouchpadDeviceConfigurationChanged(touchpad_devices);
67 67
68 if (!device_lists_complete_) { 68 if (!device_lists_complete_) {
69 device_lists_complete_ = true; 69 device_lists_complete_ = true;
70 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_, 70 FOR_EACH_OBSERVER(ui::InputDeviceEventObserver, observers_,
71 OnDeviceListsComplete()); 71 OnDeviceListsComplete());
72 } 72 }
73 } 73 }
74 74
75 void InputDeviceClient::AddObserver(ui::InputDeviceEventObserver* observer) { 75 void InputDeviceClient::AddObserver(ui::InputDeviceEventObserver* observer) {
76 observers_.AddObserver(observer); 76 observers_.AddObserver(observer);
(...skipping 26 matching lines...) Expand all
103 return device_lists_complete_; 103 return device_lists_complete_;
104 } 104 }
105 105
106 bool InputDeviceClient::AreTouchscreensEnabled() const { 106 bool InputDeviceClient::AreTouchscreensEnabled() const {
107 // TODO(kylechar): This obviously isn't right. We either need to pass this 107 // TODO(kylechar): This obviously isn't right. We either need to pass this
108 // state around or modify the interface. 108 // state around or modify the interface.
109 return true; 109 return true;
110 } 110 }
111 111
112 } // namespace ui 112 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/input_devices/input_device_client.h ('k') | services/ui/public/interfaces/input_devices/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698