| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 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_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_ | |
| 6 #define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_ | |
| 7 | |
| 8 #import <Cocoa/Cocoa.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/mac/scoped_nsobject.h" | |
| 13 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | |
| 14 #import "chrome/browser/ui/cocoa/autofill/autofill_input_field.h" | |
| 15 #import "chrome/browser/ui/cocoa/autofill/autofill_layout.h" | |
| 16 #include "components/autofill/core/browser/detail_input.h" | |
| 17 #include "components/autofill/core/browser/dialog_section.h" | |
| 18 | |
| 19 namespace autofill { | |
| 20 class AutofillDialogViewDelegate; | |
| 21 } | |
| 22 | |
| 23 @class AutofillSectionView; | |
| 24 @class AutofillSuggestionContainer; | |
| 25 @class AutofillTextField; | |
| 26 @class AutofillTooltipController; | |
| 27 @class LayoutView; | |
| 28 @class MenuButton; | |
| 29 @class MenuController; | |
| 30 | |
| 31 // Delegate to handle display of validation messages. | |
| 32 @protocol AutofillValidationDisplay | |
| 33 | |
| 34 // Updates the validation message for a given field. | |
| 35 - (void)updateMessageForField:(NSControl<AutofillInputField>*)field; | |
| 36 | |
| 37 // Hides the validation error bubble. | |
| 38 - (void)hideErrorBubble; | |
| 39 | |
| 40 @end | |
| 41 | |
| 42 | |
| 43 // View delegate for a section of the payment details. Contains a label | |
| 44 // describing the section as well as associated inputs and controls. Built | |
| 45 // dynamically based on data retrieved from AutofillDialogViewDelegate. | |
| 46 @interface AutofillSectionContainer : | |
| 47 NSViewController<AutofillLayout, AutofillInputDelegate> { | |
| 48 @private | |
| 49 base::scoped_nsobject<LayoutView> inputs_; | |
| 50 base::scoped_nsobject<MenuButton> suggestButton_; | |
| 51 base::scoped_nsobject<AutofillSuggestionContainer> suggestContainer_; | |
| 52 base::scoped_nsobject<NSTextField> label_; | |
| 53 | |
| 54 // The view for the container. | |
| 55 base::scoped_nsobject<AutofillSectionView> view_; | |
| 56 | |
| 57 // Some sections need to show an icon with an associated tooltip. This is the | |
| 58 // controller for such an icon. There is at most one such icon per section. | |
| 59 base::scoped_nsobject<AutofillTooltipController> tooltipController_; | |
| 60 | |
| 61 // The logical superview for the tooltip icon. Weak pointer, owned by | |
| 62 // |inputs_|. | |
| 63 AutofillTextField* tooltipField_; | |
| 64 | |
| 65 // List of weak pointers, which constitute unique field IDs. | |
| 66 std::vector<const autofill::DetailInput*> detailInputs_; | |
| 67 | |
| 68 // A delegate to handle display of validation messages. Not owned. | |
| 69 id<AutofillValidationDisplay> validationDelegate_; | |
| 70 | |
| 71 // Indicate whether the dialog should show suggestions or manual inputs when | |
| 72 // performLayout is triggered. | |
| 73 BOOL showSuggestions_; | |
| 74 | |
| 75 base::scoped_nsobject<MenuController> menuController_; | |
| 76 autofill::DialogSection section_; | |
| 77 autofill::AutofillDialogViewDelegate* delegate_; // Not owned. | |
| 78 } | |
| 79 | |
| 80 @property(readonly, nonatomic) autofill::DialogSection section; | |
| 81 @property(assign, nonatomic) id<AutofillValidationDisplay> validationDelegate; | |
| 82 | |
| 83 // Designated initializer. Queries |delegate| for the list of desired input | |
| 84 // fields for |section|. | |
| 85 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate | |
| 86 forSection:(autofill::DialogSection)section; | |
| 87 | |
| 88 // Populates |output| with mappings from field identification to input value. | |
| 89 - (void)getInputs:(autofill::FieldValueMap*)output; | |
| 90 | |
| 91 // Called when the delegate-maintained suggestions model has changed. | |
| 92 - (void)modelChanged; | |
| 93 | |
| 94 // Called when the contents of a section have changed. | |
| 95 - (void)update; | |
| 96 | |
| 97 // Fills the section with Autofill data that was triggered by a user | |
| 98 // interaction with the originating |type|. | |
| 99 - (void)fillForType:(const autofill::ServerFieldType)type; | |
| 100 | |
| 101 // Validate this section. Validation rules depend on |validationType|. | |
| 102 - (BOOL)validateFor:(autofill::ValidationType)validationType; | |
| 103 | |
| 104 // Returns the value of the |suggestContainer_|'s input field, or nil if no | |
| 105 // suggestion is currently showing. | |
| 106 - (NSString*)suggestionText; | |
| 107 | |
| 108 // Collects all input fields (direct & suggestions) into the given |array|. | |
| 109 - (void)addInputsToArray:(NSMutableArray*)array; | |
| 110 | |
| 111 @end | |
| 112 | |
| 113 @interface AutofillSectionContainer (ForTesting) | |
| 114 | |
| 115 // Retrieve the field associated with the given type. | |
| 116 - (NSControl<AutofillInputField>*)getField:(autofill::ServerFieldType)type; | |
| 117 | |
| 118 // Sets the value for the field matching |type|. Does nothing if the field is | |
| 119 // not part of this section. | |
| 120 - (void)setFieldValue:(NSString*)text | |
| 121 forType:(autofill::ServerFieldType)type; | |
| 122 | |
| 123 // Sets the value for the suggestion text field. | |
| 124 - (void)setSuggestionFieldValue:(NSString*)text; | |
| 125 | |
| 126 // Activates a given input field, determined by |type|. Does nothing if the | |
| 127 // field is not part of this section. | |
| 128 - (void)activateFieldForType:(autofill::ServerFieldType)type; | |
| 129 | |
| 130 @end | |
| 131 | |
| 132 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_ | |
| OLD | NEW |