| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillAssistInfoBar.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillAssistInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillAssistInfoBar.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fdaeee808fed685df533e602de97877c43f1c249
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillAssistInfoBar.java
|
| @@ -0,0 +1,119 @@
|
| +// Copyright 2016 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.infobar;
|
| +
|
| +import android.graphics.Bitmap;
|
| +
|
| +import org.chromium.base.annotations.CalledByNative;
|
| +import org.chromium.chrome.browser.ResourceId;
|
| +
|
| +import java.util.LinkedList;
|
| +import java.util.List;
|
| +
|
| +/**
|
| + * An infobar for saving credit card information.
|
| + */
|
| +public class AutofillAssistInfoBar extends ConfirmInfoBar {
|
| + /**
|
| + * Detailed card information to show in the infobar.
|
| + */
|
| + public static class CardDetail {
|
| + /**
|
| + * The identifier of the drawable of the card issuer icon.
|
| + */
|
| + public int issuerIconDrawableId;
|
| +
|
| + /**
|
| + * The label for the card.
|
| + */
|
| + public String label;
|
| +
|
| + /**
|
| + * The sub-label for the card.
|
| + */
|
| + public String subLabel;
|
| +
|
| + /**
|
| + * Creates a new instance of the detailed card information.
|
| + *
|
| + * @param enumeratedIconId ID corresponding to the icon that will be shown for this credit
|
| + * card. The ID must have been mapped using the ResourceMapper class
|
| + * before passing it to this function.
|
| + * @param label The credit card label, for example "***1234".
|
| + * @param subLabel The credit card sub-label, for example "Exp: 06/17".
|
| + */
|
| + public CardDetail(int enumeratedIconId, String label, String subLabel) {
|
| + this.issuerIconDrawableId = ResourceId.mapToDrawableId(enumeratedIconId);
|
| + this.label = label;
|
| + this.subLabel = subLabel;
|
| + }
|
| + }
|
| +
|
| + private final long mNativeAutofillAssistInfoBar;
|
| + private final List<CardDetail> mCardDetails = new LinkedList<CardDetail>();
|
| +
|
| + /**
|
| + * Creates a new instance of the infobar.
|
| + *
|
| + * @param nativeAutofillAssistInfoBar The pointer to the native object for callbacks.
|
| + * @param enumeratedIconId ID corresponding to the icon that will be shown for the InfoBar.
|
| + * The ID must have been mapped using the ResourceMapper class before
|
| + * passing it to this function.
|
| + * @param iconBitmap Bitmap to use if there is no equivalent Java resource for enumeratedIconId.
|
| + * @param message Message to display to the user indicating what the InfoBar is for.
|
| + * @param buttonOk String to display on the OK button.
|
| + * @param buttonCancel String to display on the Cancel button.
|
| + */
|
| + private AutofillAssistInfoBar(long nativeAutofillAssistInfoBar, int enumeratedIconId,
|
| + Bitmap iconBitmap, String message, String buttonOk, String buttonCancel) {
|
| + super(ResourceId.mapToDrawableId(enumeratedIconId), iconBitmap, message, null, buttonOk,
|
| + buttonCancel);
|
| + mNativeAutofillAssistInfoBar = nativeAutofillAssistInfoBar;
|
| + }
|
| +
|
| + /**
|
| + * Creates an infobar for saving a credit card.
|
| + *
|
| + * @param nativeAutofillAssistInfoBar The pointer to the native object for callbacks.
|
| + * @param enumeratedIconId ID corresponding to the icon that will be shown for the InfoBar.
|
| + * The ID must have been mapped using the ResourceMapper class before
|
| + * passing it to this function.
|
| + * @param iconBitmap Bitmap to use if there is no equivalent Java resource for enumeratedIconId.
|
| + * @param message Message to display to the user indicating what the InfoBar is for.
|
| + * @param buttonOk String to display on the OK button.
|
| + * @param buttonCancel String to display on the Cancel button.
|
| + * @return A new instance of the infobar.
|
| + */
|
| + @CalledByNative
|
| + private static AutofillAssistInfoBar create(long nativeAutofillAssistInfoBar,
|
| + int enumeratedIconId, Bitmap iconBitmap, String message, String buttonOk,
|
| + String buttonCancel) {
|
| + return new AutofillAssistInfoBar(nativeAutofillAssistInfoBar, enumeratedIconId, iconBitmap,
|
| + message, buttonOk, buttonCancel);
|
| + }
|
| +
|
| + /**
|
| + * Adds information to the infobar about the credit card that will be saved.
|
| + *
|
| + * @param enumeratedIconId ID corresponding to the icon that will be shown for this credit card.
|
| + * The ID must have been mapped using the ResourceMapper class before
|
| + * passing it to this function.
|
| + * @param label The credit card label, for example "***1234".
|
| + * @param subLabel The credit card sub-label, for example "Exp: 06/17".
|
| + */
|
| + @CalledByNative
|
| + private void addDetail(int enumeratedIconId, String label, String subLabel) {
|
| + mCardDetails.add(new CardDetail(enumeratedIconId, label, subLabel));
|
| + }
|
| +
|
| + @Override
|
| + public void createContent(InfoBarLayout layout) {
|
| + super.createContent(layout);
|
| + InfoBarControlLayout control = layout.addControlLayout();
|
| + for (CardDetail detail : mCardDetails) {
|
| + control.addIcon(detail.issuerIconDrawableId, 0, detail.label, detail.subLabel);
|
| + }
|
| + }
|
| +}
|
|
|