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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfoCallback.java

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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfoCallback.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfoCallback.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfoCallback.java
new file mode 100644
index 0000000000000000000000000000000000000000..64f85321b7652f7d42f6799b96d2e42785bba2d7
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfoCallback.java
@@ -0,0 +1,63 @@
+// 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.
+
+package org.chromium.chrome.browser.webapps;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.chrome.browser.ShortcutHelper;
+
+/** A simple callback to load the information on WebAPKs. */
+public class WebApkInfoCallback {
+ private long mNativeWebApkInfoCallback;
+
+ /**
+ * Fetches the information of all WebAPKs installed on the device and returns them to the
+ * caller using a callback.
+ *
+ * @param webApkInfoCallback Callback to be called with each WebAPK found on the device.
+ */
+ @CalledByNative
+ private static void listWebApks(WebApkInfoCallback webApkInfoCallback) {
+ ShortcutHelper.listWebApks(webApkInfoCallback);
+ }
+
+ /**
+ * Called with information of one WebAPK. When information is requested, it will be called once
+ * for each WebAPK installed on the device.
+ *
+ * @param name The name of the WebAPK.
+ * @param packageName The package name of the WebAPK.
+ * @param shellApkVersion The version of the shell APK of the WebAPK.
+ * @param versionCode The version code associated with the WebAPK.
+ */
+ public void onWebApkFound(
+ String name, String packageName, int shellApkVersion, int versionCode) {
+ nativeOnWebApkFound(
+ mNativeWebApkInfoCallback, name, packageName, shellApkVersion, versionCode);
+ }
+
+ /** Destroys the native counterpart of this object. */
+ public void destroy() {
+ nativeDestroy(mNativeWebApkInfoCallback);
+ mNativeWebApkInfoCallback = 0;
+ }
+
+ /**
+ * Called from C++ by |nativeWebApkInfoCallback| to instantiate this class. Note that this is
+ * the only way to construct an WebApkInfoCallback; the constructor is private.
+ * @param nativeWebApkInfoCallback The native counterpart that creates and owns this object.
+ */
+ @CalledByNative
+ private static WebApkInfoCallback create(long nativeWebApkInfoCallback) {
+ return new WebApkInfoCallback(nativeWebApkInfoCallback);
+ }
+
+ private WebApkInfoCallback(long nativeWebApkInfoCallback) {
+ mNativeWebApkInfoCallback = nativeWebApkInfoCallback;
+ }
+
+ private native void nativeOnWebApkFound(long nativeWebApkInfoCallback, String name,
+ String packageName, int shellApkVersion, int versionCode);
+ private native void nativeDestroy(long nativeWebApkInfoCallback);
+}

Powered by Google App Engine
This is Rietveld 408576698