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

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

Issue 2694693003: [Payments] Add support for required fields in editor validation (Closed)
Patch Set: addressed comments 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector> 10 #include <vector>
(...skipping 16 matching lines...) Expand all
27 27
28 class PaymentRequest; 28 class PaymentRequest;
29 class PaymentRequestDialogView; 29 class PaymentRequestDialogView;
30 30
31 // Field definition for an editor field, used to build the UI. 31 // Field definition for an editor field, used to build the UI.
32 struct EditorField { 32 struct EditorField {
33 enum class LengthHint : int { HINT_LONG, HINT_SHORT }; 33 enum class LengthHint : int { HINT_LONG, HINT_SHORT };
34 34
35 EditorField(autofill::ServerFieldType type, 35 EditorField(autofill::ServerFieldType type,
36 const base::string16& label, 36 const base::string16& label,
37 LengthHint length_hint) 37 LengthHint length_hint,
38 : type(type), label(label), length_hint(length_hint) {} 38 bool required)
39 : type(type),
40 label(label),
41 length_hint(length_hint),
42 required(required) {}
39 43
44 // Data type in the field.
40 const autofill::ServerFieldType type; 45 const autofill::ServerFieldType type;
46 // Label to be shown alongside the field.
41 const base::string16 label; 47 const base::string16 label;
48 // Hint about the length of this field's contents.
42 LengthHint length_hint; 49 LengthHint length_hint;
50 // Whether the field is required.
51 bool required;
43 }; 52 };
44 53
45 // The PaymentRequestSheetController subtype for the editor screens of the 54 // The PaymentRequestSheetController subtype for the editor screens of the
46 // Payment Request flow. 55 // Payment Request flow.
47 class EditorViewController : public PaymentRequestSheetController, 56 class EditorViewController : public PaymentRequestSheetController,
48 public views::TextfieldController { 57 public views::TextfieldController {
49 public: 58 public:
50 using TextFieldsMap = 59 using TextFieldsMap =
51 std::unordered_map<ValidatingTextfield*, const EditorField>; 60 std::unordered_map<ValidatingTextfield*, const EditorField>;
52 61
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // parent view, this only keeps a reference that is good as long as the 100 // parent view, this only keeps a reference that is good as long as the
92 // textfield is visible. 101 // textfield is visible.
93 TextFieldsMap text_fields_; 102 TextFieldsMap text_fields_;
94 103
95 DISALLOW_COPY_AND_ASSIGN(EditorViewController); 104 DISALLOW_COPY_AND_ASSIGN(EditorViewController);
96 }; 105 };
97 106
98 } // namespace payments 107 } // namespace payments
99 108
100 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 109 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698