| 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);
|
| +}
|
|
|