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

Unified Diff: chrome/browser/ui/webui/webapk_info_callback.cc

Issue 2629573004: Add a chrome://webapks page. (Closed)
Patch Set: Adds an about:webapks page with information about all installed Web APKs on the device 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 side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698