Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/ui/autofill/data_model_wrapper.h

Issue 12815002: requestAutocomplete: Fill |form_structure_| from Online Wallet data (including (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
11 #include "components/autofill/browser/field_types.h" 11 #include "components/autofill/browser/field_types.h"
12 #include "components/autofill/browser/wallet/wallet_items.h" 12 #include "components/autofill/browser/wallet/wallet_items.h"
13 13
14 class AutofillProfile; 14 class AutofillProfile;
15 class CreditCard; 15 class CreditCard;
16 class FormGroup; 16 class FormGroup;
17 class FormStructure; 17 class FormStructure;
18 18
19 namespace gfx { 19 namespace gfx {
20 class Image; 20 class Image;
21 } 21 }
22 22
23 namespace wallet {
24 class Address;
25 }
26
27 namespace autofill { 23 namespace autofill {
28 24
25 namespace wallet {
26 class Address;
27 class FullWallet;
28 }
29
29 // A glue class that allows uniform interactions with autocomplete data sources, 30 // A glue class that allows uniform interactions with autocomplete data sources,
30 // regardless of their type. Implementations are intended to be lightweight and 31 // regardless of their type. Implementations are intended to be lightweight and
31 // copyable, only holding weak references to their backing model. 32 // copyable, only holding weak references to their backing model.
32 class DataModelWrapper { 33 class DataModelWrapper {
33 public: 34 public:
34 virtual ~DataModelWrapper(); 35 virtual ~DataModelWrapper();
35 36
36 // Returns the data for a specific autocomplete type. 37 // Returns the data for a specific autocomplete type.
37 virtual string16 GetInfo(AutofillFieldType type) = 0; 38 virtual string16 GetInfo(AutofillFieldType type) = 0;
38 39
39 // Returns the icon, if any, that represents this model. 40 // Returns the icon, if any, that represents this model.
40 virtual gfx::Image GetIcon() = 0; 41 virtual gfx::Image GetIcon() = 0;
41 42
42 // Fills in |inputs| with the data that this model contains (|inputs| is an 43 // Fills in |inputs| with the data that this model contains (|inputs| is an
43 // out-param). 44 // out-param).
44 virtual void FillInputs(DetailInputs* inputs) = 0; 45 virtual void FillInputs(DetailInputs* inputs);
45 46
46 // Returns text to display to the user to summarize this data source. The 47 // Returns text to display to the user to summarize this data source. The
47 // default implementation assumes this is an address. 48 // default implementation assumes this is an address.
48 virtual string16 GetDisplayText(); 49 virtual string16 GetDisplayText();
49 50
50 // Fills in |form_structure| with the data that this model contains. |inputs| 51 // Fills in |form_structure| with the data that this model contains. |inputs|
51 // and |comparator| are used to determine whether each field in the 52 // and |comparator| are used to determine whether each field in the
52 // FormStructure should be filled in or left alone. 53 // FormStructure should be filled in or left alone.
53 void FillFormStructure( 54 void FillFormStructure(
54 const DetailInputs& inputs, 55 const DetailInputs& inputs,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 }; 110 };
110 111
111 // A DataModelWrapper for Wallet addresses. 112 // A DataModelWrapper for Wallet addresses.
112 class WalletAddressWrapper : public DataModelWrapper { 113 class WalletAddressWrapper : public DataModelWrapper {
113 public: 114 public:
114 explicit WalletAddressWrapper(const wallet::Address* address); 115 explicit WalletAddressWrapper(const wallet::Address* address);
115 virtual ~WalletAddressWrapper(); 116 virtual ~WalletAddressWrapper();
116 117
117 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; 118 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
118 virtual gfx::Image GetIcon() OVERRIDE; 119 virtual gfx::Image GetIcon() OVERRIDE;
119 virtual void FillInputs(DetailInputs* inputs) OVERRIDE;
120 120
121 protected: 121 protected:
122 virtual void FillFormField(AutofillField* field) OVERRIDE; 122 virtual void FillFormField(AutofillField* field) OVERRIDE;
123 123
124 private: 124 private:
125 const wallet::Address* address_; 125 const wallet::Address* address_;
126 }; 126 };
127 127
128 // A DataModelWrapper for Wallet instruments. 128 // A DataModelWrapper for Wallet instruments.
129 class WalletInstrumentWrapper : public DataModelWrapper { 129 class WalletInstrumentWrapper : public DataModelWrapper {
130 public: 130 public:
131 explicit WalletInstrumentWrapper( 131 explicit WalletInstrumentWrapper(
132 const wallet::WalletItems::MaskedInstrument* instrument); 132 const wallet::WalletItems::MaskedInstrument* instrument);
133 virtual ~WalletInstrumentWrapper(); 133 virtual ~WalletInstrumentWrapper();
134 134
135 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; 135 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
136 virtual gfx::Image GetIcon() OVERRIDE; 136 virtual gfx::Image GetIcon() OVERRIDE;
137 virtual void FillInputs(DetailInputs* inputs) OVERRIDE;
138 virtual string16 GetDisplayText() OVERRIDE; 137 virtual string16 GetDisplayText() OVERRIDE;
139 138
140 protected: 139 protected:
141 virtual void FillFormField(AutofillField* field) OVERRIDE; 140 virtual void FillFormField(AutofillField* field) OVERRIDE;
142 141
143 private: 142 private:
144 const wallet::WalletItems::MaskedInstrument* instrument_; 143 const wallet::WalletItems::MaskedInstrument* instrument_;
145 }; 144 };
146 145
147 } 146 // A DataModelWrapper for FullWallets.
147 class FullWalletWrapper : public DataModelWrapper {
148 public:
149 explicit FullWalletWrapper(wallet::FullWallet* full_wallet);
150 virtual ~FullWalletWrapper();
151
152 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
153 virtual gfx::Image GetIcon() OVERRIDE;
154
155 protected:
156 virtual bool IsBillingWrapper() const = 0;
157 virtual void FillFormField(AutofillField* field) OVERRIDE;
158
159 private:
160 wallet::FullWallet* full_wallet_;
161 };
162
163 class FullWalletBillingWrapper : public FullWalletWrapper {
164 public:
165 explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet);
166 virtual ~FullWalletBillingWrapper();
167 virtual bool IsBillingWrapper() const OVERRIDE;
168 };
169
170 class FullWalletShippingWrapper : public FullWalletWrapper {
171 public:
172 explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet);
173 virtual ~FullWalletShippingWrapper();
174 virtual bool IsBillingWrapper() const OVERRIDE;
175 };
176
177 } // namespace autofill
148 178
149 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ 179 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698