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 // An interface 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 |
| 54 // A DataModelWrapper for Autofill data. |
| 55 class AutofillDataModelWrapper : public DataModelWrapper { |
| 56 public: |
| 57 AutofillDataModelWrapper(const FormGroup* form_group, size_t variant); |
| 58 virtual ~AutofillDataModelWrapper(); |
| 59 |
| 60 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; |
| 61 virtual gfx::Image GetIcon() OVERRIDE; |
| 62 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; |
| 63 virtual void FillFormStructure( |
| 64 const DetailInputs& inputs, |
| 65 const InputFieldComparator& compare, |
| 66 FormStructure* form_structure) OVERRIDE; |
| 67 |
| 68 private: |
| 69 const FormGroup* form_group_; |
| 70 const size_t variant_; |
| 71 }; |
| 72 |
| 73 // A DataModelWrapper specifically for Autofill CreditCard data. |
| 74 class AutofillCreditCardWrapper : public AutofillDataModelWrapper { |
| 75 public: |
| 76 explicit AutofillCreditCardWrapper(const CreditCard* card); |
| 77 virtual ~AutofillCreditCardWrapper(); |
| 78 |
| 79 virtual gfx::Image GetIcon() OVERRIDE; |
| 80 |
| 81 private: |
| 82 const CreditCard* card_; |
| 83 }; |
| 84 |
| 85 // A DataModelWrapper for Wallet instruments. |
| 86 class WalletInstrumentWrapper : public DataModelWrapper { |
| 87 public: |
| 88 explicit WalletInstrumentWrapper( |
| 89 const wallet::WalletItems::MaskedInstrument* instrument); |
| 90 virtual ~WalletInstrumentWrapper(); |
| 91 |
| 92 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; |
| 93 virtual gfx::Image GetIcon() OVERRIDE; |
| 94 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; |
| 95 virtual void FillFormStructure( |
| 96 const DetailInputs& inputs, |
| 97 const InputFieldComparator& compare, |
| 98 FormStructure* form_structure) OVERRIDE; |
| 99 |
| 100 private: |
| 101 const wallet::WalletItems::MaskedInstrument* instrument_; |
| 102 }; |
| 103 |
| 104 // A DataModelWrapper for Wallet addresses. |
| 105 class WalletAddressWrapper : public DataModelWrapper { |
| 106 public: |
| 107 explicit WalletAddressWrapper(const wallet::Address* address); |
| 108 virtual ~WalletAddressWrapper(); |
| 109 |
| 110 virtual string16 GetInfo(AutofillFieldType type) OVERRIDE; |
| 111 virtual gfx::Image GetIcon() OVERRIDE; |
| 112 virtual void FillInputs(DetailInputs* inputs) OVERRIDE; |
| 113 virtual void FillFormStructure( |
| 114 const DetailInputs& inputs, |
| 115 const InputFieldComparator& compare, |
| 116 FormStructure* form_structure) OVERRIDE; |
| 117 |
| 118 private: |
| 119 const wallet::Address* address_; |
| 120 }; |
| 121 |
| 122 } |
| 123 |
| 124 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ |
OLD | NEW |