Chromium Code Reviews| Index: third_party/libaddressinput/chromium/cpp/src/address_validator.cc |
| diff --git a/third_party/libaddressinput/chromium/cpp/src/address_validator.cc b/third_party/libaddressinput/chromium/cpp/src/address_validator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f0ca6e521642b81e07580803d60bae649bf413c2 |
| --- /dev/null |
| +++ b/third_party/libaddressinput/chromium/cpp/src/address_validator.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright (C) 2013 Google Inc. |
| +// |
| +// Licensed under the Apache License, Version 2.0 (the "License"); |
| +// you may not use this file except in compliance with the License. |
| +// You may obtain a copy of the License at |
| +// |
| +// http://www.apache.org/licenses/LICENSE-2.0 |
| +// |
| +// Unless required by applicable law or agreed to in writing, software |
| +// distributed under the License is distributed on an "AS IS" BASIS, |
| +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| +// See the License for the specific language governing permissions and |
| +// limitations under the License. |
| + |
| +#include <libaddressinput/address_validator.h> |
| + |
| +#include <libaddressinput/downloader.h> |
| +#include <libaddressinput/load_rules_delegate.h> |
| +#include <libaddressinput/storage.h> |
| + |
| +#include <cassert> |
| +#include <cstddef> |
| +#include <string> |
| + |
| +#include "retriever.h" |
| +#include "rule_retriever.h" |
| +#include "validating_storage.h" |
| + |
| +namespace i18n { |
| +namespace addressinput { |
| + |
| +AddressValidator::AddressValidator(const Downloader* downloader, |
| + Storage* storage, |
| + LoadRulesDelegate* load_rules_delegate) |
| + : rule_retriever_(new RuleRetriever(new Retriever( |
| + VALIDATION_DATA_URL, downloader, new ValidatingStorage(storage)))), |
| + load_rules_delegate_(load_rules_delegate) {} |
| + |
| +AddressValidator::~AddressValidator() {} |
| + |
| +void AddressValidator::LoadRules(const std::string& country_code) { |
| + if (load_rules_delegate_ != NULL) { |
| + load_rules_delegate_->OnAddressValidationRulesLoaded(country_code, false); |
| + } |
| +} |
| + |
| +AddressValidator::Result AddressValidator::ValidateAddress( |
| + const AddressData& address, |
| + const AddressProblemFilter& filter, |
| + AddressProblems* problems) const { |
| + assert(problems != NULL); |
|
Evan Stade
2013/12/11 01:21:49
Typically I think it's nicer to allow null outpara
please use gerrit instead
2013/12/11 02:10:11
Done.
|
| + problems->clear(); |
| + return RULES_NOT_READY; |
| +} |
| + |
| +} // namespace addressinput |
| +} // namespace i18n |