Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: trunk/src/chrome/browser/ui/autofill/data_model_wrapper.cc

Issue 387123004: Revert 282726 "Reland "Use upstream libaddressinput in Chrome."" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" 12 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" 13 #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
14 #include "components/autofill/content/browser/wallet/full_wallet.h" 14 #include "components/autofill/content/browser/wallet/full_wallet.h"
15 #include "components/autofill/content/browser/wallet/wallet_address.h" 15 #include "components/autofill/content/browser/wallet/wallet_address.h"
16 #include "components/autofill/content/browser/wallet/wallet_items.h" 16 #include "components/autofill/content/browser/wallet/wallet_items.h"
17 #include "components/autofill/core/browser/address_i18n.h" 17 #include "components/autofill/core/browser/address_i18n.h"
18 #include "components/autofill/core/browser/autofill_country.h" 18 #include "components/autofill/core/browser/autofill_country.h"
19 #include "components/autofill/core/browser/autofill_data_model.h" 19 #include "components/autofill/core/browser/autofill_data_model.h"
20 #include "components/autofill/core/browser/autofill_field.h" 20 #include "components/autofill/core/browser/autofill_field.h"
21 #include "components/autofill/core/browser/autofill_profile.h" 21 #include "components/autofill/core/browser/autofill_profile.h"
22 #include "components/autofill/core/browser/autofill_type.h" 22 #include "components/autofill/core/browser/autofill_type.h"
23 #include "components/autofill/core/browser/credit_card.h" 23 #include "components/autofill/core/browser/credit_card.h"
24 #include "components/autofill/core/browser/form_structure.h" 24 #include "components/autofill/core/browser/form_structure.h"
25 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h" 25 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_data.h"
26 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h" 26 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_formatter.h"
27 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo rmatter.h"
28 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/gfx/image/image.h" 28 #include "ui/gfx/image/image.h"
30 29
31 namespace autofill { 30 namespace autofill {
32 31
33 DataModelWrapper::~DataModelWrapper() {} 32 DataModelWrapper::~DataModelWrapper() {}
34 33
35 void DataModelWrapper::FillInputs(DetailInputs* inputs) { 34 void DataModelWrapper::FillInputs(DetailInputs* inputs) {
36 for (size_t i = 0; i < inputs->size(); ++i) { 35 for (size_t i = 0; i < inputs->size(); ++i) {
37 (*inputs)[i].initial_value = 36 (*inputs)[i].initial_value =
(...skipping 19 matching lines...) Expand all
57 return false; 56 return false;
58 57
59 // Format the address. 58 // Format the address.
60 scoped_ptr< ::i18n::addressinput::AddressData> address_data = 59 scoped_ptr< ::i18n::addressinput::AddressData> address_data =
61 i18n::CreateAddressData( 60 i18n::CreateAddressData(
62 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this))); 61 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)));
63 address_data->language_code = GetLanguageCode(); 62 address_data->language_code = GetLanguageCode();
64 std::vector<std::string> lines; 63 std::vector<std::string> lines;
65 ::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines); 64 ::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines);
66 65
67 std::string single_line;
68 ::i18n::addressinput::GetFormattedNationalAddressLine(
69 *address_data, &single_line);
70
71 // Email and phone number aren't part of address formatting. 66 // Email and phone number aren't part of address formatting.
72 base::string16 non_address_info; 67 base::string16 non_address_info;
73 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); 68 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS));
74 if (!email.empty()) 69 if (!email.empty())
75 non_address_info += base::ASCIIToUTF16("\n") + email; 70 non_address_info += base::ASCIIToUTF16("\n") + email;
76 71
77 non_address_info += base::ASCIIToUTF16("\n") + phone; 72 non_address_info += base::ASCIIToUTF16("\n") + phone;
78 73
79 *vertically_compact = base::UTF8ToUTF16(single_line) + non_address_info; 74 std::string line_address;
80 *horizontally_compact = base::UTF8ToUTF16(JoinString(lines, "\n")) + 75 ::i18n::addressinput::GetFormattedNationalAddressLine(*address_data,
81 non_address_info; 76 &line_address);
77 *vertically_compact = base::UTF8ToUTF16(line_address) + non_address_info;
78 *horizontally_compact =
79 base::UTF8ToUTF16(JoinString(lines, "\n")) + non_address_info;
82 80
83 return true; 81 return true;
84 } 82 }
85 83
86 bool DataModelWrapper::FillFormStructure( 84 bool DataModelWrapper::FillFormStructure(
87 const std::vector<ServerFieldType>& types, 85 const std::vector<ServerFieldType>& types,
88 const FormStructure::InputFieldComparator& compare, 86 const FormStructure::InputFieldComparator& compare,
89 FormStructure* form_structure) const { 87 FormStructure* form_structure) const {
90 return form_structure->FillFields( 88 return form_structure->FillFields(
91 types, 89 types,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 391 }
394 392
395 return base::UTF8ToUTF16(address_->GetFieldValue(field)); 393 return base::UTF8ToUTF16(address_->GetFieldValue(field));
396 } 394 }
397 395
398 const std::string& I18nAddressDataWrapper::GetLanguageCode() const { 396 const std::string& I18nAddressDataWrapper::GetLanguageCode() const {
399 return address_->language_code; 397 return address_->language_code;
400 } 398 }
401 399
402 } // namespace autofill 400 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698