OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_ |
| 7 |
| 8 #include "ui/views/controls/textfield/textfield.h" |
| 9 |
| 10 namespace payments { |
| 11 |
| 12 class ValidatingTextfield : public views::Textfield { |
| 13 public: |
| 14 class Delegate { |
| 15 public: |
| 16 // Only the delegate knows how to validate textfield. |
| 17 virtual bool ValidateTextfield(ValidatingTextfield* textfield) = 0; |
| 18 }; |
| 19 |
| 20 explicit ValidatingTextfield(ValidatingTextfield::Delegate* delegate); |
| 21 |
| 22 // The first validation will happen on blur. |
| 23 void OnBlur() override; |
| 24 |
| 25 // Called when the textfield contents is changed. May do validation. |
| 26 void OnContentsChanged(); |
| 27 |
| 28 private: |
| 29 // Will call to the Delegate to validate the contents of the textfield. |
| 30 void Validate(); |
| 31 |
| 32 ValidatingTextfield::Delegate* delegate_; |
| 33 bool was_validated_ = false; |
| 34 }; |
| 35 |
| 36 } // namespace payments |
| 37 |
| 38 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_ |
OLD | NEW |