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

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: 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..63590c4c2cd097a81af7cd09b61686b159cfa501 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;
+ upload_cvc_should_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 upload_cvc_should_be_requested,
const base::Closure& save_card_callback) {
is_uploading_ = true;
is_reshow_ = false;
+ upload_cvc_should_be_requested_ = upload_cvc_should_be_requested;
AutofillMetrics::LogSaveCardPromptMetric(
AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, is_uploading_,
is_reshow_);
@@ -121,6 +126,26 @@ const CreditCard SaveCardBubbleControllerImpl::GetCard() const {
return card_;
}
+int SaveCardBubbleControllerImpl::GetCvcImageRid() const {
+ return card_.type() == kAmericanExpressCard ? IDR_CREDIT_CARD_CVC_HINT_AMEX
+ : IDR_CREDIT_CARD_CVC_HINT;
+}
+
+bool SaveCardBubbleControllerImpl::ShouldRequestCvcFromUser() const {
+ return upload_cvc_should_be_requested_;
+}
+
+void SaveCardBubbleControllerImpl::SetUserProvidedCvc(
+ const base::string16& cvc) {
+ DCHECK(ShouldRequestCvcFromUser());
+ cvc_entered_by_user_ = cvc;
csashi 2017/03/31 21:48:15 No need to trim here?
Shanfeng 2017/03/31 22:58:45 Shouldn't we check non empty here?
Jared Saul 2017/04/01 04:18:02 Probably not because it's required to be digits-on
Jared Saul 2017/04/01 04:18:02 Yep I noticed that too; done. Thanks!
+}
+
+const base::string16 SaveCardBubbleControllerImpl::GetUserProvidedCvc() 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 +184,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