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_MAIN_CONTAINER_H_ 6#define CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_MAIN_CONTAINER_H_ 7 8#import <Cocoa/Cocoa.h> 9 10#include "base/mac/scoped_nsobject.h" 11#include "chrome/browser/ui/autofill/autofill_dialog_types.h" 12#import "chrome/browser/ui/cocoa/autofill/autofill_layout.h" 13 14@class AutofillDetailsContainer; 15@class AutofillDialogWindowController; 16@class AutofillNotificationContainer; 17@class AutofillSectionContainer; 18@class AutofillTooltipController; 19@class GTMWidthBasedTweaker; 20@class HyperlinkTextView; 21 22namespace autofill { 23 class AutofillDialogViewDelegate; 24} 25 26// NSViewController for the main portion of the autofill dialog. Contains 27// account chooser, details for current payment instruments, OK/Cancel. 28// Might dynamically add and remove other elements. 29@interface AutofillMainContainer : NSViewController<AutofillLayout, 30 NSTextViewDelegate> { 31 @private 32 base::scoped_nsobject<GTMWidthBasedTweaker> buttonContainer_; 33 base::scoped_nsobject<NSImageView> buttonStripImage_; 34 base::scoped_nsobject<NSButton> saveInChromeCheckbox_; 35 base::scoped_nsobject<AutofillTooltipController> saveInChromeTooltip_; 36 base::scoped_nsobject<AutofillDetailsContainer> detailsContainer_; 37 base::scoped_nsobject<HyperlinkTextView> legalDocumentsView_; 38 base::scoped_nsobject<AutofillNotificationContainer> notificationContainer_; 39 AutofillDialogWindowController* target_; 40 41 // Weak. Owns the dialog. 42 autofill::AutofillDialogViewDelegate* delegate_; 43 44 // Preferred size for legal documents. 45 NSSize legalDocumentsSize_; 46 47 // Dirty marker for preferred size. 48 BOOL legalDocumentsSizeDirty_; 49} 50 51@property(assign, nonatomic) AutofillDialogWindowController* target; 52 53// Designated initializer. 54- (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate; 55 56// Returns the preferred size for the footer and notifications at the specfied 57// |width|. 58- (NSSize)decorationSizeForWidth:(CGFloat)width; 59 60// Sets the anchor point for the notificationView_. 61- (void)setAnchorView:(NSView*)anchorView; 62 63// Returns the view delegate responsible for |section|. 64- (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section; 65 66// Called when the delegate-maintained suggestions model has changed. 67- (void)modelChanged; 68 69// Get status of "Save in Chrome" checkbox. 70- (BOOL)saveDetailsLocally; 71 72// Called when the legal documents text might need to be refreshed. 73- (void)updateLegalDocuments; 74 75// Called when there are changes to the notification area. 76- (void)updateNotificationArea; 77 78// Called when the error bubble needs to be updated. 79- (void)updateErrorBubble; 80 81// Validates form input data. 82- (BOOL)validate; 83 84// Updates status of "save in Chrome" checkbox. 85- (void)updateSaveInChrome; 86 87// Makes the first invalid input first responder. 88- (void)makeFirstInvalidInputFirstResponder; 89 90// Called when the main container becomes visible. Ensures the right input field 91// becomes first responder, and positions the scrollview correctly. This MUST be 92// called after layout on the main container is complete, since it depends on 93// the size of the contained views to be correct. 94- (void)scrollInitialEditorIntoViewAndMakeFirstResponder; 95 96@end 97 98 99// AutofillMainContainer helper functions, for testing purposes only. 100@interface AutofillMainContainer (Testing) 101 102@property(readonly, nonatomic) NSButton* saveInChromeCheckboxForTesting; 103@property(readonly, nonatomic) NSImageView* buttonStripImageForTesting; 104@property(readonly, nonatomic) NSImageView* saveInChromeTooltipForTesting; 105 106@end 107 108#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_MAIN_CONTAINER_H_ 109