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

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();
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,
55 const InputFieldComparator& compare, 56 const InputFieldComparator& compare,
56 FormStructure* form_structure); 57 FormStructure* form_structure);
57 58
58 protected: 59 protected:
59 // Fills in |field| with data from the model. 60 // Fills in |field| with data from the model.
60 virtual void FillFormField(AutofillField* field) = 0; 61 virtual void FillFormField(AutofillField* field);
61 }; 62 };
62 63
63 // A DataModelWrapper for Autofill data. 64 // A DataModelWrapper for Autofill data.
64 class AutofillFormGroupWrapper : public DataModelWrapper { 65 class AutofillFormGroupWrapper : public DataModelWrapper {
65 public: 66 public:
66 AutofillFormGroupWrapper(const FormGroup* form_group, size_t variant); 67 AutofillFormGroupWrapper(const FormGroup* form_group, size_t variant);
67 virtual ~AutofillFormGroupWrapper(); 68 virtual ~AutofillFormGroupWrapper();
68 69
69 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; 70 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
70 virtual gfx::Image GetIcon() OVERRIDE;
71 71
72 protected: 72 protected:
73 virtual void FillFormField(AutofillField* field) OVERRIDE; 73 virtual void FillFormField(AutofillField* field) OVERRIDE;
74 74
75 size_t variant() const { return variant_; } 75 size_t variant() const { return variant_; }
76 76
77 private: 77 private:
78 const FormGroup* form_group_; 78 const FormGroup* form_group_;
79 const size_t variant_; 79 const size_t variant_;
80 }; 80 };
(...skipping 10 matching lines...) Expand all
91 const AutofillProfile* profile_; 91 const AutofillProfile* profile_;
92 }; 92 };
93 93
94 // A DataModelWrapper specifically for Autofill CreditCard data. 94 // A DataModelWrapper specifically for Autofill CreditCard data.
95 class AutofillCreditCardWrapper : public AutofillFormGroupWrapper { 95 class AutofillCreditCardWrapper : public AutofillFormGroupWrapper {
96 public: 96 public:
97 explicit AutofillCreditCardWrapper(const CreditCard* card); 97 explicit AutofillCreditCardWrapper(const CreditCard* card);
98 virtual ~AutofillCreditCardWrapper(); 98 virtual ~AutofillCreditCardWrapper();
99 99
100 virtual gfx::Image GetIcon() OVERRIDE; 100 virtual gfx::Image GetIcon() OVERRIDE;
101 virtual void FillInputs(DetailInputs* inputs) OVERRIDE;
102 virtual string16 GetDisplayText() OVERRIDE; 101 virtual string16 GetDisplayText() OVERRIDE;
103 102
104 protected: 103 protected:
105 virtual void FillFormField(AutofillField* field) OVERRIDE; 104 virtual void FillFormField(AutofillField* field) OVERRIDE;
106 105
107 private: 106 private:
108 const CreditCard* card_; 107 const CreditCard* card_;
109 }; 108 };
110 109
111 // A DataModelWrapper for Wallet addresses. 110 // A DataModelWrapper for Wallet addresses.
112 class WalletAddressWrapper : public DataModelWrapper { 111 class WalletAddressWrapper : public DataModelWrapper {
113 public: 112 public:
114 explicit WalletAddressWrapper(const wallet::Address* address); 113 explicit WalletAddressWrapper(const wallet::Address* address);
115 virtual ~WalletAddressWrapper(); 114 virtual ~WalletAddressWrapper();
116 115
117 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; 116 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
118 virtual gfx::Image GetIcon() OVERRIDE;
119 virtual void FillInputs(DetailInputs* inputs) OVERRIDE;
120
121 protected:
122 virtual void FillFormField(AutofillField* field) OVERRIDE;
123 117
124 private: 118 private:
125 const wallet::Address* address_; 119 const wallet::Address* address_;
126 }; 120 };
127 121
128 // A DataModelWrapper for Wallet instruments. 122 // A DataModelWrapper for Wallet instruments.
129 class WalletInstrumentWrapper : public DataModelWrapper { 123 class WalletInstrumentWrapper : public DataModelWrapper {
130 public: 124 public:
131 explicit WalletInstrumentWrapper( 125 explicit WalletInstrumentWrapper(
132 const wallet::WalletItems::MaskedInstrument* instrument); 126 const wallet::WalletItems::MaskedInstrument* instrument);
133 virtual ~WalletInstrumentWrapper(); 127 virtual ~WalletInstrumentWrapper();
134 128
135 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; 129 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
136 virtual gfx::Image GetIcon() OVERRIDE; 130 virtual gfx::Image GetIcon() OVERRIDE;
137 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; 131 virtual void FillInputs(DetailInputs* inputs) OVERRIDE;
138 virtual string16 GetDisplayText() OVERRIDE; 132 virtual string16 GetDisplayText() OVERRIDE;
139 133
140 protected:
141 virtual void FillFormField(AutofillField* field) OVERRIDE;
142
143 private: 134 private:
144 const wallet::WalletItems::MaskedInstrument* instrument_; 135 const wallet::WalletItems::MaskedInstrument* instrument_;
145 }; 136 };
146 137
147 } 138 // A DataModelWrapper for FullWallets billing data.
139 class FullWalletBillingWrapper : public DataModelWrapper {
140 public:
141 explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet);
142 virtual ~FullWalletBillingWrapper();
143
144 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
145
146 private:
147 wallet::FullWallet* full_wallet_;
148 };
149
150 // A DataModelWrapper for FullWallets shipping data.
151 class FullWalletShippingWrapper : public DataModelWrapper {
152 public:
153 explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet);
154 virtual ~FullWalletShippingWrapper();
155
156 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE;
157
158 private:
159 wallet::FullWallet* full_wallet_;
160 };
161
162 } // namespace autofill
148 163
149 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ 164 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc ('k') | chrome/browser/ui/autofill/data_model_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698