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

Side by Side Diff: chrome/browser/ui/webui/webapk_info_callback.cc

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Adds comment to explain the reason of an empty param Created 3 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/webapk_info_callback.h"
6
7 #include <jni.h>
8 #include <string>
9
10 #include "base/android/jni_android.h"
11 #include "base/android/jni_string.h"
12 #include "jni/WebApkInfoCallback_jni.h"
13
14 using base::android::JavaParamRef;
15
16 WebApkInfoCallback::WebApkInfoCallback(
17 const base::RepeatingCallback<void(std::string, std::string, int, int)>&
18 callback)
19 : callback_(callback),
20 j_webapk_info_callback_(
21 Java_WebApkInfoCallback_create(base::android::AttachCurrentThread(),
22 reinterpret_cast<uintptr_t>(this))) {}
23
24 WebApkInfoCallback::~WebApkInfoCallback() {}
25
26 void WebApkInfoCallback::Destroy(JNIEnv* env,
27 const JavaParamRef<jobject>& obj) {
28 delete this;
29 }
30
31 void WebApkInfoCallback::MakeInfoRequest(JNIEnv* env) {
32 Java_WebApkInfoCallback_listWebApks(env, j_webapk_info_callback_);
33 }
34
35 void WebApkInfoCallback::OnWebApkFound(
36 JNIEnv* env,
37 const JavaParamRef<jobject>& obj,
38 const base::android::JavaParamRef<jstring>& j_name,
39 const base::android::JavaParamRef<jstring>& j_package_name,
40 const jint j_shell_apk_version,
41 const jint j_version_code) const {
42 std::string name = base::android::ConvertJavaStringToUTF8(env, j_name);
43 std::string package_name =
44 base::android::ConvertJavaStringToUTF8(env, j_package_name);
45 int shell_apk_version = static_cast<int>(j_shell_apk_version);
46 int version_code = static_cast<int>(j_version_code);
47 callback_.Run(name, package_name, shell_apk_version, version_code);
48 }
49
50 // static
51 bool WebApkInfoCallback::Register(JNIEnv* env) {
52 return RegisterNativesImpl(env);
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698