| 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/library_loader/library_loader_hooks.h" | 10 #include "base/android/library_loader/library_loader_hooks.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // The google_apis functions check the command-line arguments to make sure no | 46 // The google_apis functions check the command-line arguments to make sure no |
| 47 // runtime API keys have been specified by the environment. Unfortunately, we | 47 // runtime API keys have been specified by the environment. Unfortunately, we |
| 48 // neither launch Chromium nor have a command line, so we need to prevent | 48 // neither launch Chromium nor have a command line, so we need to prevent |
| 49 // them from DCHECKing out when they go looking. | 49 // them from DCHECKing out when they go looking. |
| 50 base::CommandLine::Init(0, nullptr); | 50 base::CommandLine::Init(0, nullptr); |
| 51 | 51 |
| 52 // Create the singleton now so that the Chromoting threads will be set up. | 52 // Create the singleton now so that the Chromoting threads will be set up. |
| 53 remoting::ChromotingJniRuntime::GetInstance(); | 53 remoting::ChromotingJniRuntime::GetInstance(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 static jstring GetApiKey(JNIEnv* env, jclass clazz) { | 56 static ScopedJavaLocalRef<jstring> GetApiKey(JNIEnv* env, jclass clazz) { |
| 57 return ConvertUTF8ToJavaString( | 57 return ConvertUTF8ToJavaString(env, google_apis::GetAPIKey().c_str()); |
| 58 env, google_apis::GetAPIKey().c_str()).Release(); | |
| 59 } | 58 } |
| 60 | 59 |
| 61 static jstring GetClientId(JNIEnv* env, jclass clazz) { | 60 static ScopedJavaLocalRef<jstring> GetClientId(JNIEnv* env, jclass clazz) { |
| 62 return ConvertUTF8ToJavaString( | 61 return ConvertUTF8ToJavaString( |
| 63 env, google_apis::GetOAuth2ClientID( | 62 env, |
| 64 google_apis::CLIENT_REMOTING).c_str()).Release(); | 63 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING).c_str()); |
| 65 } | 64 } |
| 66 | 65 |
| 67 static jstring GetClientSecret(JNIEnv* env, jclass clazz) { | 66 static ScopedJavaLocalRef<jstring> GetClientSecret(JNIEnv* env, jclass clazz) { |
| 68 return ConvertUTF8ToJavaString( | 67 return ConvertUTF8ToJavaString( |
| 69 env, google_apis::GetOAuth2ClientSecret( | 68 env, |
| 70 google_apis::CLIENT_REMOTING).c_str()).Release(); | 69 google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_REMOTING).c_str()); |
| 71 } | 70 } |
| 72 | 71 |
| 73 static void Connect(JNIEnv* env, | 72 static void Connect(JNIEnv* env, |
| 74 jclass clazz, | 73 jclass clazz, |
| 75 jstring username, | 74 jstring username, |
| 76 jstring authToken, | 75 jstring authToken, |
| 77 jstring hostJid, | 76 jstring hostJid, |
| 78 jstring hostId, | 77 jstring hostId, |
| 79 jstring hostPubkey, | 78 jstring hostPubkey, |
| 80 jstring pairId, | 79 jstring pairId, |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 363 |
| 365 JNIEnv* env = base::android::AttachCurrentThread(); | 364 JNIEnv* env = base::android::AttachCurrentThread(); |
| 366 Java_JniInterface_redrawGraphicsInternal(env); | 365 Java_JniInterface_redrawGraphicsInternal(env); |
| 367 } | 366 } |
| 368 | 367 |
| 369 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { | 368 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { |
| 370 base::android::DetachFromVM(); | 369 base::android::DetachFromVM(); |
| 371 waiter->Signal(); | 370 waiter->Signal(); |
| 372 } | 371 } |
| 373 } // namespace remoting | 372 } // namespace remoting |
| OLD | NEW |