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

Side by Side Diff: remoting/protocol/key_event_tracker.cc

Issue 9646013: Add the plumbing that will carry a clipboard item from a chromoting client to a host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync, and make InputStub inherit from ClipboardStub. Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/protocol/key_event_tracker.h" 5 #include "remoting/protocol/key_event_tracker.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "remoting/proto/event.pb.h" 8 #include "remoting/proto/event.pb.h"
9 9
10 namespace remoting { 10 namespace remoting {
11 namespace protocol { 11 namespace protocol {
12 12
13 KeyEventTracker::KeyEventTracker(InputStub* input_stub) 13 KeyEventTracker::KeyEventTracker(InputStub* input_stub)
14 : input_stub_(input_stub) { 14 : input_stub_(input_stub) {
15 } 15 }
16 16
17 KeyEventTracker::~KeyEventTracker() { 17 KeyEventTracker::~KeyEventTracker() {
18 } 18 }
19 19
20 void KeyEventTracker::InjectClipboardEvent(const ClipboardEvent& event) {
21 input_stub_->InjectClipboardEvent(event);
22 }
23
20 void KeyEventTracker::InjectKeyEvent(const KeyEvent& event) { 24 void KeyEventTracker::InjectKeyEvent(const KeyEvent& event) {
21 DCHECK(event.has_pressed()); 25 DCHECK(event.has_pressed());
22 DCHECK(event.has_keycode()); 26 DCHECK(event.has_keycode());
23 if (event.pressed()) { 27 if (event.pressed()) {
24 pressed_keys_.insert(event.keycode()); 28 pressed_keys_.insert(event.keycode());
25 } else { 29 } else {
26 pressed_keys_.erase(event.keycode()); 30 pressed_keys_.erase(event.keycode());
27 } 31 }
28 input_stub_->InjectKeyEvent(event); 32 input_stub_->InjectKeyEvent(event);
29 } 33 }
30 34
31 void KeyEventTracker::InjectMouseEvent(const MouseEvent& event) { 35 void KeyEventTracker::InjectMouseEvent(const MouseEvent& event) {
32 input_stub_->InjectMouseEvent(event); 36 input_stub_->InjectMouseEvent(event);
33 } 37 }
34 38
35 void KeyEventTracker::ReleaseAllKeys() { 39 void KeyEventTracker::ReleaseAllKeys() {
36 std::set<int>::iterator i; 40 std::set<int>::iterator i;
37 for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) { 41 for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) {
38 KeyEvent event; 42 KeyEvent event;
39 event.set_keycode(*i); 43 event.set_keycode(*i);
40 event.set_pressed(false); 44 event.set_pressed(false);
41 input_stub_->InjectKeyEvent(event); 45 input_stub_->InjectKeyEvent(event);
42 } 46 }
43 pressed_keys_.clear(); 47 pressed_keys_.clear();
44 } 48 }
45 49
46 } // namespace protocol 50 } // namespace protocol
47 } // namespace remoting 51 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698