| OLD | NEW |
| 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_runtime.h" | 5 #include "remoting/client/jni/chromoting_jni_runtime.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 jstring deviceName) { | 96 jstring deviceName) { |
| 97 remoting::ChromotingJniRuntime::GetInstance()->session()->ProvideSecret( | 97 remoting::ChromotingJniRuntime::GetInstance()->session()->ProvideSecret( |
| 98 ConvertJavaStringToUTF8(env, pin).c_str(), createPair, | 98 ConvertJavaStringToUTF8(env, pin).c_str(), createPair, |
| 99 ConvertJavaStringToUTF8(env, deviceName)); | 99 ConvertJavaStringToUTF8(env, deviceName)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 static void ScheduleRedraw(JNIEnv* env, jclass clazz) { | 102 static void ScheduleRedraw(JNIEnv* env, jclass clazz) { |
| 103 remoting::ChromotingJniRuntime::GetInstance()->session()->RedrawDesktop(); | 103 remoting::ChromotingJniRuntime::GetInstance()->session()->RedrawDesktop(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 static void MouseAction(JNIEnv* env, | 106 static void SendMouseEvent(JNIEnv* env, |
| 107 jclass clazz, | 107 jclass clazz, |
| 108 jint x, | 108 jint x, |
| 109 jint y, | 109 jint y, |
| 110 jint whichButton, | 110 jint whichButton, |
| 111 jboolean buttonDown) { | 111 jboolean buttonDown) { |
| 112 // Button must be within the bounds of the MouseEvent_MouseButton enum. | 112 // Button must be within the bounds of the MouseEvent_MouseButton enum. |
| 113 DCHECK(whichButton >= 0 && whichButton < 5); | 113 DCHECK(whichButton >= 0 && whichButton < 5); |
| 114 | 114 |
| 115 remoting::ChromotingJniRuntime::GetInstance()->session()->PerformMouseAction( | 115 remoting::ChromotingJniRuntime::GetInstance()->session()->SendMouseEvent( |
| 116 x, | 116 x, y, |
| 117 y, | |
| 118 static_cast<remoting::protocol::MouseEvent_MouseButton>(whichButton), | 117 static_cast<remoting::protocol::MouseEvent_MouseButton>(whichButton), |
| 119 buttonDown); | 118 buttonDown); |
| 120 } | 119 } |
| 121 | 120 |
| 122 static void MouseWheelDeltaAction(JNIEnv* env, | 121 static void SendMouseWheelEvent(JNIEnv* env, |
| 123 jclass clazz, | 122 jclass clazz, |
| 124 jint delta_x, | 123 jint delta_x, |
| 125 jint delta_y) { | 124 jint delta_y) { |
| 126 remoting::ChromotingJniRuntime::GetInstance() | 125 remoting::ChromotingJniRuntime::GetInstance()->session()->SendMouseWheelEvent( |
| 127 ->session() | 126 delta_x, delta_y); |
| 128 ->PerformMouseWheelDeltaAction(delta_x, delta_y); | |
| 129 } | 127 } |
| 130 | 128 |
| 131 static void KeyboardAction(JNIEnv* env, | 129 static void SendKeyEvent(JNIEnv* env, |
| 132 jclass clazz, | 130 jclass clazz, |
| 133 jint keyCode, | 131 jint keyCode, |
| 134 jboolean keyDown) { | 132 jboolean keyDown) { |
| 135 remoting::ChromotingJniRuntime::GetInstance() | 133 remoting::ChromotingJniRuntime::GetInstance()->session()->SendKeyEvent( |
| 136 ->session() | 134 keyCode, keyDown); |
| 137 ->PerformKeyboardAction(keyCode, keyDown); | 135 } |
| 136 |
| 137 static void SendTextEvent(JNIEnv* env, |
| 138 jclass clazz, |
| 139 jstring text) { |
| 140 remoting::ChromotingJniRuntime::GetInstance()->session()->SendTextEvent( |
| 141 ConvertJavaStringToUTF8(env, text)); |
| 138 } | 142 } |
| 139 | 143 |
| 140 // ChromotingJniRuntime implementation. | 144 // ChromotingJniRuntime implementation. |
| 141 | 145 |
| 142 // static | 146 // static |
| 143 ChromotingJniRuntime* ChromotingJniRuntime::GetInstance() { | 147 ChromotingJniRuntime* ChromotingJniRuntime::GetInstance() { |
| 144 return Singleton<ChromotingJniRuntime>::get(); | 148 return Singleton<ChromotingJniRuntime>::get(); |
| 145 } | 149 } |
| 146 | 150 |
| 147 ChromotingJniRuntime::ChromotingJniRuntime() { | 151 ChromotingJniRuntime::ChromotingJniRuntime() { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 JNIEnv* env = base::android::AttachCurrentThread(); | 294 JNIEnv* env = base::android::AttachCurrentThread(); |
| 291 Java_JniInterface_redrawGraphicsInternal(env); | 295 Java_JniInterface_redrawGraphicsInternal(env); |
| 292 } | 296 } |
| 293 | 297 |
| 294 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { | 298 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { |
| 295 base::android::DetachFromVM(); | 299 base::android::DetachFromVM(); |
| 296 waiter->Signal(); | 300 waiter->Signal(); |
| 297 } | 301 } |
| 298 | 302 |
| 299 } // namespace remoting | 303 } // namespace remoting |
| OLD | NEW |