| 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..8ace2295836fa70964466b998b6c397bec392bed
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/webui/webapk_info_callback.cc
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// 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 <string>
|
| +
|
| +#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::MakeInfoRequest(JNIEnv* env) {
|
| + Java_WebApkInfoCallback_listWebApks(env, j_webapk_info_callback_);
|
| +}
|
| +
|
| +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);
|
| +}
|
|
|