| 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:
|
| + // Only the delegate knows how to validate textfield.
|
| + virtual bool ValidateTextfield(ValidatingTextfield* textfield) = 0;
|
| + };
|
| +
|
| + explicit ValidatingTextfield(ValidatingTextfield::Delegate* delegate);
|
| +
|
| + // The first validation will happen on blur.
|
| + void OnBlur() override;
|
| +
|
| + // 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;
|
| +};
|
| +
|
| +} // namespace payments
|
| +
|
| +#endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_
|
|
|