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

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

Issue 21236002: Chromoting Android app mouse/keyboard bugfixes and enhancements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One last (TODO) comment change 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/android_keymap.h"
11 #include "remoting/client/jni/chromoting_jni_runtime.h" 11 #include "remoting/client/jni/chromoting_jni_runtime.h"
12 #include "remoting/protocol/libjingle_transport_factory.h" 12 #include "remoting/protocol/libjingle_transport_factory.h"
13 13
14 // TODO(solb) Move into location shared with client plugin. 14 // TODO(solb) Move into location shared with client plugin.
15 const char* const CHAT_SERVER = "talk.google.com"; 15 const char* const kXmppServer = "talk.google.com";
16 const int CHAT_PORT = 5222; 16 const int kXmppPort = 5222;
17 const bool CHAT_USE_TLS = true; 17 const bool kXmppUseTls = true;
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, 21 ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime,
22 const char* username, 22 const char* username,
23 const char* auth_token, 23 const char* auth_token,
24 const char* host_jid, 24 const char* host_jid,
25 const char* host_id, 25 const char* host_id,
26 const char* host_pubkey) 26 const char* host_pubkey)
27 : jni_runtime_(jni_runtime), 27 : jni_runtime_(jni_runtime),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return; 76 return;
77 } 77 }
78 78
79 jni_runtime_->RedrawCanvas(); 79 jni_runtime_->RedrawCanvas();
80 } 80 }
81 81
82 void ChromotingJniInstance::PerformMouseAction( 82 void ChromotingJniInstance::PerformMouseAction(
83 int x, 83 int x,
84 int y, 84 int y,
85 protocol::MouseEvent_MouseButton button, 85 protocol::MouseEvent_MouseButton button,
86 bool buttonDown) { 86 bool button_down) {
87 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 87 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
88 jni_runtime_->network_task_runner()->PostTask( 88 jni_runtime_->network_task_runner()->PostTask(
89 FROM_HERE, 89 FROM_HERE,
90 base::Bind(&ChromotingJniInstance::PerformMouseAction, 90 base::Bind(&ChromotingJniInstance::PerformMouseAction,
91 this, 91 this,
92 x, 92 x,
93 y, 93 y,
94 button, 94 button,
95 buttonDown)); 95 button_down));
96 return; 96 return;
97 } 97 }
98 98
99 protocol::MouseEvent action; 99 protocol::MouseEvent action;
100 action.set_x(x); 100 action.set_x(x);
101 action.set_y(y); 101 action.set_y(y);
102 action.set_button(button); 102 action.set_button(button);
103 if (button != protocol::MouseEvent::BUTTON_UNDEFINED) 103 if (button != protocol::MouseEvent::BUTTON_UNDEFINED)
104 action.set_button_down(buttonDown); 104 action.set_button_down(button_down);
105 105
106 connection_->input_stub()->InjectMouseEvent(action); 106 connection_->input_stub()->InjectMouseEvent(action);
107 } 107 }
108 108
109 void ChromotingJniInstance::PerformKeyboardAction(int keyCode, bool keyDown) { 109 void ChromotingJniInstance::PerformKeyboardAction(int key_code, bool key_down) {
110 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 110 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
111 jni_runtime_->network_task_runner()->PostTask( 111 jni_runtime_->network_task_runner()->PostTask(
112 FROM_HERE, 112 FROM_HERE,
113 base::Bind(&ChromotingJniInstance::PerformKeyboardAction, 113 base::Bind(&ChromotingJniInstance::PerformKeyboardAction,
114 this, 114 this,
115 keyCode, 115 key_code,
116 keyDown)); 116 key_down));
117 return; 117 return;
118 } 118 }
119 119
120 uint32 usbCode = AndroidKeycodeToUsbKeycode(keyCode); 120 uint32 usb_code = AndroidKeycodeToUsbKeycode(key_code);
121 if (usbCode) { 121 if (usb_code) {
122 protocol::KeyEvent action; 122 protocol::KeyEvent action;
123 action.set_usb_keycode(usbCode); 123 action.set_usb_keycode(usb_code);
124 action.set_pressed(keyDown); 124 action.set_pressed(key_down);
125 connection_->input_stub()->InjectKeyEvent(action); 125 connection_->input_stub()->InjectKeyEvent(action);
126 } 126 }
127 else 127 else {
128 LOG(WARNING) << "Ignoring unknown keycode: " << keyCode; 128 LOG(WARNING) << "Ignoring unknown keycode: " << key_code;
129 }
129 } 130 }
130 131
131 void ChromotingJniInstance::OnConnectionState( 132 void ChromotingJniInstance::OnConnectionState(
132 protocol::ConnectionToHost::State state, 133 protocol::ConnectionToHost::State state,
133 protocol::ErrorCode error) { 134 protocol::ErrorCode error) {
134 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { 135 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) {
135 jni_runtime_->ui_task_runner()->PostTask( 136 jni_runtime_->ui_task_runner()->PostTask(
136 FROM_HERE, 137 FROM_HERE,
137 base::Bind(&ChromotingJniInstance::OnConnectionState, 138 base::Bind(&ChromotingJniInstance::OnConnectionState,
138 this, 139 this,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 client_.reset(new ChromotingClient(*client_config_, 221 client_.reset(new ChromotingClient(*client_config_,
221 client_context_.get(), 222 client_context_.get(),
222 connection_.get(), 223 connection_.get(),
223 this, 224 this,
224 frame_consumer_, 225 frame_consumer_,
225 scoped_ptr<AudioPlayer>())); 226 scoped_ptr<AudioPlayer>()));
226 227
227 view_->set_frame_producer(client_->GetFrameProducer()); 228 view_->set_frame_producer(client_->GetFrameProducer());
228 229
229 signaling_config_.reset(new XmppSignalStrategy::XmppServerConfig()); 230 signaling_config_.reset(new XmppSignalStrategy::XmppServerConfig());
230 signaling_config_->host = CHAT_SERVER; 231 signaling_config_->host = kXmppServer;
231 signaling_config_->port = CHAT_PORT; 232 signaling_config_->port = kXmppPort;
232 signaling_config_->use_tls = CHAT_USE_TLS; 233 signaling_config_->use_tls = kXmppUseTls;
233 234
234 signaling_.reset(new XmppSignalStrategy(jni_runtime_->url_requester(), 235 signaling_.reset(new XmppSignalStrategy(jni_runtime_->url_requester(),
235 username_, 236 username_,
236 auth_token_, 237 auth_token_,
237 "oauth2", 238 "oauth2",
238 *signaling_config_)); 239 *signaling_config_));
239 240
240 network_settings_.reset(new NetworkSettings( 241 network_settings_.reset(new NetworkSettings(
241 NetworkSettings::NAT_TRAVERSAL_ENABLED)); 242 NetworkSettings::NAT_TRAVERSAL_ENABLED));
242 scoped_ptr<protocol::TransportFactory> fact( 243 scoped_ptr<protocol::TransportFactory> fact(
(...skipping 29 matching lines...) Expand all
272 pairable, 273 pairable,
273 callback)); 274 callback));
274 return; 275 return;
275 } 276 }
276 277
277 pin_callback_ = callback; 278 pin_callback_ = callback;
278 jni_runtime_->DisplayAuthenticationPrompt(); 279 jni_runtime_->DisplayAuthenticationPrompt();
279 } 280 }
280 281
281 } // namespace remoting 282 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_instance.h ('k') | remoting/client/jni/chromoting_jni_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698