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