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

Side by Side Diff: remoting/host/input_injector_chromeos.cc

Issue 931393003: Fix breaking change in It2me Host on Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile failure Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "remoting/host/input_injector_chromeos.h" 5 #include "remoting/host/input_injector_chromeos.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 28 matching lines...) Expand all
39 NOTREACHED(); 39 NOTREACHED();
40 return ui::EF_NONE; 40 return ui::EF_NONE;
41 } 41 }
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 // This class is run exclusively on the UI thread of the browser process. 46 // This class is run exclusively on the UI thread of the browser process.
47 class InputInjectorChromeos::Core { 47 class InputInjectorChromeos::Core {
48 public: 48 public:
49 Core(scoped_ptr<ui::SystemInputInjector> delegate_, 49 Core();
50 ui::InputController* input_controller);
51 50
52 // Mirrors the public InputInjectorChromeos interface. 51 // Mirrors the public InputInjectorChromeos interface.
53 void InjectClipboardEvent(const ClipboardEvent& event); 52 void InjectClipboardEvent(const ClipboardEvent& event);
54 void InjectKeyEvent(const KeyEvent& event); 53 void InjectKeyEvent(const KeyEvent& event);
55 void InjectTextEvent(const TextEvent& event); 54 void InjectTextEvent(const TextEvent& event);
56 void InjectMouseEvent(const MouseEvent& event); 55 void InjectMouseEvent(const MouseEvent& event);
57 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard); 56 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard);
58 57
59 private: 58 private:
60 void HandleAutoRepeat(ui::DomCode dom_code, bool pressed); 59 void HandleAutoRepeat(ui::DomCode dom_code, bool pressed);
61 60
62 scoped_ptr<ui::SystemInputInjector> delegate_; 61 scoped_ptr<ui::SystemInputInjector> delegate_;
63 ui::InputController* input_controller_; 62 ui::InputController* input_controller_;
64 scoped_ptr<Clipboard> clipboard_; 63 scoped_ptr<Clipboard> clipboard_;
65 64
66 // Used to rotate the input coordinates appropriately based on the current 65 // Used to rotate the input coordinates appropriately based on the current
67 // display rotation settings. 66 // display rotation settings.
68 scoped_ptr<PointTransformer> point_transformer_; 67 scoped_ptr<PointTransformer> point_transformer_;
69 68
70 // Used by HandleAutoRepeat(). 69 // Used by HandleAutoRepeat().
71 std::set<ui::DomCode> pressed_keys_; 70 std::set<ui::DomCode> pressed_keys_;
72 bool saved_auto_repeat_enabled_; 71 bool saved_auto_repeat_enabled_;
73 72
74 DISALLOW_COPY_AND_ASSIGN(Core); 73 DISALLOW_COPY_AND_ASSIGN(Core);
75 }; 74 };
76 75
77 InputInjectorChromeos::Core::Core(scoped_ptr<ui::SystemInputInjector> delegate, 76 InputInjectorChromeos::Core::Core() : saved_auto_repeat_enabled_(false) {
78 ui::InputController* input_controller)
79 : delegate_(delegate.Pass()),
80 input_controller_(input_controller),
81 saved_auto_repeat_enabled_(false) {
82 DCHECK(delegate_);
83 DCHECK(input_controller_);
84 } 77 }
85 78
86 void InputInjectorChromeos::Core::InjectClipboardEvent( 79 void InputInjectorChromeos::Core::InjectClipboardEvent(
87 const ClipboardEvent& event) { 80 const ClipboardEvent& event) {
88 clipboard_->InjectClipboardEvent(event); 81 clipboard_->InjectClipboardEvent(event);
89 } 82 }
90 83
91 void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) { 84 void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) {
92 DCHECK(event.has_pressed()); 85 DCHECK(event.has_pressed());
93 DCHECK(event.has_usb_keycode()); 86 DCHECK(event.has_usb_keycode());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 delegate_->InjectMouseWheel(event.wheel_delta_x(), event.wheel_delta_y()); 142 delegate_->InjectMouseWheel(event.wheel_delta_x(), event.wheel_delta_y());
150 } else { 143 } else {
151 DCHECK(event.has_x() && event.has_y()); 144 DCHECK(event.has_x() && event.has_y());
152 delegate_->MoveCursorTo(point_transformer_->ToScreenCoordinates( 145 delegate_->MoveCursorTo(point_transformer_->ToScreenCoordinates(
153 gfx::PointF(event.x(), event.y()))); 146 gfx::PointF(event.x(), event.y())));
154 } 147 }
155 } 148 }
156 149
157 void InputInjectorChromeos::Core::Start( 150 void InputInjectorChromeos::Core::Start(
158 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 151 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
152 ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance();
153 delegate_ = ozone_platform->CreateSystemInputInjector();
154 DCHECK(delegate_);
155 input_controller_ = ozone_platform->GetInputController();
156 DCHECK(input_controller_);
157
158 // Implemented by remoting::ClipboardAura.
159 clipboard_ = Clipboard::Create(); 159 clipboard_ = Clipboard::Create();
160 clipboard_->Start(client_clipboard.Pass()); 160 clipboard_->Start(client_clipboard.Pass());
161 point_transformer_.reset(new PointTransformer()); 161 point_transformer_.reset(new PointTransformer());
162 } 162 }
163 163
164 InputInjectorChromeos::InputInjectorChromeos( 164 InputInjectorChromeos::InputInjectorChromeos(
165 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 165 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
166 : input_task_runner_(task_runner) { 166 : input_task_runner_(task_runner) {
167 ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance(); 167 core_.reset(new Core());
168 core_.reset(new Core(ozone_platform->CreateSystemInputInjector(),
169 ozone_platform->GetInputController()));
170 } 168 }
171 169
172 InputInjectorChromeos::~InputInjectorChromeos() { 170 InputInjectorChromeos::~InputInjectorChromeos() {
173 input_task_runner_->DeleteSoon(FROM_HERE, core_.release()); 171 input_task_runner_->DeleteSoon(FROM_HERE, core_.release());
174 } 172 }
175 173
176 void InputInjectorChromeos::InjectClipboardEvent(const ClipboardEvent& event) { 174 void InputInjectorChromeos::InjectClipboardEvent(const ClipboardEvent& event) {
177 input_task_runner_->PostTask( 175 input_task_runner_->PostTask(
178 FROM_HERE, base::Bind(&Core::InjectClipboardEvent, 176 FROM_HERE, base::Bind(&Core::InjectClipboardEvent,
179 base::Unretained(core_.get()), event)); 177 base::Unretained(core_.get()), event));
(...skipping 27 matching lines...) Expand all
207 // static 205 // static
208 scoped_ptr<InputInjector> InputInjector::Create( 206 scoped_ptr<InputInjector> InputInjector::Create(
209 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 207 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
210 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 208 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
211 // The Ozone input injector must be called on the UI task runner of the 209 // The Ozone input injector must be called on the UI task runner of the
212 // browser process. 210 // browser process.
213 return make_scoped_ptr(new InputInjectorChromeos(ui_task_runner)); 211 return make_scoped_ptr(new InputInjectorChromeos(ui_task_runner));
214 } 212 }
215 213
216 } // namespace remoting 214 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698