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

Side by Side Diff: chrome/browser/autofill/autofill_profile.cc

Issue 6484022: Autofill i18n: Set postal code and state field labels based on the selected country. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Still needs tests Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autofill/autofill_profile.h" 5 #include "chrome/browser/autofill/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (iter == personal_info_.end() || iter->second == NULL) 190 if (iter == personal_info_.end() || iter->second == NULL)
191 return; 191 return;
192 192
193 iter->second->SetInfo(type, CollapseWhitespace(value, false)); 193 iter->second->SetInfo(type, CollapseWhitespace(value, false));
194 } 194 }
195 195
196 FormGroup* AutoFillProfile::Clone() const { 196 FormGroup* AutoFillProfile::Clone() const {
197 return new AutoFillProfile(*this); 197 return new AutoFillProfile(*this);
198 } 198 }
199 199
200 const string16 AutoFillProfile::Label() const { 200 string16 AutoFillProfile::Label() const {
201 return label_; 201 return label_;
202 } 202 }
203 203
204 std::string AutoFillProfile::CountryCode() const {
205 FormGroup* form_group =
206 personal_info_.find(AutoFillType::ADDRESS_HOME)->second;
207 DCHECK(form_group);
208 Address* address = static_cast<Address*>(form_group);
209 return address->country_code();
210 }
211
212 void AutoFillProfile::SetCountryCode(const std::string& country_code) {
213 FormGroup* form_group =
214 personal_info_.find(AutoFillType::ADDRESS_HOME)->second;
215 DCHECK(form_group);
216 Address* address = static_cast<Address*>(form_group);
217 address->set_country_code(country_code);
218 }
219
204 // static 220 // static
205 bool AutoFillProfile::AdjustInferredLabels( 221 bool AutoFillProfile::AdjustInferredLabels(
206 std::vector<AutoFillProfile*>* profiles) { 222 std::vector<AutoFillProfile*>* profiles) {
207 const size_t kMinimalFieldsShown = 2; 223 const size_t kMinimalFieldsShown = 2;
208 224
209 std::vector<string16> created_labels; 225 std::vector<string16> created_labels;
210 CreateInferredLabels(profiles, NULL, UNKNOWN_TYPE, kMinimalFieldsShown, 226 CreateInferredLabels(profiles, NULL, UNKNOWN_TYPE, kMinimalFieldsShown,
211 &created_labels); 227 &created_labels);
212 DCHECK_EQ(profiles->size(), created_labels.size()); 228 DCHECK_EQ(profiles->size(), created_labels.size());
213 229
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))) 485 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_ZIP)))
470 << " " 486 << " "
471 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY))) 487 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY)))
472 << " " 488 << " "
473 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( 489 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(
474 PHONE_HOME_WHOLE_NUMBER))) 490 PHONE_HOME_WHOLE_NUMBER)))
475 << " " 491 << " "
476 << UTF16ToUTF8(profile.GetFieldText(AutoFillType( 492 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(
477 PHONE_FAX_WHOLE_NUMBER))); 493 PHONE_FAX_WHOLE_NUMBER)));
478 } 494 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698