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 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 5 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (!address2.empty()) | 77 if (!address2.empty()) |
78 address += separator + address2; | 78 address += separator + address2; |
79 | 79 |
80 base::string16 comma = ASCIIToUTF16(", "); | 80 base::string16 comma = ASCIIToUTF16(", "); |
81 base::string16 newline = ASCIIToUTF16("\n"); | 81 base::string16 newline = ASCIIToUTF16("\n"); |
82 address += separator + | 82 address += separator + |
83 GetInfo(AutofillType(ADDRESS_HOME_CITY)) + comma + | 83 GetInfo(AutofillType(ADDRESS_HOME_CITY)) + comma + |
84 GetInfo(AutofillType(ADDRESS_HOME_STATE)) + ASCIIToUTF16(" ") + | 84 GetInfo(AutofillType(ADDRESS_HOME_STATE)) + ASCIIToUTF16(" ") + |
85 GetInfo(AutofillType(ADDRESS_HOME_ZIP)); | 85 GetInfo(AutofillType(ADDRESS_HOME_ZIP)); |
86 | 86 |
87 // TODO(estade): email? | 87 base::string16 email = GetInfo(AutofillType(EMAIL_ADDRESS)); |
| 88 if (!email.empty()) |
| 89 address += newline + email; |
88 address += newline + GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)); | 90 address += newline + GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)); |
89 | 91 |
90 return address; | 92 return address; |
91 } | 93 } |
92 | 94 |
93 // EmptyDataModelWrapper | 95 // EmptyDataModelWrapper |
94 | 96 |
95 EmptyDataModelWrapper::EmptyDataModelWrapper() {} | 97 EmptyDataModelWrapper::EmptyDataModelWrapper() {} |
96 EmptyDataModelWrapper::~EmptyDataModelWrapper() {} | 98 EmptyDataModelWrapper::~EmptyDataModelWrapper() {} |
97 | 99 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 field->SetHtmlType(HTML_TYPE_NAME, field->html_mode()); | 153 field->SetHtmlType(HTML_TYPE_NAME, field->html_mode()); |
152 AutofillDataModelWrapper::FillFormField(field); | 154 AutofillDataModelWrapper::FillFormField(field); |
153 | 155 |
154 // Restore the field's true type. | 156 // Restore the field's true type. |
155 field->SetHtmlType(original_type, field->html_mode()); | 157 field->SetHtmlType(original_type, field->html_mode()); |
156 } else { | 158 } else { |
157 AutofillDataModelWrapper::FillFormField(field); | 159 AutofillDataModelWrapper::FillFormField(field); |
158 } | 160 } |
159 } | 161 } |
160 | 162 |
| 163 AutofillShippingAddressWrapper::AutofillShippingAddressWrapper( |
| 164 const AutofillProfile* profile, size_t variant) |
| 165 : AutofillProfileWrapper(profile, variant) {} |
| 166 |
| 167 AutofillShippingAddressWrapper::~AutofillShippingAddressWrapper() {} |
| 168 |
| 169 base::string16 AutofillShippingAddressWrapper::GetInfo( |
| 170 const AutofillType& type) const { |
| 171 // Shipping addresses don't have email addresses associated with them. |
| 172 if (type.GetStorableType() == EMAIL_ADDRESS) |
| 173 return base::string16(); |
| 174 |
| 175 return AutofillProfileWrapper::GetInfo(type); |
| 176 } |
| 177 |
161 // AutofillCreditCardWrapper | 178 // AutofillCreditCardWrapper |
162 | 179 |
163 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) | 180 AutofillCreditCardWrapper::AutofillCreditCardWrapper(const CreditCard* card) |
164 : AutofillDataModelWrapper(card, 0), | 181 : AutofillDataModelWrapper(card, 0), |
165 card_(card) {} | 182 card_(card) {} |
166 | 183 |
167 AutofillCreditCardWrapper::~AutofillCreditCardWrapper() {} | 184 AutofillCreditCardWrapper::~AutofillCreditCardWrapper() {} |
168 | 185 |
169 base::string16 AutofillCreditCardWrapper::GetInfo(const AutofillType& type) | 186 base::string16 AutofillCreditCardWrapper::GetInfo(const AutofillType& type) |
170 const { | 187 const { |
(...skipping 22 matching lines...) Expand all Loading... |
193 } | 210 } |
194 | 211 |
195 // WalletAddressWrapper | 212 // WalletAddressWrapper |
196 | 213 |
197 WalletAddressWrapper::WalletAddressWrapper( | 214 WalletAddressWrapper::WalletAddressWrapper( |
198 const wallet::Address* address) : address_(address) {} | 215 const wallet::Address* address) : address_(address) {} |
199 | 216 |
200 WalletAddressWrapper::~WalletAddressWrapper() {} | 217 WalletAddressWrapper::~WalletAddressWrapper() {} |
201 | 218 |
202 base::string16 WalletAddressWrapper::GetInfo(const AutofillType& type) const { | 219 base::string16 WalletAddressWrapper::GetInfo(const AutofillType& type) const { |
| 220 // Reachable from DataModelWrapper::GetDisplayText(). |
| 221 if (type.GetStorableType() == EMAIL_ADDRESS) |
| 222 return base::string16(); |
| 223 |
203 return address_->GetInfo(type, g_browser_process->GetApplicationLocale()); | 224 return address_->GetInfo(type, g_browser_process->GetApplicationLocale()); |
204 } | 225 } |
205 | 226 |
206 bool WalletAddressWrapper::GetDisplayText( | 227 bool WalletAddressWrapper::GetDisplayText( |
207 base::string16* vertically_compact, | 228 base::string16* vertically_compact, |
208 base::string16* horizontally_compact) { | 229 base::string16* horizontally_compact) { |
209 if (!address_->is_complete_address() || | 230 if (!address_->is_complete_address() || |
210 GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty()) { | 231 GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty()) { |
211 return false; | 232 return false; |
212 } | 233 } |
213 | 234 |
214 return DataModelWrapper::GetDisplayText(vertically_compact, | 235 return DataModelWrapper::GetDisplayText(vertically_compact, |
215 horizontally_compact); | 236 horizontally_compact); |
216 } | 237 } |
217 | 238 |
218 // WalletInstrumentWrapper | 239 // WalletInstrumentWrapper |
219 | 240 |
220 WalletInstrumentWrapper::WalletInstrumentWrapper( | 241 WalletInstrumentWrapper::WalletInstrumentWrapper( |
221 const wallet::WalletItems::MaskedInstrument* instrument) | 242 const wallet::WalletItems::MaskedInstrument* instrument) |
222 : instrument_(instrument) {} | 243 : instrument_(instrument) {} |
223 | 244 |
224 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} | 245 WalletInstrumentWrapper::~WalletInstrumentWrapper() {} |
225 | 246 |
226 base::string16 WalletInstrumentWrapper::GetInfo(const AutofillType& type) | 247 base::string16 WalletInstrumentWrapper::GetInfo(const AutofillType& type) |
227 const { | 248 const { |
| 249 // Reachable from DataModelWrapper::GetDisplayText(). |
| 250 if (type.GetStorableType() == EMAIL_ADDRESS) |
| 251 return base::string16(); |
| 252 |
228 if (type.GetStorableType() == CREDIT_CARD_EXP_MONTH) | 253 if (type.GetStorableType() == CREDIT_CARD_EXP_MONTH) |
229 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); | 254 return MonthComboboxModel::FormatMonth(instrument_->expiration_month()); |
230 | 255 |
231 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale()); | 256 return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale()); |
232 } | 257 } |
233 | 258 |
234 gfx::Image WalletInstrumentWrapper::GetIcon() { | 259 gfx::Image WalletInstrumentWrapper::GetIcon() { |
235 return instrument_->CardIcon(); | 260 return instrument_->CardIcon(); |
236 } | 261 } |
237 | 262 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 ServerFieldType storable_type = type.GetStorableType(); | 337 ServerFieldType storable_type = type.GetStorableType(); |
313 for (DetailOutputMap::const_iterator it = outputs_.begin(); | 338 for (DetailOutputMap::const_iterator it = outputs_.begin(); |
314 it != outputs_.end(); ++it) { | 339 it != outputs_.end(); ++it) { |
315 if (storable_type == AutofillType(it->first->type).GetStorableType()) | 340 if (storable_type == AutofillType(it->first->type).GetStorableType()) |
316 return it->second; | 341 return it->second; |
317 } | 342 } |
318 return base::string16(); | 343 return base::string16(); |
319 } | 344 } |
320 | 345 |
321 } // namespace autofill | 346 } // namespace autofill |
OLD | NEW |