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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/payments/payment_request_edit_view_controller.h
diff --git a/ios/chrome/browser/payments/payment_request_edit_view_controller.h b/ios/chrome/browser/payments/payment_request_edit_view_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..75669c296c9edc60ab77ffe47df82ba142c7e3cd
--- /dev/null
+++ b/ios/chrome/browser/payments/payment_request_edit_view_controller.h
@@ -0,0 +1,82 @@
+// 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 IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_EDIT_VIEW_CONTROLLER_H_
+#define IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_EDIT_VIEW_CONTROLLER_H_
+
+#import <UIKit/UIKit.h>
+#include <vector>
+
+#include "components/autofill/core/browser/field_types.h"
+#include "ios/chrome/browser/payments/payment_request.h"
+#import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
+
+// Field definition for an editor field. Used for building the UI and
+// validation.
+struct EditorField {
+ EditorField(autofill::ServerFieldType data_type,
+ const base::string16& label,
+ bool required,
+ int item_type,
+ int section_id)
+ : data_type(data_type),
+ label(label),
+ required(required),
+ item_type(item_type),
+ section_id(section_id) {}
+
+ // Data type for the field.
+ const autofill::ServerFieldType data_type;
+ // Label for the field.
+ const base::string16 label;
+ // Whether the field is required.
+ bool required;
+ // Item type for the field.
+ int item_type;
+ // Section identifier for the field.
+ int section_id;
+};
+
+// The collection view controller for a generic Payment Request edit screen. It
+// Features sections for every EditorField returned by -editorFields. Each
+// section has a text field as well as an optional error message item.
+@interface PaymentRequestEditViewController
+ : CollectionViewController<UITextFieldDelegate>
+
+// Subclasses override this method to returns a list of field definitions for
+// the editor.
+- (std::vector<EditorField>)editorFields;
+
+// Returns the index path for the cell associated with the currently focused
+// text field.
+- (NSIndexPath*)indexPathForCurrentTextField;
+
+// Returns the validation error string for |value| for the autofill type
+// |autofillType|. |required| indicates wether this is a required field or not.
+// If there are no validation errors an empty string is returned.
+- (NSString*)validateValue:(NSString*)value
+ autofillType:(autofill::ServerFieldType)autofillType
+ required:(BOOL)required;
+
+// Adds an error message item with the type |itemType| in the section
+// |sectionIdentifier| if |errorMessage| is non-empty. Otherwise removes such an
+// item if one exists.
+- (void)addOrRemoveErrorItemWithType:(NSInteger)itemType
+ errorMessage:(NSString*)errorMessage
+ inSectionWithIdentifier:(NSInteger)sectionIdentifier;
+
+// Initializes this object with an instance of PaymentRequest which owns an
+// instance of web::PaymentRequest as provided by the page invoking the Payment
+// Request API. This object will not take ownership of |paymentRequest|.
+- (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest
+ NS_DESIGNATED_INITIALIZER;
+
+- (instancetype)init NS_UNAVAILABLE;
+
+- (instancetype)initWithStyle:(CollectionViewControllerStyle)style
+ NS_UNAVAILABLE;
+
+@end
+
+#endif // IOS_CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_EDIT_VIEW_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698