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 69f2955d80e818f83b3ff6555e5b146b4391b2de..5af268d19ea19c70482c64e5a3840e5341307f8c 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" |
@@ -18,32 +22,70 @@ |
#include "url/gurl.h" |
namespace autofill { |
+namespace { |
+ |
+// Number of card details to show in the details section of the infobar. |
+const int kNumberOfCards = 1; |
+ |
+} // namespace |
// static |
void AutofillCCInfoBarDelegate::CreateForLocalSave( |
infobars::InfoBarManager* infobar_manager, |
- const base::Closure& save_card_callback) { |
- infobar_manager->AddInfoBar( |
- infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
- new AutofillCCInfoBarDelegate(false, save_card_callback)))); |
+ const base::Closure& save_card_callback, |
+ const CreditCard& card) { |
+ scoped_ptr<base::DictionaryValue> no_legal_message; |
+ infobar_manager->AddInfoBar(infobar_manager->CreateConfirmInfoBar( |
+ scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate( |
+ false, save_card_callback, card, std::move(no_legal_message))))); |
} |
// static |
void AutofillCCInfoBarDelegate::CreateForUpload( |
infobars::InfoBarManager* infobar_manager, |
- const base::Closure& save_card_callback) { |
- infobar_manager->AddInfoBar( |
- infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
- new AutofillCCInfoBarDelegate(true, save_card_callback)))); |
+ const base::Closure& save_card_callback, |
+ const CreditCard& card, |
+ scoped_ptr<base::DictionaryValue> legal_message) { |
+ infobar_manager->AddInfoBar(infobar_manager->CreateConfirmInfoBar( |
+ scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate( |
+ true, save_card_callback, card, std::move(legal_message))))); |
} |
AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( |
bool upload, |
- const base::Closure& save_card_callback) |
+ const base::Closure& save_card_callback, |
+ const CreditCard& card, |
+ scoped_ptr<base::DictionaryValue> legal_message) |
: ConfirmInfoBarDelegate(), |
upload_(upload), |
save_card_callback_(save_card_callback), |
+ card_details_(kNumberOfCards), |
had_user_interaction_(false) { |
+#if !defined(OS_IOS) |
+ // TODO(rouslan): Use credit card issuer images on iOS. |
+ // http://crbug.com/535784 |
+ card_details_.front().icon_id = CreditCard::IconResourceId( |
+ CreditCard::GetCreditCardType(card.GetRawInfo(CREDIT_CARD_NUMBER))); |
+#endif |
+ |
+ card_details_.front().label = card.LastFourDigitsForDisplay(); |
+ card_details_.front().sub_label = card.AbbreviatedExpirationDateForDisplay(); |
+ |
+ if (legal_message) { |
+ LegalMessageLines parsed_legal_message; |
+ LegalMessageLine::Parse(*legal_message, &parsed_legal_message); |
+ for (const auto& line : parsed_legal_message) { |
+ legal_messages_.push_back(Description()); |
+ legal_messages_.back().text = line.text(); |
Justin Donnelly
2015/12/30 18:06:37
When we discussed copying LegalMessage into anothe
please use gerrit instead
2016/01/07 01:39:25
Done.
|
+ for (const auto& link : line.links()) { |
+ legal_messages_.back().links.push_back(Description::Link()); |
+ legal_messages_.back().links.back().start = link.range.start(); |
+ legal_messages_.back().links.back().end = link.range.end(); |
+ legal_messages_.back().links.back().url = link.url; |
+ } |
+ } |
+ } |
+ |
AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); |
} |
@@ -77,6 +119,16 @@ gfx::VectorIconId AutofillCCInfoBarDelegate::GetVectorIconId() const { |
#endif |
} |
+const std::vector<infobars::InfoBarDelegate::Detail>& |
+AutofillCCInfoBarDelegate::GetDetails() const { |
+ return card_details_; |
+} |
+ |
+const std::vector<infobars::InfoBarDelegate::Description>& |
+AutofillCCInfoBarDelegate::GetDescriptions() const { |
+ return legal_messages_; |
+} |
+ |
bool AutofillCCInfoBarDelegate::ShouldExpire( |
const NavigationDetails& details) const { |
// The user has submitted a form, causing the page to navigate elsewhere. We |