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

Side by Side Diff: ios/chrome/browser/payments/payment_request_edit_view_controller.h

Issue 2744823003: [Payment Request] Generic edit form (Closed)
Patch Set: Created 3 years, 9 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 IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_EDIT_VIEW_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_EDIT_VIEW_CONTROLLER_H_
7
8 #import <UIKit/UIKit.h>
9 #include <vector>
10
11 #include "components/autofill/core/browser/field_types.h"
12 #include "ios/chrome/browser/payments/payment_request.h"
13 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
14
15 // Field definition for an editor field. Used for building the UI and
16 // validation.
17 struct EditorField {
18 EditorField(autofill::ServerFieldType data_type,
19 const base::string16& label,
20 bool required,
21 int item_type,
22 int section_id)
23 : data_type(data_type),
24 label(label),
25 required(required),
26 item_type(item_type),
27 section_id(section_id) {}
28
29 // Data type for the field.
30 const autofill::ServerFieldType data_type;
31 // Label for the field.
32 const base::string16 label;
33 // Whether the field is required.
34 bool required;
35 // Item type for the field.
36 int item_type;
37 // Section identifier for the field.
38 int section_id;
39 };
40
41 // The collection view controller for a generic Payment Request edit screen. It
42 // Features sections for every EditorField returned by -editorFields. Each
43 // section has a text field as well as an optional error message item.
44 @interface PaymentRequestEditViewController
45 : CollectionViewController<UITextFieldDelegate>
46
47 // Subclasses override this method to returns a list of field definitions for
48 // the editor.
49 - (std::vector<EditorField>)editorFields;
50
51 // Returns the index path for the cell associated with the currently focused
52 // text field.
53 - (NSIndexPath*)indexPathForCurrentTextField;
54
55 // Returns the validation error string for |value| for the autofill type
56 // |autofillType|. |required| indicates wether this is a required field or not.
57 // If there are no validation errors an empty string is returned.
58 - (NSString*)validateValue:(NSString*)value
59 autofillType:(autofill::ServerFieldType)autofillType
60 required:(BOOL)required;
61
62 // Adds an error message item with the type |itemType| in the section
63 // |sectionIdentifier| if |errorMessage| is non-empty. Otherwise removes such an
64 // item if one exists.
65 - (void)addOrRemoveErrorItemWithType:(NSInteger)itemType
66 errorMessage:(NSString*)errorMessage
67 inSectionWithIdentifier:(NSInteger)sectionIdentifier;
68
69 // Initializes this object with an instance of PaymentRequest which owns an
70 // instance of web::PaymentRequest as provided by the page invoking the Payment
71 // Request API. This object will not take ownership of |paymentRequest|.
72 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest
73 NS_DESIGNATED_INITIALIZER;
74
75 - (instancetype)init NS_UNAVAILABLE;
76
77 - (instancetype)initWithStyle:(CollectionViewControllerStyle)style
78 NS_UNAVAILABLE;
79
80 @end
81
82 #endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_EDIT_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698