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

Unified Diff: components/autofill/core/browser/autofill_cc_infobar_delegate.cc

Issue 1540423004: Add card details and legal message to Android save credit card infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Justin's nits. Created 4 years, 11 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: components/autofill/core/browser/autofill_cc_infobar_delegate.cc
diff --git a/components/autofill/core/browser/autofill_cc_infobar_delegate.cc b/components/autofill/core/browser/autofill_cc_infobar_delegate.cc
index 97703b27c946f9ae13c1dc7779d9b723b876f47e..b36994aba172a129e01eaa42b64a9ceb84b553de 100644
--- a/components/autofill/core/browser/autofill_cc_infobar_delegate.cc
+++ b/components/autofill/core/browser/autofill_cc_infobar_delegate.cc
@@ -4,9 +4,13 @@
#include "components/autofill/core/browser/autofill_cc_infobar_delegate.h"
+#include <utility>
+
#include "base/logging.h"
+#include "base/values.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/credit_card.h"
+#include "components/autofill/core/browser/legal_message_line.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/infobars/core/infobar.h"
@@ -14,6 +18,7 @@
#include "grit/components_scaled_resources.h"
#include "grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/window_open_disposition.h"
#include "ui/gfx/vector_icons_public.h"
#include "url/gurl.h"
@@ -22,34 +27,58 @@ namespace autofill {
// static
void AutofillCCInfoBarDelegate::CreateForLocalSave(
infobars::InfoBarManager* infobar_manager,
+ const CreditCard& card,
const base::Closure& save_card_callback) {
- infobar_manager->AddInfoBar(
- infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
- new AutofillCCInfoBarDelegate(false, save_card_callback))));
+ infobar_manager->AddInfoBar(infobar_manager->CreateAutofillCCInfoBar(
+ make_scoped_ptr(new AutofillCCInfoBarDelegate(
+ false, card, scoped_ptr<base::DictionaryValue>(nullptr),
+ save_card_callback))));
}
// static
void AutofillCCInfoBarDelegate::CreateForUpload(
infobars::InfoBarManager* infobar_manager,
+ const CreditCard& card,
+ scoped_ptr<base::DictionaryValue> legal_message,
const base::Closure& save_card_callback) {
- infobar_manager->AddInfoBar(
- infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
- new AutofillCCInfoBarDelegate(true, save_card_callback))));
+ infobar_manager->AddInfoBar(infobar_manager->CreateAutofillCCInfoBar(
+ make_scoped_ptr(new AutofillCCInfoBarDelegate(
+ true, card, std::move(legal_message), save_card_callback))));
+}
+
+AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
+ if (!had_user_interaction_)
+ LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
+}
+
+void AutofillCCInfoBarDelegate::OnLegalMessageLinkClicked(GURL url) {
+ infobar()->owner()->OpenURL(url, NEW_FOREGROUND_TAB);
}
AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
bool upload,
+ const CreditCard& card,
+ scoped_ptr<base::DictionaryValue> legal_message,
const base::Closure& save_card_callback)
: ConfirmInfoBarDelegate(),
upload_(upload),
+#if defined(OS_IOS)
+ // TODO(rouslan): Use credit card issuer images on iOS.
+ // http://crbug.com/535784
+ issuer_icon_id_(kNoIconID),
+#else
+ issuer_icon_id_(CreditCard::IconResourceId(
+ CreditCard::GetCreditCardType(card.GetRawInfo(CREDIT_CARD_NUMBER)))),
+#endif // defined(OS_IOS)
+ card_label_(card.LastFourDigitsForDisplay()),
+ card_sub_label_(card.AbbreviatedExpirationDateForDisplay()),
save_card_callback_(save_card_callback),
had_user_interaction_(false) {
- AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
-}
+ if (legal_message) {
Peter Kasting 2016/01/08 00:34:31 Nit: {} unnecessary
please use gerrit instead 2016/01/12 00:47:25 Done.
+ LegalMessageLine::Parse(*legal_message, &legal_messages_);
+ }
-AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
- if (!had_user_interaction_)
- LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
+ AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
}
void AutofillCCInfoBarDelegate::LogUserAction(

Powered by Google App Engine
This is Rietveld 408576698