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 15013b172bf53e7994f710f4ee8deb8715f4361e..43ca1545bad4ca442c357f0521594f0d55581283 100644 |
| --- a/chrome/browser/autofill/android/personal_data_manager_android.h |
| +++ b/chrome/browser/autofill/android/personal_data_manager_android.h |
| @@ -5,6 +5,11 @@ |
| #ifndef CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
| #define CHROME_BROWSER_AUTOFILL_ANDROID_PERSONAL_DATA_MANAGER_ANDROID_H_ |
| +#include <map> |
|
sebsg
2017/02/28 16:14:00
Needed?
Parastoo
2017/03/21 14:30:44
Not really. It was either suggested by git cl form
|
| +#include <memory> |
| +#include <string> |
| +#include <vector> |
| + |
| #include "base/android/jni_weak_ref.h" |
| #include "base/android/scoped_java_ref.h" |
| #include "base/macros.h" |
| @@ -12,14 +17,25 @@ |
| #include "components/autofill/core/browser/personal_data_manager.h" |
| #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| #include "components/payments/address_normalizer.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 base::SupportsWeakPtr<PersonalDataManagerAndroid> { |
| public: |
| + // The interface for the sub-key request. |
| + class Delegate { |
| + public: |
| + virtual void OnRulesSuccessfullyLoaded() = 0; |
| + virtual ~Delegate() {} |
| + }; |
| + |
| PersonalDataManagerAndroid(JNIEnv* env, jobject obj); |
| // Returns true if personal data manager has loaded the initial data. |
| @@ -284,7 +300,14 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| // Starts loading the address validation rules for the specified |
| // |region_code|. |
| - void LoadRulesForRegion( |
| + void LoadRulesForAddressNormalization( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& unused_obj, |
| + const base::android::JavaParamRef<jstring>& region_code); |
| + |
| + // Starts loading the rules for the specified |region_code| for the further |
| + // sub-key request. |
| + void LoadRulesForSubKeys( |
| JNIEnv* env, |
| const base::android::JavaParamRef<jobject>& unused_obj, |
| const base::android::JavaParamRef<jstring>& region_code); |
| @@ -312,6 +335,31 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| JNIEnv* env, |
| const base::android::JavaParamRef<jobject>& unused_obj); |
| + // Gets the sub-keys for the region with |jregion_code| code, if the |
| + // |jregion_code| rules have finished loading. Otherwise, sets up a task to |
| + // get the sub-keys, when the rules are loaded. |
| + void StartGettingRegionSubKeys( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& unused_obj, |
| + const base::android::JavaParamRef<jstring>& jregion_code, |
| + const base::android::JavaParamRef<jobject>& jdelegate); |
| + |
| + // Gets the sub-keys of the rule associated with |jregion_code|. Should only |
| + // be called when the rules are loaded. |
| + base::android::ScopedJavaLocalRef<jobjectArray> GetSubKeys( |
| + JNIEnv* env, |
| + const std::string& jregion_code); |
| + |
| + // Callback of the sub-keys request. |
| + // This is called when the sub-keys are loaded. |
| + void OnAddressRulesLoaded(const std::string& region_code, |
| + bool success) override; |
| + |
| + // Cancels the pending sub-key request task. |
| + void CancelPendingGetSubKeys( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& unused_obj); |
| + |
| private: |
| ~PersonalDataManagerAndroid() override; |
| @@ -362,6 +410,12 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver { |
| // The address validator used to normalize addresses. |
| payments::AddressNormalizer address_normalizer_; |
| + AddressValidator address_validator_; |
|
sebsg
2017/02/28 16:14:00
Add comment that this is used for the sub keys.
Parastoo
2017/03/21 14:30:44
Done.
|
| + |
| + // Map associating a region code to pending sub-keys' request. |
| + std::map<std::string, std::vector<std::unique_ptr<Delegate>>> |
|
sebsg
2017/02/28 16:14:00
Like mentioned in another comment, maybe we can si
Parastoo
2017/03/21 14:30:44
Done.
|
| + pending_subkeys_request_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid); |
| }; |