| OLD | NEW |
| 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/strings/string16.h" | 9 #include "base/strings/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/content/browser/wallet/wallet_items.h" | 11 #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 12 #include "components/autofill/core/browser/field_types.h" | |
| 13 | 12 |
| 14 namespace gfx { | 13 namespace gfx { |
| 15 class Image; | 14 class Image; |
| 16 } | 15 } |
| 17 | 16 |
| 18 namespace autofill { | 17 namespace autofill { |
| 19 | 18 |
| 20 class AutofillDataModel; | 19 class AutofillDataModel; |
| 21 class AutofillProfile; | 20 class AutofillProfile; |
| 21 class AutofillType; |
| 22 class CreditCard; | 22 class CreditCard; |
| 23 class FormStructure; | 23 class FormStructure; |
| 24 | 24 |
| 25 namespace wallet { | 25 namespace wallet { |
| 26 class Address; | 26 class Address; |
| 27 class FullWallet; | 27 class FullWallet; |
| 28 } | 28 } |
| 29 | 29 |
| 30 // A glue class that allows uniform interactions with autocomplete data sources, | 30 // A glue class that allows uniform interactions with autocomplete data sources, |
| 31 // regardless of their type. Implementations are intended to be lightweight and | 31 // regardless of their type. Implementations are intended to be lightweight and |
| 32 // copyable, only holding weak references to their backing model. | 32 // copyable, only holding weak references to their backing model. |
| 33 class DataModelWrapper { | 33 class DataModelWrapper { |
| 34 public: | 34 public: |
| 35 virtual ~DataModelWrapper(); | 35 virtual ~DataModelWrapper(); |
| 36 | 36 |
| 37 // Returns the data for a specific autocomplete type. | 37 // Returns the data for a specific autocomplete type. |
| 38 virtual string16 GetInfo(AutofillFieldType type) const = 0; | 38 virtual string16 GetInfo(const AutofillType& type) const = 0; |
| 39 | 39 |
| 40 // Returns the icon, if any, that represents this model. | 40 // Returns the icon, if any, that represents this model. |
| 41 virtual gfx::Image GetIcon(); | 41 virtual gfx::Image GetIcon(); |
| 42 | 42 |
| 43 // 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 |
| 44 // out-param). | 44 // out-param). |
| 45 virtual void FillInputs(DetailInputs* inputs); | 45 virtual void FillInputs(DetailInputs* inputs); |
| 46 | 46 |
| 47 // 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 |
| 48 // default implementation assumes this is an address. | 48 // default implementation assumes this is an address. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 67 DISALLOW_COPY_AND_ASSIGN(DataModelWrapper); | 67 DISALLOW_COPY_AND_ASSIGN(DataModelWrapper); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // A DataModelWrapper that does not hold data and does nothing when told to | 70 // A DataModelWrapper that does not hold data and does nothing when told to |
| 71 // fill in a form. | 71 // fill in a form. |
| 72 class EmptyDataModelWrapper : public DataModelWrapper { | 72 class EmptyDataModelWrapper : public DataModelWrapper { |
| 73 public: | 73 public: |
| 74 EmptyDataModelWrapper(); | 74 EmptyDataModelWrapper(); |
| 75 virtual ~EmptyDataModelWrapper(); | 75 virtual ~EmptyDataModelWrapper(); |
| 76 | 76 |
| 77 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 77 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 virtual void FillFormField(AutofillField* field) const OVERRIDE; | 80 virtual void FillFormField(AutofillField* field) const OVERRIDE; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(EmptyDataModelWrapper); | 82 DISALLOW_COPY_AND_ASSIGN(EmptyDataModelWrapper); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // A DataModelWrapper for Autofill data. | 85 // A DataModelWrapper for Autofill data. |
| 86 class AutofillDataModelWrapper : public DataModelWrapper { | 86 class AutofillDataModelWrapper : public DataModelWrapper { |
| 87 public: | 87 public: |
| 88 AutofillDataModelWrapper(const AutofillDataModel* data_model, size_t variant); | 88 AutofillDataModelWrapper(const AutofillDataModel* data_model, size_t variant); |
| 89 virtual ~AutofillDataModelWrapper(); | 89 virtual ~AutofillDataModelWrapper(); |
| 90 | 90 |
| 91 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 91 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 92 | 92 |
| 93 protected: | 93 protected: |
| 94 virtual void FillFormField(AutofillField* field) const OVERRIDE; | 94 virtual void FillFormField(AutofillField* field) const OVERRIDE; |
| 95 | 95 |
| 96 size_t variant() const { return variant_; } | 96 size_t variant() const { return variant_; } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 const AutofillDataModel* data_model_; | 99 const AutofillDataModel* data_model_; |
| 100 const size_t variant_; | 100 const size_t variant_; |
| 101 | 101 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(AutofillProfileWrapper); | 118 DISALLOW_COPY_AND_ASSIGN(AutofillProfileWrapper); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // A DataModelWrapper specifically for Autofill CreditCard data. | 121 // A DataModelWrapper specifically for Autofill CreditCard data. |
| 122 class AutofillCreditCardWrapper : public AutofillDataModelWrapper { | 122 class AutofillCreditCardWrapper : public AutofillDataModelWrapper { |
| 123 public: | 123 public: |
| 124 explicit AutofillCreditCardWrapper(const CreditCard* card); | 124 explicit AutofillCreditCardWrapper(const CreditCard* card); |
| 125 virtual ~AutofillCreditCardWrapper(); | 125 virtual ~AutofillCreditCardWrapper(); |
| 126 | 126 |
| 127 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 127 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 128 virtual gfx::Image GetIcon() OVERRIDE; | 128 virtual gfx::Image GetIcon() OVERRIDE; |
| 129 virtual string16 GetDisplayText() OVERRIDE; | 129 virtual string16 GetDisplayText() OVERRIDE; |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 const CreditCard* card_; | 132 const CreditCard* card_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(AutofillCreditCardWrapper); | 134 DISALLOW_COPY_AND_ASSIGN(AutofillCreditCardWrapper); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 // A DataModelWrapper for Wallet addresses. | 137 // A DataModelWrapper for Wallet addresses. |
| 138 class WalletAddressWrapper : public DataModelWrapper { | 138 class WalletAddressWrapper : public DataModelWrapper { |
| 139 public: | 139 public: |
| 140 explicit WalletAddressWrapper(const wallet::Address* address); | 140 explicit WalletAddressWrapper(const wallet::Address* address); |
| 141 virtual ~WalletAddressWrapper(); | 141 virtual ~WalletAddressWrapper(); |
| 142 | 142 |
| 143 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 143 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 144 virtual string16 GetDisplayText() OVERRIDE; | 144 virtual string16 GetDisplayText() OVERRIDE; |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 const wallet::Address* address_; | 147 const wallet::Address* address_; |
| 148 | 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(WalletAddressWrapper); | 149 DISALLOW_COPY_AND_ASSIGN(WalletAddressWrapper); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 // A DataModelWrapper for Wallet instruments. | 152 // A DataModelWrapper for Wallet instruments. |
| 153 class WalletInstrumentWrapper : public DataModelWrapper { | 153 class WalletInstrumentWrapper : public DataModelWrapper { |
| 154 public: | 154 public: |
| 155 explicit WalletInstrumentWrapper( | 155 explicit WalletInstrumentWrapper( |
| 156 const wallet::WalletItems::MaskedInstrument* instrument); | 156 const wallet::WalletItems::MaskedInstrument* instrument); |
| 157 virtual ~WalletInstrumentWrapper(); | 157 virtual ~WalletInstrumentWrapper(); |
| 158 | 158 |
| 159 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 159 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 160 virtual gfx::Image GetIcon() OVERRIDE; | 160 virtual gfx::Image GetIcon() OVERRIDE; |
| 161 virtual string16 GetDisplayText() OVERRIDE; | 161 virtual string16 GetDisplayText() OVERRIDE; |
| 162 | 162 |
| 163 private: | 163 private: |
| 164 const wallet::WalletItems::MaskedInstrument* instrument_; | 164 const wallet::WalletItems::MaskedInstrument* instrument_; |
| 165 | 165 |
| 166 DISALLOW_COPY_AND_ASSIGN(WalletInstrumentWrapper); | 166 DISALLOW_COPY_AND_ASSIGN(WalletInstrumentWrapper); |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 // A DataModelWrapper for FullWallet billing data. | 169 // A DataModelWrapper for FullWallet billing data. |
| 170 class FullWalletBillingWrapper : public DataModelWrapper { | 170 class FullWalletBillingWrapper : public DataModelWrapper { |
| 171 public: | 171 public: |
| 172 explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet); | 172 explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet); |
| 173 virtual ~FullWalletBillingWrapper(); | 173 virtual ~FullWalletBillingWrapper(); |
| 174 | 174 |
| 175 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 175 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 176 virtual string16 GetDisplayText() OVERRIDE; | 176 virtual string16 GetDisplayText() OVERRIDE; |
| 177 | 177 |
| 178 private: | 178 private: |
| 179 wallet::FullWallet* full_wallet_; | 179 wallet::FullWallet* full_wallet_; |
| 180 | 180 |
| 181 DISALLOW_COPY_AND_ASSIGN(FullWalletBillingWrapper); | 181 DISALLOW_COPY_AND_ASSIGN(FullWalletBillingWrapper); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 // A DataModelWrapper for FullWallet shipping data. | 184 // A DataModelWrapper for FullWallet shipping data. |
| 185 class FullWalletShippingWrapper : public DataModelWrapper { | 185 class FullWalletShippingWrapper : public DataModelWrapper { |
| 186 public: | 186 public: |
| 187 explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet); | 187 explicit FullWalletShippingWrapper(wallet::FullWallet* full_wallet); |
| 188 virtual ~FullWalletShippingWrapper(); | 188 virtual ~FullWalletShippingWrapper(); |
| 189 | 189 |
| 190 virtual string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 190 virtual string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 191 | 191 |
| 192 private: | 192 private: |
| 193 wallet::FullWallet* full_wallet_; | 193 wallet::FullWallet* full_wallet_; |
| 194 | 194 |
| 195 DISALLOW_COPY_AND_ASSIGN(FullWalletShippingWrapper); | 195 DISALLOW_COPY_AND_ASSIGN(FullWalletShippingWrapper); |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 // A DataModelWrapper to copy the output of one section to the input of another. | 198 // A DataModelWrapper to copy the output of one section to the input of another. |
| 199 class DetailOutputWrapper : public DataModelWrapper { | 199 class DetailOutputWrapper : public DataModelWrapper { |
| 200 public: | 200 public: |
| 201 explicit DetailOutputWrapper(const DetailOutputMap& outputs); | 201 explicit DetailOutputWrapper(const DetailOutputMap& outputs); |
| 202 virtual ~DetailOutputWrapper(); | 202 virtual ~DetailOutputWrapper(); |
| 203 | 203 |
| 204 virtual base::string16 GetInfo(AutofillFieldType type) const OVERRIDE; | 204 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 const DetailOutputMap& outputs_; | 207 const DetailOutputMap& outputs_; |
| 208 | 208 |
| 209 DISALLOW_COPY_AND_ASSIGN(DetailOutputWrapper); | 209 DISALLOW_COPY_AND_ASSIGN(DetailOutputWrapper); |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 } // namespace autofill | 212 } // namespace autofill |
| 213 | 213 |
| 214 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ | 214 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ |
| OLD | NEW |