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

Unified Diff: chrome/browser/ui/views/payments/validating_textfield.h

Issue 2673753005: [Payments] Basic validation in the credit card editor. (Closed)
Patch Set: more tests 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698