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..76ba0e6103c0c9c40651fb8277058b21ccd90685 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillAssistInfoBar.java |
@@ -0,0 +1,85 @@ |
+// 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.ArrayList; |
+import java.util.List; |
+ |
+/** |
+ * An infobar for assisted credit card filling. |
+ */ |
+public class AutofillAssistInfoBar extends ConfirmInfoBar { |
+ private final long mNativeAutofillAssistInfoBar; |
gone
2016/08/01 20:35:54
1) Are you planning on using this pointer at some
Mathieu
2016/08/01 22:16:57
Done.
|
+ private final List<CardDetail> mCardDetails = new ArrayList<>(); |
+ |
+ /** |
+ * 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 assisted credit card filling. |
+ * |
+ * @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 proposed for the assist. |
+ * |
+ * @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 (int i = 0; i < mCardDetails.size(); i++) { |
+ CardDetail detail = mCardDetails.get(i); |
+ control.addIcon(detail.issuerIconDrawableId, 0, detail.label, detail.subLabel); |
+ } |
+ } |
+} |