summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_credit_card_view_controller_mac.h
blob: c836176404418dadff87c4da666929458d333823 (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
// Copyright (c) 2010 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_AUTOFILL_AUTOFILL_CREDIT_CARD_VIEW_CONTROLLER_MAC_
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_VIEW_CONTROLLER_MAC_

#import <Cocoa/Cocoa.h>
#import "chrome/browser/cocoa/disclosure_view_controller.h"

@class AutoFillCreditCardModel;
@class AutoFillDialogController;
class CreditCard;

// A class that coordinates the |creditCardModel| and the associated view
// held in AutoFillCreditCardFormView.xib.
// |initWithCreditCard:| is the designated initializer.  It takes |creditCard|
// and transcribes it to |creditCardModel| to which the view is bound.
@interface AutoFillCreditCardViewController : DisclosureViewController {
 @private
  IBOutlet NSPopUpButton* billingAddressPopup_;
  IBOutlet NSPopUpButton* shippingAddressPopup_;

  // The primary model for this controller.  The model is instantiated
  // from within |initWithCreditCard:|.  We do not hold it as a scoped_nsobject
  // because it is exposed as a KVO compliant property.
  AutoFillCreditCardModel* creditCardModel_;

  // Array of strings that populate the |billingAddressPopup_| control.  We
  // do not hold this as scoped_nsobject because it is exposed as a KVO
  // compliant property.  The values of this array may change as the list
  // of addresses change in the |parentController_|.
  NSArray* billingAddressContents_;

  // Array of strings that populate the |shippingAddressPopup_| control.  We
  // do not hold this as scoped_nsobject because it is exposed as a KVO
  // compliant property.  The values of this array may change as the list
  // of addresses change in the |parentController_|.
  NSArray* shippingAddressContents_;

  // A reference to our parent controller.  Used for notifying parent if/when
  // deletion occurs.  May be not be nil.
  // Weak reference, owns us.
  AutoFillDialogController* parentController_;
}

@property (nonatomic, retain) AutoFillCreditCardModel* creditCardModel;
@property (nonatomic, retain) NSArray* billingAddressContents;
@property (nonatomic, retain) NSArray* shippingAddressContents;

// Designated initializer.  Takes a copy of the data in |creditCard|,
// it is not held as a reference.
- (id)initWithCreditCard:(const CreditCard&)creditCard
    disclosure:(NSCellStateValue)disclosureState
    controller:(AutoFillDialogController*)parentController;

// Action to remove this credit card from the dialog.  Forwards the request to
// |parentController_| which does all the actual work.  We have the action
// here so that the delete button in the AutoFillCreditCardViewFormView.xib has
// something to call.
- (IBAction)deleteCreditCard:(id)sender;

// Action to notify observers of the address list when changes have occured.
// For the credit card controller this means rebuild the popup menus.
- (IBAction)onAddressesChanged:(id)sender;

// Copy data from internal model to |creditCard|.
- (void)copyModelToCreditCard:(CreditCard*)creditCard;

@end

#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CREDIT_CARD_VIEW_CONTROLLER_MAC_