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

Side by Side Diff: remoting/client/jni/chromoting_jni_instance.cc

Issue 21120005: Add Android Chromoting client keyboard input (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve related comments Created 7 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/client/jni/chromoting_jni_instance.h" 5 #include "remoting/client/jni/chromoting_jni_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "remoting/client/audio_player.h" 9 #include "remoting/client/audio_player.h"
10 #include "remoting/client/jni/android_keymap.h"
10 #include "remoting/client/jni/chromoting_jni_runtime.h" 11 #include "remoting/client/jni/chromoting_jni_runtime.h"
11 #include "remoting/protocol/libjingle_transport_factory.h" 12 #include "remoting/protocol/libjingle_transport_factory.h"
12 13
13 // TODO(solb) Move into location shared with client plugin. 14 // TODO(solb) Move into location shared with client plugin.
14 const char* const CHAT_SERVER = "talk.google.com"; 15 const char* const CHAT_SERVER = "talk.google.com";
15 const int CHAT_PORT = 5222; 16 const int CHAT_PORT = 5222;
16 const bool CHAT_USE_TLS = true; 17 const bool CHAT_USE_TLS = true;
17 18
18 namespace remoting { 19 namespace remoting {
19 20
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 protocol::MouseEvent action; 99 protocol::MouseEvent action;
99 action.set_x(x); 100 action.set_x(x);
100 action.set_y(y); 101 action.set_y(y);
101 action.set_button(button); 102 action.set_button(button);
102 if (button != protocol::MouseEvent::BUTTON_UNDEFINED) 103 if (button != protocol::MouseEvent::BUTTON_UNDEFINED)
103 action.set_button_down(buttonDown); 104 action.set_button_down(buttonDown);
104 105
105 connection_->input_stub()->InjectMouseEvent(action); 106 connection_->input_stub()->InjectMouseEvent(action);
106 } 107 }
107 108
109 void ChromotingJniInstance::PerformKeyboardAction(int keyCode, bool keyDown) {
110 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
111 jni_runtime_->network_task_runner()->PostTask(
112 FROM_HERE,
113 base::Bind(&ChromotingJniInstance::PerformKeyboardAction,
114 this,
Sergey Ulanov 2013/07/30 19:19:27 two arguments below this one would fit on this lin
solb 2013/07/30 21:30:54 It's formatted in accordance with http://google-st
Sergey Ulanov 2013/07/30 21:42:10 "if this makes the code more readable". IMO it doe
115 keyCode,
116 keyDown));
117 return;
118 }
119
120 uint32 usbCode = AndroidKeycodeToUsbKeycode(keyCode);
121 if (usbCode) {
122 protocol::KeyEvent action;
123 action.set_usb_keycode(usbCode);
124 action.set_pressed(keyDown);
125 connection_->input_stub()->InjectKeyEvent(action);
126 }
127 else
128 LOG(WARNING) << "Ignoring unknown keycode: " << keyCode;
Sergey Ulanov 2013/07/30 19:19:27 nit: add {}
solb 2013/07/30 21:30:54 Done in https://codereview.chromium.org/21236002
129 }
130
108 void ChromotingJniInstance::OnConnectionState( 131 void ChromotingJniInstance::OnConnectionState(
109 protocol::ConnectionToHost::State state, 132 protocol::ConnectionToHost::State state,
110 protocol::ErrorCode error) { 133 protocol::ErrorCode error) {
111 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { 134 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) {
112 jni_runtime_->ui_task_runner()->PostTask( 135 jni_runtime_->ui_task_runner()->PostTask(
113 FROM_HERE, 136 FROM_HERE,
114 base::Bind(&ChromotingJniInstance::OnConnectionState, 137 base::Bind(&ChromotingJniInstance::OnConnectionState,
115 this, 138 this,
116 state, 139 state,
117 error)); 140 error));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 pairable, 272 pairable,
250 callback)); 273 callback));
251 return; 274 return;
252 } 275 }
253 276
254 pin_callback_ = callback; 277 pin_callback_ = callback;
255 jni_runtime_->DisplayAuthenticationPrompt(); 278 jni_runtime_->DisplayAuthenticationPrompt();
256 } 279 }
257 280
258 } // namespace remoting 281 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698