Chromium Code Reviews| Index: chrome/browser/autofill/android/personal_data_manager_android.h |
| diff --git a/chrome/browser/autofill/android/personal_data_manager_android.h b/chrome/browser/autofill/android/personal_data_manager_android.h |
| index a1b74730c2de34670d477820e50c8b3e34459555..92276aada6039443b540e231443c7ae5afc6700b 100644 |
| --- a/chrome/browser/autofill/android/personal_data_manager_android.h |
| +++ b/chrome/browser/autofill/android/personal_data_manager_android.h |
| @@ -8,16 +8,25 @@ |
| #include "base/android/jni_weak_ref.h" |
| #include "base/android/scoped_java_ref.h" |
| #include "base/macros.h" |
| +#include "chrome/browser/autofill/validation_rules_storage_factory.h" |
| #include "components/autofill/core/browser/personal_data_manager.h" |
| #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| +#include "third_party/libaddressinput/chromium/chrome_address_validator.h" |
| namespace autofill { |
| // Android wrapper of the PersonalDataManager which provides access from the |
| // Java layer. Note that on Android, there's only a single profile, and |
| // therefore a single instance of this wrapper. |
| -class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| +class PersonalDataManagerAndroid : public PersonalDataManagerObserver, |
| + public LoadRulesListener { |
| public: |
| + // The interface for the normalization request. |
| + class Delegate { |
| + public: |
| + virtual void OnRulesSuccessfullyLoaded() = 0; |
| + }; |
| + |
| PersonalDataManagerAndroid(JNIEnv* env, jobject obj); |
| // Returns true if personal data manager has loaded the initial data. |
| @@ -250,6 +259,42 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| JNIEnv* env, |
| const base::android::JavaParamRef<jobject>& unused_obj); |
| + // These functions help address normalization. |
| + // -------------------- |
| + |
| + // Starts loading the address validation rules for the specified |
| + // |region_code|. |
| + void LoadRulesForRegion( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& unused_obj, |
| + const base::android::JavaParamRef<jstring>& region_code); |
| + |
| + // Callback of the address validator that is called when the validator has |
| + // finished loading the rules for a region. |
| + void OnAddressValidationRulesLoaded(const std::string& region_code, |
| + bool success) override; |
| + |
| + // Sets up the task to start the address normalization of the profile |
| + // associated with the specified |jguid| when the rules associated with the |
| + // |jregion_code| have finished loading. |
| + void StartAddressNormalizationTask( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& unused_obj, |
| + const base::android::JavaParamRef<jstring>& jguid, |
| + const base::android::JavaParamRef<jstring>& jregion_code, |
| + const base::android::JavaParamRef<jobject>& jdelegate); |
| + |
| + // Normalizes the address of the profile associated with the |guid| with the |
| + // rules associates with the |region_code|. Should only be called when the |
| + // rules have finished loading. |
| + base::android::ScopedJavaLocalRef<jobject> NormalizeAddress( |
| + const std::string& guid, |
| + const std::string& region_code, |
| + JNIEnv* env); |
| + |
| + void CancelPendingAddressNormalization(JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& unused_obj); |
| + |
| private: |
| ~PersonalDataManagerAndroid() override; |
| @@ -263,6 +308,9 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| JNIEnv* env, |
| const std::vector<CreditCard*>& credit_cards); |
| + // Returns whether the rules are loading for the specified |region_code|. |
|
vabr (Chromium)
2016/09/28 08:41:36
nit: loading -> loaded ?
sebsg
2016/09/28 16:15:25
Done.
|
| + bool AreRulesLoadedForRegion(const std::string& region_code); |
| + |
| // Gets the labels for the |profiles| passed as parameters. These labels are |
| // useful for distinguishing the profiles from one another. |
| // |
| @@ -282,6 +330,12 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| // Pointer to the PersonalDataManager for the main profile. |
| PersonalDataManager* personal_data_manager_; |
| + // Pointer to the address validator used to normalize addresses. |
| + std::unique_ptr<AddressValidator> address_validator_; |
| + |
| + // Map associating a region code to a pending normalization. |
| + std::map<std::string, Delegate*> pending_normalization_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); |
| }; |