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

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

Issue 145553009: rAc: use libaddressinput to validate international addresses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 6 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/ui/autofill/field_map_wrapper.h"
8 #include "components/autofill/core/browser/autofill_country.h"
9 #include "components/autofill/core/browser/field_types.h"
10
11 namespace autofill {
12
13 FieldMapWrapper::FieldMapWrapper(const FieldValueMap& field_map,
14 DialogSection section)
15 : field_map_(field_map),
16 is_billing_section_(section != SECTION_SHIPPING) {}
17
18 FieldMapWrapper::~FieldMapWrapper() {}
19
20 base::string16 FieldMapWrapper::GetInfo(const AutofillType& type) const {
21 ServerFieldType field_type = type.GetStorableType();
22
23 if (is_billing_section_)
24 field_type = AutofillType::GetEquivalentBillingFieldType(field_type);
25
26 base::string16 info;
27 FieldValueMap::const_iterator it = field_map_.find(field_type);
28 if (it != field_map_.end())
29 info = it->second;
30
31 if (!info.empty() && type.html_type() == HTML_TYPE_COUNTRY_CODE) {
32 info = base::ASCIIToUTF16(AutofillCountry::GetCountryCode(
33 info, g_browser_process->GetApplicationLocale()));
34 }
35
36 return info;
37 }
38
39 void FieldMapWrapper::FillInputs(DetailInputs* inputs) {
40 for (size_t i = 0; i < inputs->size(); ++i) {
41 (*inputs)[i].initial_value = GetInfo(AutofillType((*inputs)[i].type));
42 }
43 }
44
45 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698