Chromium Code Reviews| Index: chrome/browser/ui/webui/webapk_info_callback.cc |
| diff --git a/chrome/browser/ui/webui/webapk_info_callback.cc b/chrome/browser/ui/webui/webapk_info_callback.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..874a11e000985e5eddcd9cb098fb706123c3561b |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/webapk_info_callback.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
hartmanng
2017/01/13 15:40:21
s/2016/2017/
gonzalon
2017/01/13 20:24:39
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/webapk_info_callback.h" |
| + |
| +#include <jni.h> |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/android/jni_string.h" |
| +#include "jni/WebapkInfoCallback_jni.h" |
| + |
| +using base::android::JavaParamRef; |
| + |
| +WebapkInfoCallback::WebapkInfoCallback( |
| + const base::RepeatingCallback<void(std::string, std::string, int, int)>& |
| + callback) |
| + : callback_(callback), |
| + j_webapk_info_callback_( |
| + Java_WebapkInfoCallback_create(base::android::AttachCurrentThread(), |
| + reinterpret_cast<uintptr_t>(this))) {} |
| + |
| +WebapkInfoCallback::~WebapkInfoCallback() {} |
| + |
| +void WebapkInfoCallback::Destroy(JNIEnv* env, |
| + const JavaParamRef<jobject>& obj) { |
| + delete this; |
| +} |
| + |
| +void WebapkInfoCallback::OnWebApkFound( |
| + JNIEnv* env, |
| + const JavaParamRef<jobject>& obj, |
| + const base::android::JavaParamRef<jstring>& j_name, |
| + const base::android::JavaParamRef<jstring>& j_package_name, |
| + const jint j_shell_apk_version, |
| + const jint j_version_code) const { |
| + std::string name = base::android::ConvertJavaStringToUTF8(env, j_name); |
| + std::string package_name = |
| + base::android::ConvertJavaStringToUTF8(env, j_package_name); |
| + int shell_apk_version = static_cast<int>(j_shell_apk_version); |
| + int version_code = static_cast<int>(j_version_code); |
| + callback_.Run(name, package_name, shell_apk_version, version_code); |
| +} |
| + |
| +// static |
| +bool WebapkInfoCallback::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |