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