Chromium Code Reviews| Index: third_party/libaddressinput/chromium/preload_address_validator.h |
| diff --git a/third_party/libaddressinput/chromium/preload_address_validator.h b/third_party/libaddressinput/chromium/preload_address_validator.h |
| index 8b22040b912a95e5bbb60569bb6f160855d0a039..3c30d0490acdf1c3d8fb45870400c13edb63d1cd 100644 |
| --- a/third_party/libaddressinput/chromium/preload_address_validator.h |
| +++ b/third_party/libaddressinput/chromium/preload_address_validator.h |
| @@ -14,28 +14,34 @@ |
| #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h" |
| #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_validator.h" |
| #include "third_party/libaddressinput/src/cpp/include/libaddressinput/callback.h" |
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/preload_supplier.h" |
| namespace i18n { |
| namespace addressinput { |
| - |
| +class AddressNormalizer; |
| class Downloader; |
| -class PreloadSupplier; |
| class Storage; |
| -class Synonyms; |
| struct AddressData; |
| - |
| -} // namespace addressinput |
| -} // namespace i18n |
| +struct AddressInputHelper; |
| +} |
| +} |
| namespace autofill { |
| +class LoadRulesDelegate; |
| class Suggestions; |
| -// Interface to the libaddressinput AddressValidator for Chromium Autofill. |
| -class PreloadAddressValidator { |
| +// Interface to the libaddressinput AddressValidator for Chromium Autofill. The |
| +// class is named AddressValidator to simplify switching between libaddressinput |
| +// and this version. |
| +// |
| +// It's not possible to name this file address_validator.h because some |
| +// compilers do not handle multiple files with the same name (although in |
| +// different directories) gracefully. This class uses preloaded validation rules |
|
Evan Stade
2014/06/12 00:18:09
what? so chrome doesn't load validation rules on d
please use gerrit instead
2014/06/13 19:22:09
Chrome loads all rules for a country when the user
Evan Stade
2014/06/13 20:07:08
It does load the rules on demand (saying it doesn'
please use gerrit instead
2014/06/16 19:02:24
Changed to chrome_address_validator to be similar
|
| +// instead of loading them on demand, hence the file name |
| +// preload_address_validator.h. |
| +class AddressValidator { |
| public: |
| - typedef ::i18n::addressinput::Callback<std::string, int> Callback; |
| - |
| // The status of address validation. |
| enum Status { |
| // Address validation completed successfully. Check |problems| to see if any |
| @@ -51,12 +57,12 @@ class PreloadAddressValidator { |
| }; |
| // Takes ownership of |downloader| and |storage|. |
| - PreloadAddressValidator( |
| - const std::string& validation_data_url, |
| - scoped_ptr< ::i18n::addressinput::Downloader> downloader, |
| - scoped_ptr< ::i18n::addressinput::Storage> storage); |
| + AddressValidator(const std::string& validation_data_url, |
| + scoped_ptr< ::i18n::addressinput::Downloader> downloader, |
| + scoped_ptr< ::i18n::addressinput::Storage> storage, |
| + LoadRulesDelegate* load_rules_delegate); |
| - virtual ~PreloadAddressValidator(); |
| + virtual ~AddressValidator(); |
| // Loads the generic validation rules for |region_code| and specific rules |
| // for the regions's administrative areas, localities, and dependent |
| @@ -67,9 +73,8 @@ class PreloadAddressValidator { |
| // https://i18napis.appspot.com/ssl-aggregate-address/data/US |
| // |
| // If the rules are already in progress of being loaded, it does nothing. |
| - // Calls |loaded| when the loading has finished. |
| - virtual void LoadRules(const std::string& region_code, |
| - const Callback& loaded); |
| + // Invokes |load_rules_delegate| when the loading has finished. |
| + virtual void LoadRules(const std::string& region_code); |
| // Validates the |address| and populates |problems| with the validation |
| // problems, filtered according to the |filter| parameter. |
| @@ -77,7 +82,7 @@ class PreloadAddressValidator { |
| // If the |filter| is empty, then all discovered validation problems are |
| // returned. If the |filter| contains problem elements, then only the problems |
| // in the |filter| may be returned. |
| - virtual Status Validate( |
| + virtual Status ValidateAddress( |
| const ::i18n::addressinput::AddressData& address, |
| const ::i18n::addressinput::FieldProblemMap* filter, |
| ::i18n::addressinput::FieldProblemMap* problems) const; |
| @@ -123,17 +128,24 @@ class PreloadAddressValidator { |
| const ::i18n::addressinput::AddressData&, |
| const ::i18n::addressinput::FieldProblemMap&); |
| + void RulesLoaded(bool success, const std::string& country_code, const int&); |
| + |
| const scoped_ptr< ::i18n::addressinput::PreloadSupplier> supplier_; |
| const scoped_ptr<Suggestions> suggestions_; |
| - const scoped_ptr< ::i18n::addressinput::Synonyms> synonyms_; |
| + const scoped_ptr< ::i18n::addressinput::AddressNormalizer> normalizer_; |
| const scoped_ptr<const ::i18n::addressinput::AddressValidator> validator_; |
| + const scoped_ptr<const ::i18n::addressinput::AddressInputHelper> |
| + input_helper_; |
| const scoped_ptr<const ::i18n::addressinput::AddressValidator::Callback> |
| validated_; |
| + const scoped_ptr<const ::i18n::addressinput::PreloadSupplier::Callback> |
| + rules_loaded_; |
| + LoadRulesDelegate* const load_rules_delegate_; // Not owned. |
| friend class MockAddressValidator; |
| - PreloadAddressValidator(); |
| + AddressValidator(); |
| - DISALLOW_COPY_AND_ASSIGN(PreloadAddressValidator); |
| + DISALLOW_COPY_AND_ASSIGN(AddressValidator); |
| }; |
| } // namespace autofill |