| 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 <vector> |
| 9 |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 12 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 11 #include "components/autofill/content/browser/wallet/wallet_items.h" | 13 #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 12 #include "components/autofill/core/browser/field_types.h" | 14 #include "components/autofill/core/browser/field_types.h" |
| 15 #include "components/autofill/core/browser/form_structure.h" |
| 13 | 16 |
| 14 namespace gfx { | 17 namespace gfx { |
| 15 class Image; | 18 class Image; |
| 16 } | 19 } |
| 17 | 20 |
| 18 namespace autofill { | 21 namespace autofill { |
| 19 | 22 |
| 20 class AutofillDataModel; | 23 class AutofillDataModel; |
| 21 class AutofillProfile; | 24 class AutofillProfile; |
| 22 class AutofillType; | 25 class AutofillType; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 // into a web form. | 46 // into a web form. |
| 44 virtual base::string16 GetInfo(const AutofillType& type) const = 0; | 47 virtual base::string16 GetInfo(const AutofillType& type) const = 0; |
| 45 | 48 |
| 46 // Returns the data for a specified type in a format optimized for displaying | 49 // Returns the data for a specified type in a format optimized for displaying |
| 47 // to the user. | 50 // to the user. |
| 48 virtual base::string16 GetInfoForDisplay(const AutofillType& type) const; | 51 virtual base::string16 GetInfoForDisplay(const AutofillType& type) const; |
| 49 | 52 |
| 50 // Returns the icon, if any, that represents this model. | 53 // Returns the icon, if any, that represents this model. |
| 51 virtual gfx::Image GetIcon(); | 54 virtual gfx::Image GetIcon(); |
| 52 | 55 |
| 53 #if !defined(OS_ANDROID) | |
| 54 // Gets text to display to the user to summarize this data source. The | 56 // Gets text to display to the user to summarize this data source. The |
| 55 // default implementation assumes this is an address. Both params are required | 57 // default implementation assumes this is an address. Both params are required |
| 56 // to be non-NULL and will be filled in with text that is vertically compact | 58 // to be non-NULL and will be filled in with text that is vertically compact |
| 57 // (but may take up a lot of horizontal space) and horizontally compact (but | 59 // (but may take up a lot of horizontal space) and horizontally compact (but |
| 58 // may take up a lot of vertical space) respectively. The return value will | 60 // may take up a lot of vertical space) respectively. The return value will |
| 59 // be true and the outparams will be filled in only if the data represented is | 61 // be true and the outparams will be filled in only if the data represented is |
| 60 // complete and valid. | 62 // complete and valid. |
| 61 virtual bool GetDisplayText(base::string16* vertically_compact, | 63 virtual bool GetDisplayText(base::string16* vertically_compact, |
| 62 base::string16* horizontally_compact); | 64 base::string16* horizontally_compact); |
| 63 #endif | |
| 64 | 65 |
| 65 // Fills in |form_structure| with the data that this model contains. |inputs| | 66 // Fills in |form_structure| with the data that this model contains. |inputs| |
| 66 // and |comparator| are used to determine whether each field in the | 67 // and |comparator| are used to determine whether each field in the |
| 67 // FormStructure should be filled in or left alone. Returns whether any fields | 68 // FormStructure should be filled in or left alone. Returns whether any fields |
| 68 // in |form_structure| were found to be matching. | 69 // in |form_structure| were found to be matching. |
| 69 bool FillFormStructure( | 70 bool FillFormStructure( |
| 70 const DetailInputs& inputs, | 71 const std::vector<ServerFieldType>& types, |
| 71 const InputFieldComparator& compare, | 72 const FormStructure::InputFieldComparator& compare, |
| 72 FormStructure* form_structure) const; | 73 FormStructure* form_structure) const; |
| 73 | 74 |
| 74 protected: | 75 protected: |
| 75 DataModelWrapper(); | 76 DataModelWrapper(); |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(DataModelWrapper); | 79 DISALLOW_COPY_AND_ASSIGN(DataModelWrapper); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 // A DataModelWrapper that does not hold data and does nothing when told to | |
| 82 // fill in a form. | |
| 83 class EmptyDataModelWrapper : public DataModelWrapper { | |
| 84 public: | |
| 85 EmptyDataModelWrapper(); | |
| 86 virtual ~EmptyDataModelWrapper(); | |
| 87 | |
| 88 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; | |
| 89 | |
| 90 protected: | |
| 91 DISALLOW_COPY_AND_ASSIGN(EmptyDataModelWrapper); | |
| 92 }; | |
| 93 | |
| 94 // A DataModelWrapper for Autofill profiles. | 82 // A DataModelWrapper for Autofill profiles. |
| 95 class AutofillProfileWrapper : public DataModelWrapper { | 83 class AutofillProfileWrapper : public DataModelWrapper { |
| 96 public: | 84 public: |
| 97 explicit AutofillProfileWrapper(const AutofillProfile* profile); | 85 explicit AutofillProfileWrapper(const AutofillProfile* profile); |
| 98 AutofillProfileWrapper(const AutofillProfile* profile, | 86 AutofillProfileWrapper(const AutofillProfile* profile, |
| 99 const AutofillType& variant_type, | 87 const AutofillType& variant_type, |
| 100 size_t variant); | 88 size_t variant); |
| 101 virtual ~AutofillProfileWrapper(); | 89 virtual ~AutofillProfileWrapper(); |
| 102 | 90 |
| 103 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; | 91 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 133 }; | 121 }; |
| 134 | 122 |
| 135 // A DataModelWrapper specifically for Autofill CreditCard data. | 123 // A DataModelWrapper specifically for Autofill CreditCard data. |
| 136 class AutofillCreditCardWrapper : public DataModelWrapper { | 124 class AutofillCreditCardWrapper : public DataModelWrapper { |
| 137 public: | 125 public: |
| 138 explicit AutofillCreditCardWrapper(const CreditCard* card); | 126 explicit AutofillCreditCardWrapper(const CreditCard* card); |
| 139 virtual ~AutofillCreditCardWrapper(); | 127 virtual ~AutofillCreditCardWrapper(); |
| 140 | 128 |
| 141 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; | 129 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 142 virtual gfx::Image GetIcon() OVERRIDE; | 130 virtual gfx::Image GetIcon() OVERRIDE; |
| 143 #if !defined(OS_ANDROID) | |
| 144 virtual bool GetDisplayText(base::string16* vertically_compact, | 131 virtual bool GetDisplayText(base::string16* vertically_compact, |
| 145 base::string16* horizontally_compact) OVERRIDE; | 132 base::string16* horizontally_compact) OVERRIDE; |
| 146 #endif | |
| 147 | 133 |
| 148 private: | 134 private: |
| 149 const CreditCard* card_; | 135 const CreditCard* card_; |
| 150 | 136 |
| 151 DISALLOW_COPY_AND_ASSIGN(AutofillCreditCardWrapper); | 137 DISALLOW_COPY_AND_ASSIGN(AutofillCreditCardWrapper); |
| 152 }; | 138 }; |
| 153 | 139 |
| 154 // A DataModelWrapper for Wallet addresses. | 140 // A DataModelWrapper for Wallet addresses. |
| 155 class WalletAddressWrapper : public DataModelWrapper { | 141 class WalletAddressWrapper : public DataModelWrapper { |
| 156 public: | 142 public: |
| 157 explicit WalletAddressWrapper(const wallet::Address* address); | 143 explicit WalletAddressWrapper(const wallet::Address* address); |
| 158 virtual ~WalletAddressWrapper(); | 144 virtual ~WalletAddressWrapper(); |
| 159 | 145 |
| 160 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; | 146 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 161 virtual base::string16 GetInfoForDisplay(const AutofillType& type) const | 147 virtual base::string16 GetInfoForDisplay(const AutofillType& type) const |
| 162 OVERRIDE; | 148 OVERRIDE; |
| 163 #if !defined(OS_ANDROID) | |
| 164 virtual bool GetDisplayText(base::string16* vertically_compact, | 149 virtual bool GetDisplayText(base::string16* vertically_compact, |
| 165 base::string16* horizontally_compact) OVERRIDE; | 150 base::string16* horizontally_compact) OVERRIDE; |
| 166 #endif | |
| 167 | 151 |
| 168 private: | 152 private: |
| 169 const wallet::Address* address_; | 153 const wallet::Address* address_; |
| 170 | 154 |
| 171 DISALLOW_COPY_AND_ASSIGN(WalletAddressWrapper); | 155 DISALLOW_COPY_AND_ASSIGN(WalletAddressWrapper); |
| 172 }; | 156 }; |
| 173 | 157 |
| 174 // A DataModelWrapper for Wallet instruments. | 158 // A DataModelWrapper for Wallet instruments. |
| 175 class WalletInstrumentWrapper : public DataModelWrapper { | 159 class WalletInstrumentWrapper : public DataModelWrapper { |
| 176 public: | 160 public: |
| 177 explicit WalletInstrumentWrapper( | 161 explicit WalletInstrumentWrapper( |
| 178 const wallet::WalletItems::MaskedInstrument* instrument); | 162 const wallet::WalletItems::MaskedInstrument* instrument); |
| 179 virtual ~WalletInstrumentWrapper(); | 163 virtual ~WalletInstrumentWrapper(); |
| 180 | 164 |
| 181 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; | 165 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 182 virtual base::string16 GetInfoForDisplay(const AutofillType& type) const | 166 virtual base::string16 GetInfoForDisplay(const AutofillType& type) const |
| 183 OVERRIDE; | 167 OVERRIDE; |
| 184 virtual gfx::Image GetIcon() OVERRIDE; | 168 virtual gfx::Image GetIcon() OVERRIDE; |
| 185 #if !defined(OS_ANDROID) | |
| 186 virtual bool GetDisplayText(base::string16* vertically_compact, | 169 virtual bool GetDisplayText(base::string16* vertically_compact, |
| 187 base::string16* horizontally_compact) OVERRIDE; | 170 base::string16* horizontally_compact) OVERRIDE; |
| 188 #endif | |
| 189 | 171 |
| 190 private: | 172 private: |
| 191 const wallet::WalletItems::MaskedInstrument* instrument_; | 173 const wallet::WalletItems::MaskedInstrument* instrument_; |
| 192 | 174 |
| 193 DISALLOW_COPY_AND_ASSIGN(WalletInstrumentWrapper); | 175 DISALLOW_COPY_AND_ASSIGN(WalletInstrumentWrapper); |
| 194 }; | 176 }; |
| 195 | 177 |
| 196 // A DataModelWrapper for FullWallet billing data. | 178 // A DataModelWrapper for FullWallet billing data. |
| 197 class FullWalletBillingWrapper : public DataModelWrapper { | 179 class FullWalletBillingWrapper : public DataModelWrapper { |
| 198 public: | 180 public: |
| 199 explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet); | 181 explicit FullWalletBillingWrapper(wallet::FullWallet* full_wallet); |
| 200 virtual ~FullWalletBillingWrapper(); | 182 virtual ~FullWalletBillingWrapper(); |
| 201 | 183 |
| 202 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; | 184 virtual base::string16 GetInfo(const AutofillType& type) const OVERRIDE; |
| 203 #if !defined(OS_ANDROID) | |
| 204 virtual bool GetDisplayText(base::string16* vertically_compact, | 185 virtual bool GetDisplayText(base::string16* vertically_compact, |
| 205 base::string16* horizontally_compact) OVERRIDE; | 186 base::string16* horizontally_compact) OVERRIDE; |
| 206 #endif | |
| 207 | 187 |
| 208 private: | 188 private: |
| 209 wallet::FullWallet* full_wallet_; | 189 wallet::FullWallet* full_wallet_; |
| 210 | 190 |
| 211 DISALLOW_COPY_AND_ASSIGN(FullWalletBillingWrapper); | 191 DISALLOW_COPY_AND_ASSIGN(FullWalletBillingWrapper); |
| 212 }; | 192 }; |
| 213 | 193 |
| 214 // A DataModelWrapper for FullWallet shipping data. | 194 // A DataModelWrapper for FullWallet shipping data. |
| 215 class FullWalletShippingWrapper : public DataModelWrapper { | 195 class FullWalletShippingWrapper : public DataModelWrapper { |
| 216 public: | 196 public: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 235 | 215 |
| 236 private: | 216 private: |
| 237 const FieldValueMap& field_map_; | 217 const FieldValueMap& field_map_; |
| 238 | 218 |
| 239 DISALLOW_COPY_AND_ASSIGN(FieldMapWrapper); | 219 DISALLOW_COPY_AND_ASSIGN(FieldMapWrapper); |
| 240 }; | 220 }; |
| 241 | 221 |
| 242 } // namespace autofill | 222 } // namespace autofill |
| 243 | 223 |
| 244 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ | 224 #endif // CHROME_BROWSER_UI_AUTOFILL_DATA_MODEL_WRAPPER_H_ |
| OLD | NEW |