Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: chrome/browser/autofill/android/personal_data_manager_android.h

Issue 2338283003: [Payments] Normalize addresses before passing them to merchants. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e3a466e5b5ebaf95bf23bbf17f112b355732b90a 100644
--- a/chrome/browser/autofill/android/personal_data_manager_android.h
+++ b/chrome/browser/autofill/android/personal_data_manager_android.h
@@ -8,15 +8,20 @@
#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"
+#include "third_party/libaddressinput/chromium/chrome_metadata_source.h"
+#include "third_party/libaddressinput/chromium/chrome_storage_impl.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:
PersonalDataManagerAndroid(JNIEnv* env, jobject obj);
@@ -250,6 +255,50 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver {
JNIEnv* env,
const base::android::JavaParamRef<jobject>& unused_obj);
+ // 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);
+
+ // Returns whether the rules are done loading for the specified
+ //|jregion_code|.
+ jboolean AreRulesDoneLoadingForRegion(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& unused_obj,
+ const base::android::JavaParamRef<jstring>& jregion_code);
+
+ // Returns whether the rules were successfully loaded for the specified
+ // |jregion_code|.
+ jboolean AreRulesSuccessfullyLoadedForRegion(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& unused_obj,
+ const base::android::JavaParamRef<jstring>& jregion_);
+
+ // Gets the normalized version of the profile associated with the specified
+ // GUID.
+ //
+ // This method will wait for up to 5 seconds for the rules to be loaded. If
+ // the rules are still not loaded after that time, it returns the original
+ // profile.
+ base::android::ScopedJavaLocalRef<jobject> GetNormalizedProfile(
please use gerrit instead 2016/09/16 22:30:42 Make async plz.
sebsg 2016/09/22 19:50:40 Done.
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& unused_obj,
+ const base::android::JavaParamRef<jstring>& jguid,
+ const base::android::JavaParamRef<jstring>& jregion_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 mock address validator used in tests.
+ void SetMockAddressValidatorForTesting(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& unused_obj,
+ jboolean load_rules_response);
+
private:
~PersonalDataManagerAndroid() override;
@@ -282,6 +331,13 @@ 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 containing all the regions for which rules were requested along with
+ // a bool indicating if they have finished loading.
+ std::map<std::string, bool> loaded_rules_;
+
DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid);
};

Powered by Google App Engine
This is Rietveld 408576698