| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 ServerFieldType storable_type = type.GetStorableType(); | 329 ServerFieldType storable_type = type.GetStorableType(); |
| 313 for (DetailOutputMap::const_iterator it = outputs_.begin(); | 330 for (DetailOutputMap::const_iterator it = outputs_.begin(); |
| 314 it != outputs_.end(); ++it) { | 331 it != outputs_.end(); ++it) { |
| 315 if (storable_type == AutofillType(it->first->type).GetStorableType()) | 332 if (storable_type == AutofillType(it->first->type).GetStorableType()) |
| 316 return it->second; | 333 return it->second; |
| 317 } | 334 } |
| 318 return base::string16(); | 335 return base::string16(); |
| 319 } | 336 } |
| 320 | 337 |
| 321 } // namespace autofill | 338 } // namespace autofill |
| OLD | NEW |