| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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_AUTOFILL_AUTOFILL_CREDIT_CARD_SHEET_CONTROLLER_MAC_ | |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_SHEET_CONTROLLER_MAC_ | |
| 7 #pragma once | |
| 8 | |
| 9 #import <Cocoa/Cocoa.h> | |
| 10 #include <vector> | |
| 11 | |
| 12 @class AutoFillCreditCardModel; | |
| 13 @class AutoFillDialogController; | |
| 14 class CreditCard; | |
| 15 | |
| 16 // The sheet can be invoked in "Add" or "Edit" mode. This dictates the caption | |
| 17 // seen at the top of the sheet. | |
| 18 enum { | |
| 19 kAutoFillCreditCardAddMode = 0, | |
| 20 kAutoFillCreditCardEditMode = 1 | |
| 21 }; | |
| 22 typedef NSInteger AutoFillCreditCardMode; | |
| 23 | |
| 24 // A class that coordinates the |creditCardModel| and the associated view | |
| 25 // held in AutoFillCreditCardSheet.xib. | |
| 26 // |initWithCreditCard:| is the designated initializer. It takes |creditCard| | |
| 27 // and transcribes it to |creditCardModel| to which the view is bound. | |
| 28 @interface AutoFillCreditCardSheetController : NSWindowController { | |
| 29 @private | |
| 30 IBOutlet NSPopUpButton* expirationMonthPopup_; | |
| 31 IBOutlet NSPopUpButton* expirationYearPopup_; | |
| 32 | |
| 33 // The caption at top of dialog. Text changes according to usage. Either | |
| 34 // "New credit card" or "Edit credit card" depending on context. | |
| 35 IBOutlet NSTextField* caption_; | |
| 36 | |
| 37 // The credit card number field. This is here for unit testing purposes. | |
| 38 // The text of this field is obfuscated until edited. | |
| 39 IBOutlet NSTextField* creditCardNumberField_; | |
| 40 | |
| 41 // The primary model for this controller. The model is instantiated | |
| 42 // from within |initWithCreditCard:|. We do not hold it as a scoped_nsobject | |
| 43 // because it is exposed as a KVO compliant property. | |
| 44 AutoFillCreditCardModel* creditCardModel_; | |
| 45 | |
| 46 // Contents of the expiration month and year popups. Strongly owned. We do | |
| 47 // not hold them as scoped_nsobjects because they are exposed as KVO compliant | |
| 48 // properties. | |
| 49 NSArray* expirationMonthContents_; | |
| 50 NSArray* expirationYearContents_; | |
| 51 | |
| 52 // Either "Add" or "Edit" mode of sheet. | |
| 53 AutoFillCreditCardMode mode_; | |
| 54 } | |
| 55 | |
| 56 @property(nonatomic, retain) AutoFillCreditCardModel* creditCardModel; | |
| 57 @property(nonatomic, retain) NSArray* expirationMonthContents; | |
| 58 @property(nonatomic, retain) NSArray* expirationYearContents; | |
| 59 | |
| 60 // Designated initializer. Takes a copy of the data in |creditCard|, | |
| 61 // it is not held as a reference. | |
| 62 - (id)initWithCreditCard:(const CreditCard&)creditCard | |
| 63 mode:(AutoFillCreditCardMode)mode; | |
| 64 | |
| 65 // IBActions for save and cancel buttons. Both invoke |endSheet:|. | |
| 66 - (IBAction)save:(id)sender; | |
| 67 - (IBAction)cancel:(id)sender; | |
| 68 | |
| 69 // Copy data from internal model to |creditCard|. | |
| 70 - (void)copyModelToCreditCard:(CreditCard*)creditCard; | |
| 71 | |
| 72 @end | |
| 73 | |
| 74 // Interface exposed for unit testing. | |
| 75 @interface AutoFillCreditCardSheetController (ExposedForUnitTests) | |
| 76 - (NSTextField*)creditCardNumberField; | |
| 77 @end | |
| 78 | |
| 79 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_SHEET_CONTROLLER_MAC_ | |
| OLD | NEW |