| Index: components/devtools_bridge/test/android/client/web_client_android.cc
|
| diff --git a/components/devtools_bridge/test/android/client/web_client_android.cc b/components/devtools_bridge/test/android/client/web_client_android.cc
|
| index 8287a24690479744c602fc4092e1be9a3be85723..9ef7243631c609974930e76afb68a6d733fb5cbc 100644
|
| --- a/components/devtools_bridge/test/android/client/web_client_android.cc
|
| +++ b/components/devtools_bridge/test/android/client/web_client_android.cc
|
| @@ -4,10 +4,16 @@
|
|
|
| #include "components/devtools_bridge/test/android/client/web_client_android.h"
|
|
|
| +#include "base/android/jni_string.h"
|
| +#include "base/android/scoped_java_ref.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_android.h"
|
| #include "jni/WebClient_jni.h"
|
|
|
| +using base::android::AttachCurrentThread;
|
| +using base::android::ConvertJavaStringToUTF8;
|
| +using base::android::ConvertUTF8ToJavaString;
|
| +
|
| namespace devtools_bridge {
|
| namespace android {
|
|
|
| @@ -15,16 +21,31 @@ bool WebClientAndroid::RegisterNatives(JNIEnv* env) {
|
| return RegisterNativesImpl(env);
|
| }
|
|
|
| -WebClientAndroid::WebClientAndroid(Profile* profile)
|
| +WebClientAndroid::WebClientAndroid(
|
| + Profile* profile, JNIEnv* env, jobject j_delegate)
|
| : impl_(WebClient::CreateInstance(profile, this)) {
|
| + delegate_.Reset(env, j_delegate);
|
| }
|
|
|
| WebClientAndroid::~WebClientAndroid() {
|
| }
|
|
|
| -static jlong CreateWebClient(JNIEnv* env, jclass jcaller, jobject j_profile) {
|
| +void WebClientAndroid::SendCommand(
|
| + const std::string& command,
|
| + const WebClient::CommandSuccessCallback& sucess_callback,
|
| + const WebClient::CommandFailureCallback& failure_callback) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + Java_WebClient_sendCommand(
|
| + env,
|
| + delegate_.obj(),
|
| + ConvertUTF8ToJavaString(env, command).obj());
|
| +}
|
| +
|
| +static jlong CreateWebClient(
|
| + JNIEnv* env, jclass jcaller, jobject j_profile, jobject j_delegate) {
|
| Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
|
| - return reinterpret_cast<jlong>(new WebClientAndroid(profile));
|
| + return reinterpret_cast<jlong>(new WebClientAndroid(
|
| + profile, env, j_delegate));
|
| }
|
|
|
| static void DestroyWebClient(
|
| @@ -32,5 +53,22 @@ static void DestroyWebClient(
|
| delete reinterpret_cast<WebClientAndroid*>(web_client_ptr);
|
| }
|
|
|
| +static void Connect(
|
| + JNIEnv* env, jclass jcaller, jlong web_client_ptr, jstring device_id) {
|
| + reinterpret_cast<WebClientAndroid*>(web_client_ptr)->impl().Connect(
|
| + ConvertJavaStringToUTF8(env, device_id));
|
| +}
|
| +
|
| +static void Disconnect(
|
| + JNIEnv* env, jclass jcaller, jlong web_client_ptr, jstring device_id) {
|
| + reinterpret_cast<WebClientAndroid*>(web_client_ptr)->impl().Disconnect(
|
| + ConvertJavaStringToUTF8(env, device_id));
|
| +}
|
| +
|
| +static void DisconnectAll(
|
| + JNIEnv* env, jclass jcaller, jlong web_client_ptr) {
|
| + reinterpret_cast<WebClientAndroid*>(web_client_ptr)->impl().DisconnectAll();
|
| +}
|
| +
|
| } // namespace android
|
| } // namespace devtools_bridge
|
|
|