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

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

Issue 2338283003: [Payments] Normalize addresses before passing them to merchants. (Closed)
Patch Set: Async 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..018050fe6c6c4d0fc39955101076fc185da64f4c 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"
please use gerrit instead 2016/09/23 09:04:40 Includes for lines 14-16 should go into the *.cc f
sebsg 2016/09/27 18:48:38 The chrome_address_validator has to be there to im
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,32 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver {
JNIEnv* env,
const base::android::JavaParamRef<jobject>& unused_obj);
please use gerrit instead 2016/09/23 09:04:40 // These functions help address normalization. //
sebsg 2016/09/27 18:48:38 Done.
+ // 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);
+
+ // Cancels the pending address normalization task.
+ void CancelAddressNormalizationTask(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& unused_obj);
+
private:
~PersonalDataManagerAndroid() override;
@@ -263,6 +294,20 @@ class PersonalDataManagerAndroid : public PersonalDataManagerObserver {
JNIEnv* env,
const std::vector<CreditCard*>& credit_cards);
+ // Returns whether the rules are done loading for the specified
+ //|region_code|.
+ bool AreRulesDoneLoadingForRegion(std::string region_code);
please use gerrit instead 2016/09/23 09:04:40 const std::string& ... to avoid string copies,
sebsg 2016/09/27 18:48:38 Done.
+
+ // Returns whether the rules were successfully loaded for the specified
+ // |region_code|. This should only be called when the rules have finished
+ // loading.
+ bool AreRulesSuccessfullyLoadedForRegion(std::string region_code);
please use gerrit instead 2016/09/23 09:04:40 const std::string&
sebsg 2016/09/27 18:48:38 Done.
+
+ // 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.
+ void NormalizeAddress(std::string guid, std::string region_code);
please use gerrit instead 2016/09/23 09:04:40 const std::string&
sebsg 2016/09/27 18:48:38 Done.
+
// Gets the labels for the |profiles| passed as parameters. These labels are
// useful for distinguishing the profiles from one another.
//
@@ -282,6 +327,21 @@ 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_;
+
+ // The region code of the rules that still loading and necessary for the
+ // pending address normalization.
+ std::string pending_normalization_region_code_ = "";
+
+ // The guid of the profile to normalize when the rules associated with the
+ // |pending_normalization_region_code_| have finished loading.
+ std::string pending_normalization_profile_guid_ = "";
+
DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerAndroid);
};

Powered by Google App Engine
This is Rietveld 408576698