summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/autofill/autofill_main_container.h
blob: 8496753f1e7fd7b8ede56a2425494fdf840db48d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) 2013 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 CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_MAIN_CONTAINER_H_
#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_MAIN_CONTAINER_H_

#import <Cocoa/Cocoa.h>

#include "base/mac/scoped_nsobject.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h"
#include "components/autofill/core/browser/dialog_section.h"

@class AutofillDetailsContainer;
@class AutofillDialogWindowController;
@class AutofillNotificationContainer;
@class AutofillSectionContainer;
@class AutofillTooltipController;
@class GTMWidthBasedTweaker;
@class HyperlinkTextView;

namespace autofill {
  class AutofillDialogViewDelegate;
}

// NSViewController for the main portion of the autofill dialog. Contains
// account chooser, details for current payment instruments, OK/Cancel.
// Might dynamically add and remove other elements.
@interface AutofillMainContainer : NSViewController<AutofillLayout,
                                                    NSTextViewDelegate> {
 @private
  base::scoped_nsobject<GTMWidthBasedTweaker> buttonContainer_;
  base::scoped_nsobject<NSButton> saveInChromeCheckbox_;
  base::scoped_nsobject<AutofillTooltipController> saveInChromeTooltip_;
  base::scoped_nsobject<AutofillDetailsContainer> detailsContainer_;
  base::scoped_nsobject<AutofillNotificationContainer> notificationContainer_;
  AutofillDialogWindowController* target_;

  // Weak. Owns the dialog.
  autofill::AutofillDialogViewDelegate* delegate_;
}

@property(assign, nonatomic) AutofillDialogWindowController* target;

// Designated initializer.
- (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate;

// Returns the preferred size for the footer and notifications at the specfied
// |width|.
- (NSSize)decorationSizeForWidth:(CGFloat)width;

// Returns the view delegate responsible for |section|.
- (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section;

// Called when the delegate-maintained suggestions model has changed.
- (void)modelChanged;

// Get status of "Save in Chrome" checkbox.
- (BOOL)saveDetailsLocally;

// Called when there are changes to the notification area.
- (void)updateNotificationArea;

// Called when the error bubble needs to be updated.
- (void)updateErrorBubble;

// Validates form input data.
- (BOOL)validate;

// Updates status of "save in Chrome" checkbox.
- (void)updateSaveInChrome;

// Makes the first invalid input first responder.
- (void)makeFirstInvalidInputFirstResponder;

// Called when the main container becomes visible. Ensures the right input field
// becomes first responder, and positions the scrollview correctly. This MUST be
// called after layout on the main container is complete, since it depends on
// the size of the contained views to be correct.
- (void)scrollInitialEditorIntoViewAndMakeFirstResponder;

@end


// AutofillMainContainer helper functions, for testing purposes only.
@interface AutofillMainContainer (Testing)

@property(readonly, nonatomic) NSButton* saveInChromeCheckboxForTesting;
@property(readonly, nonatomic) NSImageView* saveInChromeTooltipForTesting;

@end

#endif  // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_MAIN_CONTAINER_H_