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

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

Issue 21554002: Enable Android support for Chromoting PINless (paired) authentication (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prevent future coordinates-related bugs 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
« no previous file with comments | « remoting/client/jni/chromoting_jni_runtime.h ('k') | remoting/client/jni/jni_interface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_runtime.h" 5 #include "remoting/client/jni/chromoting_jni_runtime.h"
6 6
7 #include "base/android/base_jni_registrar.h" 7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "media/base/yuv_convert.h" 10 #include "media/base/yuv_convert.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 JNIEnv* env = base::android::AttachCurrentThread(); 69 JNIEnv* env = base::android::AttachCurrentThread();
70 env->DeleteGlobalRef(class_); 70 env->DeleteGlobalRef(class_);
71 // TODO(solb): Detach all threads from JVM here. 71 // TODO(solb): Detach all threads from JVM here.
72 // crbug.com/259594 72 // crbug.com/259594
73 } 73 }
74 74
75 void ChromotingJniRuntime::ConnectToHost(const char* username, 75 void ChromotingJniRuntime::ConnectToHost(const char* username,
76 const char* auth_token, 76 const char* auth_token,
77 const char* host_jid, 77 const char* host_jid,
78 const char* host_id, 78 const char* host_id,
79 const char* host_pubkey) { 79 const char* host_pubkey,
80 const char* pairing_id,
81 const char* pairing_secret) {
80 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 82 DCHECK(ui_task_runner_->BelongsToCurrentThread());
81 DCHECK(!session_); 83 DCHECK(!session_);
82 session_ = new ChromotingJniInstance(this, 84 session_ = new ChromotingJniInstance(this,
83 username, 85 username,
84 auth_token, 86 auth_token,
85 host_jid, 87 host_jid,
86 host_id, 88 host_id,
87 host_pubkey); 89 host_pubkey,
90 pairing_id,
91 pairing_secret);
88 } 92 }
89 93
90 void ChromotingJniRuntime::DisconnectFromHost() { 94 void ChromotingJniRuntime::DisconnectFromHost() {
91 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 95 DCHECK(ui_task_runner_->BelongsToCurrentThread());
92 if (session_) { 96 if (session_) {
93 session_->Cleanup(); 97 session_->Cleanup();
94 session_ = NULL; 98 session_ = NULL;
95 } 99 }
96 } 100 }
97 101
(...skipping 12 matching lines...) Expand all
110 114
111 void ChromotingJniRuntime::DisplayAuthenticationPrompt() { 115 void ChromotingJniRuntime::DisplayAuthenticationPrompt() {
112 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 116 DCHECK(ui_task_runner_->BelongsToCurrentThread());
113 117
114 JNIEnv* env = base::android::AttachCurrentThread(); 118 JNIEnv* env = base::android::AttachCurrentThread();
115 env->CallStaticVoidMethod( 119 env->CallStaticVoidMethod(
116 class_, 120 class_,
117 env->GetStaticMethodID(class_, "displayAuthenticationPrompt", "()V")); 121 env->GetStaticMethodID(class_, "displayAuthenticationPrompt", "()V"));
118 } 122 }
119 123
124 void ChromotingJniRuntime::CommitPairingCredentials(const std::string& host,
125 const std::string& id,
126 const std::string& secret) {
127 DCHECK(ui_task_runner_->BelongsToCurrentThread());
128
129 JNIEnv* env = base::android::AttachCurrentThread();
130 jstring host_jstr = env->NewStringUTF(host.c_str());
131 jbyteArray id_arr = env->NewByteArray(id.size());
132 env->SetByteArrayRegion(id_arr, 0, id.size(),
133 reinterpret_cast<const jbyte*>(id.c_str()));
134 jbyteArray secret_arr = env->NewByteArray(secret.size());
135 env->SetByteArrayRegion(secret_arr, 0, secret.size(),
136 reinterpret_cast<const jbyte*>(secret.c_str()));
137
138 env->CallStaticVoidMethod(
139 class_,
140 env->GetStaticMethodID(
141 class_,
142 "commitPairingCredentials",
143 "(Ljava/lang/String;[B[B)V"),
144 host_jstr,
145 id_arr,
146 secret_arr);
147
148 // Because we passed them as arguments, their corresponding Java objects were
149 // GCd as soon as the managed method returned, so we mustn't release it here.
150 }
151
120 void ChromotingJniRuntime::UpdateImageBuffer(int width, 152 void ChromotingJniRuntime::UpdateImageBuffer(int width,
121 int height, 153 int height,
122 jobject buffer) { 154 jobject buffer) {
123 DCHECK(display_task_runner_->BelongsToCurrentThread()); 155 DCHECK(display_task_runner_->BelongsToCurrentThread());
124 156
125 JNIEnv* env = base::android::AttachCurrentThread(); 157 JNIEnv* env = base::android::AttachCurrentThread();
126 env->SetStaticIntField( 158 env->SetStaticIntField(
127 class_, 159 class_,
128 env->GetStaticFieldID(class_, "sWidth", "I"), 160 env->GetStaticFieldID(class_, "sWidth", "I"),
129 width); 161 width);
(...skipping 10 matching lines...) Expand all
140 void ChromotingJniRuntime::RedrawCanvas() { 172 void ChromotingJniRuntime::RedrawCanvas() {
141 DCHECK(display_task_runner_->BelongsToCurrentThread()); 173 DCHECK(display_task_runner_->BelongsToCurrentThread());
142 174
143 JNIEnv* env = base::android::AttachCurrentThread(); 175 JNIEnv* env = base::android::AttachCurrentThread();
144 env->CallStaticVoidMethod( 176 env->CallStaticVoidMethod(
145 class_, 177 class_,
146 env->GetStaticMethodID(class_, "redrawGraphicsInternal", "()V")); 178 env->GetStaticMethodID(class_, "redrawGraphicsInternal", "()V"));
147 } 179 }
148 180
149 } // namespace remoting 181 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_runtime.h ('k') | remoting/client/jni/jni_interface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698