Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ | |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/string16.h" | |
| 10 #include "chrome/browser/autofill/field_types.h" | |
| 11 #include "chrome/browser/autofill/wallet/wallet_items.h" | |
| 12 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | |
| 13 | |
| 14 class CreditCard; | |
| 15 class FormGroup; | |
| 16 class FormStructure; | |
| 17 | |
| 18 namespace gfx { | |
| 19 class Image; | |
| 20 } | |
| 21 | |
| 22 namespace wallet { | |
| 23 class Address; | |
| 24 } | |
| 25 | |
| 26 namespace autofill { | |
| 27 | |
| 28 // A glue class that allows uniform interactions with autocomplete data sources, | |
| 29 // regardless of their type. Implementations are intended to be lightweight and | |
| 30 // copyable, only holding weak references to their backing model. | |
| 31 class DataModelWrapper { | |
| 32 public: | |
| 33 virtual ~DataModelWrapper(); | |
| 34 | |
| 35 // Returns the data for a specific autocomplete type. | |
| 36 virtual string16 GetInfo(AutofillFieldType type) = 0; | |
| 37 | |
| 38 // Returns the icon, if any, that represents this model. | |
| 39 virtual gfx::Image GetIcon() = 0; | |
| 40 | |
| 41 // Fills in |inputs| with the data that this model contains (|inputs| is an | |
| 42 // out-param). | |
| 43 virtual void FillInputs(DetailInputs* inputs) = 0; | |
| 44 | |
| 45 // Fills in |form_structure| with the data that this model contains. |inputs| | |
| 46 // and |comparator| are used to determine whether each field in the | |
| 47 // FormStructure should be filled in or left alone. | |
| 48 virtual void FillFormStructure( | |
| 49 const DetailInputs& inputs, | |
| 50 const InputFieldComparator& compare, | |
| 51 FormStructure* form_structure) = 0; | |
| 52 | |
| 53 // Returns text to display to the user to summarize this data source. The | |
| 54 // default implementation assumes this is an address. | |
| 55 virtual string16 GetDisplayText(); | |
| 56 }; | |
| 57 | |
| 58 // A DataModelWrapper for Autofill data. | |
| 59 class AutofillDataModelWrapper : public DataModelWrapper { | |
| 60 public: | |
| 61 AutofillDataModelWrapper(const FormGroup* form_group, size_t variant); | |
| 62 virtual ~AutofillDataModelWrapper(); | |
| 63 | |
| 64 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; | |
| 65 virtual gfx::Image GetIcon() OVERRIDE; | |
| 66 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; | |
| 67 virtual void FillFormStructure( | |
| 68 const DetailInputs& inputs, | |
| 69 const InputFieldComparator& compare, | |
| 70 FormStructure* form_structure) OVERRIDE; | |
| 71 | |
| 72 private: | |
| 73 const FormGroup* form_group_; | |
| 74 const size_t variant_; | |
| 75 }; | |
| 76 | |
| 77 // A DataModelWrapper specifically for Autofill CreditCard data. | |
| 78 class AutofillCreditCardWrapper : public AutofillDataModelWrapper { | |
| 79 public: | |
| 80 explicit AutofillCreditCardWrapper(const CreditCard* card); | |
| 81 virtual ~AutofillCreditCardWrapper(); | |
| 82 | |
| 83 virtual gfx::Image GetIcon() OVERRIDE; | |
| 84 virtual string16 GetDisplayText() OVERRIDE; | |
| 85 | |
| 86 private: | |
| 87 const CreditCard* card_; | |
| 88 }; | |
| 89 | |
| 90 // A DataModelWrapper for Wallet instruments. | |
| 91 class WalletInstrumentWrapper : public DataModelWrapper { | |
|
Ilya Sherman
2013/02/12 22:50:34
Optional nit: IMO it would be better to order this
Evan Stade
2013/02/13 00:11:58
Done.
| |
| 92 public: | |
| 93 explicit WalletInstrumentWrapper( | |
| 94 const wallet::WalletItems::MaskedInstrument* instrument); | |
| 95 virtual ~WalletInstrumentWrapper(); | |
| 96 | |
| 97 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; | |
| 98 virtual gfx::Image GetIcon() OVERRIDE; | |
| 99 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; | |
| 100 virtual void FillFormStructure( | |
| 101 const DetailInputs& inputs, | |
| 102 const InputFieldComparator& compare, | |
| 103 FormStructure* form_structure) OVERRIDE; | |
| 104 | |
| 105 private: | |
| 106 const wallet::WalletItems::MaskedInstrument* instrument_; | |
| 107 }; | |
| 108 | |
| 109 // A DataModelWrapper for Wallet addresses. | |
| 110 class WalletAddressWrapper : public DataModelWrapper { | |
| 111 public: | |
| 112 explicit WalletAddressWrapper(const wallet::Address* address); | |
| 113 virtual ~WalletAddressWrapper(); | |
| 114 | |
| 115 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; | |
| 116 virtual gfx::Image GetIcon() OVERRIDE; | |
| 117 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; | |
| 118 virtual void FillFormStructure( | |
| 119 const DetailInputs& inputs, | |
| 120 const InputFieldComparator& compare, | |
| 121 FormStructure* form_structure) OVERRIDE; | |
| 122 | |
| 123 private: | |
| 124 const wallet::Address* address_; | |
| 125 }; | |
| 126 | |
| 127 } | |
| 128 | |
| 129 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ | |
| OLD | NEW |