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

Side by Side Diff: chrome/browser/ui/views/payments/validating_textfield.h

Issue 2673753005: [Payments] Basic validation in the credit card editor. (Closed)
Patch Set: rebase Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(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 "base/macros.h"
9 #include "ui/views/controls/textfield/textfield.h"
10
11 namespace payments {
12
13 class ValidatingTextfield : public views::Textfield {
14 public:
15 class Delegate {
16 public:
17 Delegate() {}
18 virtual ~Delegate() {}
19
20 // Only the delegate knows how to validate the textfield.
21 virtual bool ValidateTextfield(views::Textfield* textfield) = 0;
22
23 private:
24 DISALLOW_COPY_AND_ASSIGN(Delegate);
25 };
26
27 explicit ValidatingTextfield(
28 std::unique_ptr<ValidatingTextfield::Delegate> delegate);
29 ~ValidatingTextfield() override;
30
31 // Textfield:
32 // The first validation will happen on blur.
33 void OnBlur() override;
34
35 // Called when the textfield contents is changed. May do validation.
36 void OnContentsChanged();
37
38 private:
39 // Will call to the Delegate to validate the contents of the textfield.
40 void Validate();
41
42 std::unique_ptr<ValidatingTextfield::Delegate> delegate_;
43 bool was_validated_ = false;
44
45 DISALLOW_COPY_AND_ASSIGN(ValidatingTextfield);
46 };
47
48 } // namespace payments
49
50 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_VALIDATING_TEXTFIELD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698