| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 5 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 namespace payments { | 9 namespace payments { |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 void ValidatingTextfield::OnContentsChanged() { | 35 void ValidatingTextfield::OnContentsChanged() { |
| 36 // Validation on every keystroke only happens if the field has been validated | 36 // Validation on every keystroke only happens if the field has been validated |
| 37 // before as part of a blur. | 37 // before as part of a blur. |
| 38 if (!was_blurred_) | 38 if (!was_blurred_) |
| 39 return; | 39 return; |
| 40 | 40 |
| 41 Validate(); | 41 Validate(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool ValidatingTextfield::IsValid() { |
| 45 bool valid = delegate_->IsValidTextfield(this); |
| 46 SetInvalid(!valid); |
| 47 return valid; |
| 48 } |
| 49 |
| 44 void ValidatingTextfield::Validate() { | 50 void ValidatingTextfield::Validate() { |
| 45 // ValidateTextfield may have side-effects, such as displaying errors. | 51 // TextfieldValueChanged may have side-effects, such as displaying errors. |
| 46 SetInvalid(!delegate_->ValidateTextfield(this)); | 52 SetInvalid(!delegate_->TextfieldValueChanged(this)); |
| 47 } | 53 } |
| 48 | 54 |
| 49 } // namespace payments | 55 } // namespace payments |
| OLD | NEW |