| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFactory.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFactory.java
|
| index a868d46e94ff4d921e6271b7067d4e1aa85c912d..ca17fba70d3f7331e3b8ac1aa571d33828819049 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFactory.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFactory.java
|
| @@ -8,8 +8,11 @@ import android.content.Context;
|
| import android.content.Intent;
|
| import android.content.pm.PackageManager;
|
| import android.content.pm.ResolveInfo;
|
| +import android.graphics.drawable.Drawable;
|
| import android.net.Uri;
|
| +import android.util.Pair;
|
|
|
| +import org.chromium.base.ContextUtils;
|
| import org.chromium.chrome.browser.payments.PaymentAppFactory.PaymentAppCreatedCallback;
|
| import org.chromium.chrome.browser.payments.PaymentAppFactory.PaymentAppFactoryAddition;
|
| import org.chromium.content_public.browser.WebContents;
|
| @@ -58,6 +61,8 @@ public class AndroidPaymentAppFactory implements PaymentAppFactoryAddition {
|
| for (int i = 0; i < matches.size(); i++) {
|
| ResolveInfo match = matches.get(i);
|
| String packageName = match.activityInfo.packageName;
|
| + // Do not recommend disabled apps.
|
| + if (!PaymentPreferencesUtil.isAndroidPaymentAppEnabled(packageName)) continue;
|
| AndroidPaymentApp installedApp = installedApps.get(packageName);
|
| if (installedApp == null) {
|
| CharSequence label = match.loadLabel(pm);
|
| @@ -81,4 +86,40 @@ public class AndroidPaymentAppFactory implements PaymentAppFactoryAddition {
|
|
|
| callback.onAllPaymentAppsCreated();
|
| }
|
| +
|
| + /**
|
| + * Checks whether there are Android payment apps on device.
|
| + *
|
| + * @return True if there are Android payment apps on device.
|
| + */
|
| + public static boolean hasAndroidPaymentApps() {
|
| + PackageManager pm = ContextUtils.getApplicationContext().getPackageManager();
|
| + // Note that all Android payment apps must support org.chromium.intent.action.PAY action
|
| + // without additional data to be detected.
|
| + Intent payIntent = new Intent(AndroidPaymentApp.ACTION_PAY);
|
| + return !pm.queryIntentActivities(payIntent, 0).isEmpty();
|
| + }
|
| +
|
| + /**
|
| + * Gets Android payments apps' information on device.
|
| + *
|
| + * @return Map of Android payment apps' package names to their information. Each entry of the
|
| + * map represents an app and the value stores its name and icon.
|
| + */
|
| + public static Map<String, Pair<String, Drawable>> getAndroidPaymentAppsInfo() {
|
| + Map<String, Pair<String, Drawable>> paymentAppsInfo = new HashMap<>();
|
| +
|
| + PackageManager pm = ContextUtils.getApplicationContext().getPackageManager();
|
| + Intent payIntent = new Intent(AndroidPaymentApp.ACTION_PAY);
|
| + List<ResolveInfo> matches = pm.queryIntentActivities(payIntent, 0);
|
| + if (matches.isEmpty()) return paymentAppsInfo;
|
| +
|
| + for (ResolveInfo match : matches) {
|
| + Pair<String, Drawable> appInfo =
|
| + new Pair<String, Drawable>(match.loadLabel(pm).toString(), match.loadIcon(pm));
|
| + paymentAppsInfo.put(match.activityInfo.packageName, appInfo);
|
| + }
|
| +
|
| + return paymentAppsInfo;
|
| + }
|
| }
|
|
|