blob: 35f90407a99abcf809e72c7f153e4c30b5d04f1e (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
// Copyright (c) 2012 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_AUTOFILL_DATA_MODEL_WRAPPER_H_
#define CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
#include "base/compiler_specific.h"
#include "base/string16.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "components/autofill/browser/field_types.h"
#include "components/autofill/browser/wallet/wallet_items.h"
class AutofillProfile;
class CreditCard;
class FormGroup;
class FormStructure;
namespace gfx {
class Image;
}
namespace autofill {
namespace wallet {
class Address;
class FullWallet;
}
// A glue class that allows uniform interactions with autocomplete data sources,
// regardless of their type. Implementations are intended to be lightweight and
// copyable, only holding weak references to their backing model.
class DataModelWrapper {
public:
virtual ~DataModelWrapper();
// Returns the data for a specific autocomplete type.
virtual string16 GetInfo(AutofillFieldType type) = 0;
// Returns the icon, if any, that represents this model.
virtual gfx::Image GetIcon();
// Fills in |inputs| with the data that this model contains (|inputs| is an
// out-param).
virtual void FillInputs(DetailInputs* inputs);
// Returns text to display to the user to summarize this data source. The
// default implementation assumes this is an address.
virtual string16 GetDisplayText();
// Fills in |form_structure| with the data that this model contains. |inputs|
// and |comparator| are used to determine whether each field in the
// FormStructure should be filled in or left alone.
void FillFormStructure(
const DetailInputs& inputs,
const InputFieldComparator& compare,
FormStructure* form_structure);
protected:
// Fills in |field| with data from the model.
virtual void FillFormField(AutofillField* field);
};
// A DataModelWrapper for Autofill data.
class AutofillFormGroupWrapper : public DataModelWrapper {
public:
AutofillFormGroupWrapper(const FormGroup* form_group, size_t variant);
virtual ~AutofillFormGroupWrapper();
virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
protected:
virtual void FillFormField(AutofillField* field) OVERRIDE;
size_t variant() const { return variant_; }
private:
const FormGroup* form_group_;
const size_t variant_;
};
// A DataModelWrapper for Autofill profiles.
class AutofillProfileWrapper : public AutofillFormGroupWrapper {
public:
AutofillProfileWrapper(const AutofillProfile* profile, size_t variant);
virtual ~AutofillProfileWrapper();
virtual void FillInputs(DetailInputs* inputs) OVERRIDE;
private:
const AutofillProfile* profile_;
};
// A DataModelWrapper specifically for Autofill CreditCard data.
class AutofillCreditCardWrapper : public AutofillFormGroupWrapper {
public:
explicit AutofillCreditCardWrapper(const CreditCard* card);
virtual ~AutofillCreditCardWrapper();
virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
virtual gfx::Image GetIcon() OVERRIDE;
virtual string16 GetDisplayText() OVERRIDE;
protected:
virtual void FillFormField(AutofillField* field) OVERRIDE;
private:
const CreditCard* card_;
};
// A DataModelWrapper for Wallet addresses.
class WalletAddressWrapper : public DataModelWrapper {
public:
explicit WalletAddressWrapper(const wallet::Address* address);
virtual ~WalletAddressWrapper();
virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
private:
const wallet::Address* address_;
};
// A DataModelWrapper for Wallet instruments.
class WalletInstrumentWrapper : public DataModelWrapper {
public:
explicit WalletInstrumentWrapper(
const wallet::WalletItems::MaskedInstrument* instrument);
virtual ~WalletInstrumentWrapper();
virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
virtual gfx::Image GetIcon() OVERRIDE;
virtual string16 GetDisplayText() OVERRIDE;
private:
const wallet::WalletItems::MaskedInstrument* instrument_;
};
// A DataModelWrapper for FullWallets billing data.
class FullWalletBillingWrapper : public DataModelWrapper {
public:
explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet);
virtual ~FullWalletBillingWrapper();
virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
private:
wallet::FullWallet* full_wallet_;
};
// A DataModelWrapper for FullWallets shipping data.
class FullWalletShippingWrapper : public DataModelWrapper {
public:
explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet);
virtual ~FullWalletShippingWrapper();
virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
private:
wallet::FullWallet* full_wallet_;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
|