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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillAssistInfoBar.java

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 5 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/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.
please use gerrit instead 2016/07/27 17:02:25 This comment is not correct.
Mathieu 2016/07/27 21:35:52 Done. Sorry, so many files to keep track of :\
+ */
+public class AutofillAssistInfoBar extends ConfirmInfoBar {
+ /**
+ * Detailed card information to show in the infobar.
+ */
+ public static class CardDetail {
please use gerrit instead 2016/07/27 17:02:26 Let's extract this into a CardDetail.java that can
Mathieu 2016/07/27 21:35:52 Done.
+ /**
+ * 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>();
please use gerrit instead 2016/07/27 17:02:26 new ArrayList<>(); Android's LinkedLists are inef
Mathieu 2016/07/27 21:35:52 Done.
+
+ /**
+ * 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.
please use gerrit instead 2016/07/27 17:02:25 This comment is not correct.
Mathieu 2016/07/27 21:35:52 Done.
+ *
+ * @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.
please use gerrit instead 2016/07/27 17:02:25 This comment is not correct.
Mathieu 2016/07/27 21:35:52 Done.
+ *
+ * @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) {
please use gerrit instead 2016/07/27 17:02:26 Use integer loops, because they are more efficient
Mathieu 2016/07/27 21:35:52 Done.
+ control.addIcon(detail.issuerIconDrawableId, 0, detail.label, detail.subLabel);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698