Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (C) 2013 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 #include <libaddressinput/address_validator.h> | |
| 16 | |
| 17 #include <libaddressinput/downloader.h> | |
| 18 #include <libaddressinput/load_rules_delegate.h> | |
| 19 #include <libaddressinput/storage.h> | |
| 20 | |
| 21 #include <cassert> | |
| 22 #include <cstddef> | |
| 23 #include <string> | |
| 24 | |
| 25 #include "retriever.h" | |
| 26 #include "rule_retriever.h" | |
| 27 #include "validating_storage.h" | |
| 28 | |
| 29 namespace i18n { | |
| 30 namespace addressinput { | |
| 31 | |
| 32 AddressValidator::AddressValidator(const Downloader* downloader, | |
| 33 Storage* storage, | |
| 34 LoadRulesDelegate* load_rules_delegate) | |
| 35 : rule_retriever_(new RuleRetriever(new Retriever( | |
| 36 VALIDATION_DATA_URL, downloader, new ValidatingStorage(storage)))), | |
| 37 load_rules_delegate_(load_rules_delegate) {} | |
| 38 | |
| 39 AddressValidator::~AddressValidator() {} | |
| 40 | |
| 41 void AddressValidator::LoadRules(const std::string& country_code) { | |
| 42 if (load_rules_delegate_ != NULL) { | |
| 43 load_rules_delegate_->OnAddressValidationRulesLoaded(country_code, false); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 AddressValidator::Result AddressValidator::ValidateAddress( | |
| 48 const AddressData& address, | |
| 49 const AddressProblemFilter& filter, | |
| 50 AddressProblems* problems) const { | |
| 51 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.
| |
| 52 problems->clear(); | |
| 53 return RULES_NOT_READY; | |
| 54 } | |
| 55 | |
| 56 } // namespace addressinput | |
| 57 } // namespace i18n | |
| OLD | NEW |