| Index: chrome/browser/ui/autofill/field_map_wrapper.cc
|
| diff --git a/chrome/browser/ui/autofill/field_map_wrapper.cc b/chrome/browser/ui/autofill/field_map_wrapper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..20ac52a09294c2fc7279c781195efd4fb33d2b20
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/autofill/field_map_wrapper.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/ui/autofill/field_map_wrapper.h"
|
| +#include "components/autofill/core/browser/autofill_country.h"
|
| +#include "components/autofill/core/browser/field_types.h"
|
| +
|
| +namespace autofill {
|
| +
|
| +FieldMapWrapper::FieldMapWrapper(const FieldValueMap& field_map,
|
| + DialogSection section)
|
| + : field_map_(field_map),
|
| + is_billing_section_(section != SECTION_SHIPPING) {}
|
| +
|
| +FieldMapWrapper::~FieldMapWrapper() {}
|
| +
|
| +base::string16 FieldMapWrapper::GetInfo(const AutofillType& type) const {
|
| + ServerFieldType field_type = type.GetStorableType();
|
| +
|
| + if (is_billing_section_)
|
| + field_type = AutofillType::GetEquivalentBillingFieldType(field_type);
|
| +
|
| + base::string16 info;
|
| + FieldValueMap::const_iterator it = field_map_.find(field_type);
|
| + if (it != field_map_.end())
|
| + info = it->second;
|
| +
|
| + if (!info.empty() && type.html_type() == HTML_TYPE_COUNTRY_CODE) {
|
| + info = base::ASCIIToUTF16(AutofillCountry::GetCountryCode(
|
| + info, g_browser_process->GetApplicationLocale()));
|
| + }
|
| +
|
| + return info;
|
| +}
|
| +
|
| +void FieldMapWrapper::FillInputs(DetailInputs* inputs) {
|
| + for (size_t i = 0; i < inputs->size(); ++i) {
|
| + (*inputs)[i].initial_value = GetInfo(AutofillType((*inputs)[i].type));
|
| + }
|
| +}
|
| +
|
| +} // namespace autofill
|
|
|