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

Unified Diff: chrome/browser/ui/views/payments/validating_textfield.cc

Issue 2896263002: [Payments] Changes to validation in the Credit Card editor (Closed)
Patch Set: Initial Created 3 years, 7 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/views/payments/validating_textfield.cc
diff --git a/chrome/browser/ui/views/payments/validating_textfield.cc b/chrome/browser/ui/views/payments/validating_textfield.cc
index fe3d02d22062309f6ae8205ee86349fdf68d66d0..2a60dd69479fcf8ded12f1cf36cf0324daa178c8 100644
--- a/chrome/browser/ui/views/payments/validating_textfield.cc
+++ b/chrome/browser/ui/views/payments/validating_textfield.cc
@@ -16,14 +16,11 @@ ValidatingTextfield::~ValidatingTextfield() {}
void ValidatingTextfield::OnBlur() {
Textfield::OnBlur();
+ was_blurred_ = true;
- // The first validation should be on a blur. The subsequent validations will
- // occur when the content changes. Do not validate if the view is being
- // removed.
- if (!was_blurred_ && !being_removed_) {
- was_blurred_ = true;
+ // Do not validate if the view is being removed.
+ if (!being_removed_)
Validate();
- }
}
void ValidatingTextfield::ViewHierarchyChanged(
@@ -33,23 +30,17 @@ void ValidatingTextfield::ViewHierarchyChanged(
}
void ValidatingTextfield::OnContentsChanged() {
- // Validation on every keystroke only happens if the field has been validated
- // before as part of a blur.
- if (!was_blurred_)
- return;
-
+ // This is called on every keystroke.
Validate();
}
bool ValidatingTextfield::IsValid() {
- bool valid = delegate_->IsValidTextfield(this);
- SetInvalid(!valid);
- return valid;
+ return delegate_->IsValidTextfield(this);
}
void ValidatingTextfield::Validate() {
// TextfieldValueChanged may have side-effects, such as displaying errors.
- SetInvalid(!delegate_->TextfieldValueChanged(this));
+ SetInvalid(!delegate_->TextfieldValueChanged(this, was_blurred_));
}
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698