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

Unified Diff: chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc

Issue 2789843004: [Payments] Upload card UI now has a CVC prompt (Closed)
Patch Set: Addressing code review comments Created 3 years, 9 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/browser/ui/autofill/save_card_bubble_controller_impl.cc
diff --git a/chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc b/chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc
index 4165569f259dcdab1ce1c86303bfa55917a05c82..29ab81a31f3c172115d6c7cbf0e3ab3c143f1336 100644
--- a/chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc
+++ b/chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc
@@ -12,7 +12,9 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "components/autofill/core/browser/autofill_metrics.h"
+#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/autofill_constants.h"
+#include "components/grit/components_scaled_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/navigation_handle.h"
#include "ui/base/l10n/l10n_util.h"
@@ -47,6 +49,7 @@ void SaveCardBubbleControllerImpl::ShowBubbleForLocalSave(
const base::Closure& save_card_callback) {
is_uploading_ = false;
is_reshow_ = false;
+ should_cvc_be_requested_ = false;
legal_message_lines_.clear();
AutofillMetrics::LogSaveCardPromptMetric(
@@ -61,9 +64,11 @@ void SaveCardBubbleControllerImpl::ShowBubbleForLocalSave(
void SaveCardBubbleControllerImpl::ShowBubbleForUpload(
const CreditCard& card,
std::unique_ptr<base::DictionaryValue> legal_message,
+ const bool should_cvc_be_requested,
const base::Closure& save_card_callback) {
is_uploading_ = true;
is_reshow_ = false;
+ should_cvc_be_requested_ = should_cvc_be_requested;
AutofillMetrics::LogSaveCardPromptMetric(
AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_,
is_reshow_);
@@ -121,6 +126,29 @@ const CreditCard SaveCardBubbleControllerImpl::GetCard() const {
return card_;
}
+int SaveCardBubbleControllerImpl::GetCvcImageRid() const {
Mathieu 2017/04/03 19:46:09 Rid -> ResourceId?
Jared Saul 2017/04/03 21:19:17 Done.
+ return card_.type() == kAmericanExpressCard ? IDR_CREDIT_CARD_CVC_HINT_AMEX
+ : IDR_CREDIT_CARD_CVC_HINT;
+}
+
+bool SaveCardBubbleControllerImpl::ShouldRequestCvcFromUser() const {
+ return should_cvc_be_requested_;
+}
+
+void SaveCardBubbleControllerImpl::SetCvcEnteredByUser(
+ const base::string16& cvc) {
+ DCHECK(ShouldRequestCvcFromUser());
+ DCHECK(!cvc.empty());
+ base::string16 trimmed_cvc;
+ base::TrimWhitespace(cvc, base::TRIM_ALL, &trimmed_cvc);
+ cvc_entered_by_user_ = trimmed_cvc;
+}
+
+base::string16 SaveCardBubbleControllerImpl::GetCvcEnteredByUser() const {
+ DCHECK(!cvc_entered_by_user_.empty());
+ return cvc_entered_by_user_;
+}
+
void SaveCardBubbleControllerImpl::OnSaveButton() {
save_card_callback_.Run();
save_card_callback_.Reset();
@@ -159,6 +187,13 @@ const LegalMessageLines& SaveCardBubbleControllerImpl::GetLegalMessageLines()
return legal_message_lines_;
}
+bool SaveCardBubbleControllerImpl::InputCvcIsValid(
+ const base::string16& input_text) const {
+ base::string16 trimmed_text;
+ base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text);
+ return IsValidCreditCardSecurityCode(trimmed_text, card_.type());
+}
+
base::TimeDelta SaveCardBubbleControllerImpl::Elapsed() const {
return timer_->Elapsed();
}

Powered by Google App Engine
This is Rietveld 408576698