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

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

Issue 212873003: Store the language code for the address in autofill profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixups Created 6 years, 8 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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 base::string16 phone = 52 base::string16 phone =
53 GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER)); 53 GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER));
54 if (phone.empty()) 54 if (phone.empty())
55 return false; 55 return false;
56 56
57 // Format the address. 57 // Format the address.
58 ::i18n::addressinput::AddressData address_data; 58 ::i18n::addressinput::AddressData address_data;
59 i18ninput::CreateAddressData( 59 i18ninput::CreateAddressData(
60 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)), 60 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)),
61 &address_data); 61 &address_data);
62 address_data.language_code = GetLanguageCode();
62 std::vector<std::string> lines; 63 std::vector<std::string> lines;
63 address_data.FormatForDisplay(&lines); 64 address_data.FormatForDisplay(&lines);
64 65
65 // Email and phone number aren't part of address formatting. 66 // Email and phone number aren't part of address formatting.
66 base::string16 non_address_info; 67 base::string16 non_address_info;
67 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); 68 base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS));
68 if (!email.empty()) 69 if (!email.empty())
69 non_address_info += base::ASCIIToUTF16("\n") + email; 70 non_address_info += base::ASCIIToUTF16("\n") + email;
70 71
71 non_address_info += base::ASCIIToUTF16("\n") + phone; 72 non_address_info += base::ASCIIToUTF16("\n") + phone;
72 73
73 // The separator is locale-specific. 74 // The separator is locale-specific.
74 std::string compact_separator = 75 std::string compact_separator =
75 ::i18n::addressinput::GetCompactAddressLinesSeparator( 76 ::i18n::addressinput::GetCompactAddressLinesSeparator(GetLanguageCode());
76 g_browser_process->GetApplicationLocale());
77 *vertically_compact = 77 *vertically_compact =
78 base::UTF8ToUTF16(JoinString(lines, compact_separator)) + 78 base::UTF8ToUTF16(JoinString(lines, compact_separator)) +
79 non_address_info; 79 non_address_info;
80 *horizontally_compact = base::UTF8ToUTF16(JoinString(lines, "\n")) + 80 *horizontally_compact = base::UTF8ToUTF16(JoinString(lines, "\n")) +
81 non_address_info; 81 non_address_info;
82 82
83 return true; 83 return true;
84 } 84 }
85 85
86 const std::string& DataModelWrapper::GetLanguageCode() const {
87 return g_browser_process->GetApplicationLocale();
88 }
89
86 bool DataModelWrapper::FillFormStructure( 90 bool DataModelWrapper::FillFormStructure(
87 const std::vector<ServerFieldType>& types, 91 const std::vector<ServerFieldType>& types,
88 const FormStructure::InputFieldComparator& compare, 92 const FormStructure::InputFieldComparator& compare,
89 FormStructure* form_structure) const { 93 FormStructure* form_structure) const {
90 return form_structure->FillFields( 94 return form_structure->FillFields(
91 types, 95 types,
92 compare, 96 compare,
93 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)), 97 base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)),
94 g_browser_process->GetApplicationLocale()); 98 g_browser_process->GetApplicationLocale());
95 } 99 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 i18n::PhoneObject phone(phone_number, region); 147 i18n::PhoneObject phone(phone_number, region);
144 return phone.GetFormattedNumber(); 148 return phone.GetFormattedNumber();
145 } 149 }
146 150
147 return phone_number; 151 return phone_number;
148 } 152 }
149 153
150 return DataModelWrapper::GetInfoForDisplay(type); 154 return DataModelWrapper::GetInfoForDisplay(type);
151 } 155 }
152 156
157 const std::string& AutofillProfileWrapper::GetLanguageCode() const {
158 return profile_->language_code();
159 }
160
153 size_t AutofillProfileWrapper::GetVariantForType(const AutofillType& type) 161 size_t AutofillProfileWrapper::GetVariantForType(const AutofillType& type)
154 const { 162 const {
155 if (type.group() == variant_group_) 163 if (type.group() == variant_group_)
156 return variant_; 164 return variant_;
157 165
158 return 0; 166 return 0;
159 } 167 }
160 168
161 // AutofillShippingAddressWrapper 169 // AutofillShippingAddressWrapper
162 170
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return base::string16(); 364 return base::string16();
357 365
358 if (field == ::i18n::addressinput::COUNTRY) { 366 if (field == ::i18n::addressinput::COUNTRY) {
359 return AutofillCountry(address_->country_code, 367 return AutofillCountry(address_->country_code,
360 g_browser_process->GetApplicationLocale()).name(); 368 g_browser_process->GetApplicationLocale()).name();
361 } 369 }
362 370
363 return base::UTF8ToUTF16(address_->GetFieldValue(field)); 371 return base::UTF8ToUTF16(address_->GetFieldValue(field));
364 } 372 }
365 373
374 const std::string& I18nAddressDataWrapper::GetLanguageCode() const {
375 return address_->language_code;
376 }
377
366 } // namespace autofill 378 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/data_model_wrapper.h ('k') | components/autofill/core/browser/autofill_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698