blob: e7a1647f6ce1d17f6456459da4cb1f500db3a7f9 [file] [log] [blame]
// Copyright 2017 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 "ios/chrome/browser/autofill/address_normalizer_factory.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/autofill/validation_rules_storage_factory.h"
#include "third_party/libaddressinput/chromium/chrome_metadata_source.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
namespace autofill {
namespace {
std::unique_ptr<::i18n::addressinput::Source> GetAddressInputSource(
net::URLRequestContextGetter* url_context_getter) {
return std::unique_ptr<::i18n::addressinput::Source>(
new autofill::ChromeMetadataSource(I18N_ADDRESS_VALIDATION_DATA_URL,
url_context_getter));
}
std::unique_ptr<::i18n::addressinput::Storage> GetAddressInputStorage() {
return autofill::ValidationRulesStorageFactory::CreateStorage();
}
} // namespace
// static
AddressNormalizer* AddressNormalizerFactory::GetInstance() {
static base::LazyInstance<AddressNormalizerFactory>::DestructorAtExit
instance = LAZY_INSTANCE_INITIALIZER;
return &(instance.Get().address_normalizer_);
}
AddressNormalizerFactory::AddressNormalizerFactory()
: address_normalizer_(
GetAddressInputSource(
GetApplicationContext()->GetSystemURLRequestContext()),
GetAddressInputStorage(),
GetApplicationContext()->GetApplicationLocale()) {}
AddressNormalizerFactory::~AddressNormalizerFactory() {}
} // namespace autofill