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"
17 class AutofillDialogViewDelegate
;
20 @
class AutofillSectionView
;
21 @
class AutofillSuggestionContainer
;
22 @
class AutofillTextField
;
23 @
class AutofillTooltipController
;
26 @
class MenuController
;
28 // Delegate to handle display of validation messages.
29 @protocol AutofillValidationDisplay
31 // Updates the validation message for a given field.
32 - (void)updateMessageForField
:(NSControl
<AutofillInputField
>*)field
;
34 // Hides the validation error bubble.
35 - (void)hideErrorBubble
;
40 // View delegate for a section of the payment details. Contains a label
41 // describing the section as well as associated inputs and controls. Built
42 // dynamically based on data retrieved from AutofillDialogViewDelegate.
43 @interface AutofillSectionContainer
:
44 NSViewController
<AutofillLayout
, AutofillInputDelegate
> {
46 base::scoped_nsobject
<LayoutView
> inputs_
;
47 base::scoped_nsobject
<MenuButton
> suggestButton_
;
48 base::scoped_nsobject
<AutofillSuggestionContainer
> suggestContainer_
;
49 base::scoped_nsobject
<NSTextField
> label_
;
51 // The view for the container.
52 base::scoped_nsobject
<AutofillSectionView
> view_
;
54 // Some sections need to show an icon with an associated tooltip. This is the
55 // controller for such an icon. There is at most one such icon per section.
56 base::scoped_nsobject
<AutofillTooltipController
> tooltipController_
;
58 // The logical superview for the tooltip icon. Weak pointer, owned by
60 AutofillTextField
* tooltipField_
;
62 // List of weak pointers, which constitute unique field IDs.
63 std::vector
<const autofill::DetailInput
*> detailInputs_
;
65 // A delegate to handle display of validation messages. Not owned.
66 id
<AutofillValidationDisplay
> validationDelegate_
;
68 // Indicate whether the dialog should show suggestions or manual inputs when
69 // performLayout is triggered.
70 BOOL showSuggestions_
;
72 base::scoped_nsobject
<MenuController
> menuController_
;
73 autofill::DialogSection section_
;
74 autofill::AutofillDialogViewDelegate
* delegate_
; // Not owned.
77 @
property(readonly
, nonatomic
) autofill::DialogSection section
;
78 @
property(assign
, nonatomic
) id
<AutofillValidationDisplay
> validationDelegate
;
80 // Designated initializer. Queries |delegate| for the list of desired input
81 // fields for |section|.
82 - (id
)initWithDelegate
:(autofill::AutofillDialogViewDelegate
*)delegate
83 forSection
:(autofill::DialogSection
)section
;
85 // Populates |output| with mappings from field identification to input value.
86 - (void)getInputs
:(autofill::FieldValueMap
*)output
;
88 // Called when the delegate-maintained suggestions model has changed.
91 // Called when the contents of a section have changed.
94 // Fills the section with Autofill data that was triggered by a user
95 // interaction with the originating |type|.
96 - (void)fillForType
:(const autofill::ServerFieldType
)type
;
98 // Validate this section. Validation rules depend on |validationType|.
99 - (BOOL
)validateFor
:(autofill::ValidationType
)validationType
;
101 // Returns the value of the |suggestContainer_|'s input field, or nil if no
102 // suggestion is currently showing.
103 - (NSString
*)suggestionText
;
105 // Collects all input fields (direct & suggestions) into the given |array|.
106 - (void)addInputsToArray
:(NSMutableArray
*)array
;
110 @interface
AutofillSectionContainer (ForTesting
)
112 // Retrieve the field associated with the given type.
113 - (NSControl
<AutofillInputField
>*)getField
:(autofill::ServerFieldType
)type
;
115 // Sets the value for the field matching |type|. Does nothing if the field is
116 // not part of this section.
117 - (void)setFieldValue
:(NSString
*)text
118 forType
:(autofill::ServerFieldType
)type
;
120 // Sets the value for the suggestion text field.
121 - (void)setSuggestionFieldValue
:(NSString
*)text
;
123 // Activates a given input field, determined by |type|. Does nothing if the
124 // field is not part of this section.
125 - (void)activateFieldForType
:(autofill::ServerFieldType
)type
;
129 #endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_SECTION_CONTAINER_H_