Chromium Code Reviews| Index: chrome/browser/ui/views/payments/validating_textfield.h |
| diff --git a/chrome/browser/ui/views/payments/validating_textfield.h b/chrome/browser/ui/views/payments/validating_textfield.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d347438bcdb58b41761b4958922500a82eb42a00 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/payments/validating_textfield.h |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_ |
| + |
| +#include "ui/views/controls/textfield/textfield.h" |
| + |
| +namespace payments { |
| + |
| +class ValidatingTextfield : public views::Textfield { |
| + public: |
| + class Delegate { |
| + public: |
|
please use gerrit instead
2017/02/08 18:50:55
Need an empty destructor:
"To make sure all imple
Mathieu
2017/02/08 21:21:50
Done.
|
| + // Only the delegate knows how to validate textfield. |
| + virtual bool ValidateTextfield(ValidatingTextfield* textfield) = 0; |
| + }; |
|
anthonyvd
2017/02/08 15:28:28
DISALLOW_COPY_AND_ASSIGN
Mathieu
2017/02/08 21:21:51
Done.
|
| + |
| + explicit ValidatingTextfield(ValidatingTextfield::Delegate* delegate); |
| + |
| + // The first validation will happen on blur. |
| + void OnBlur() override; |
|
anthonyvd
2017/02/08 15:28:28
nit: comment about where the override is from.
Mathieu
2017/02/08 21:21:50
Done.
|
| + |
| + // Called when the textfield contents is changed. May do validation. |
| + void OnContentsChanged(); |
| + |
| + private: |
| + // Will call to the Delegate to validate the contents of the textfield. |
| + void Validate(); |
| + |
| + ValidatingTextfield::Delegate* delegate_; |
| + bool was_validated_ = false; |
| +}; |
|
anthonyvd
2017/02/08 15:28:28
DISALLOW_COPY_AND_ASSIGN
Mathieu
2017/02/08 21:21:50
Done.
|
| + |
| +} // namespace payments |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_ |