Index: chrome/browser/autofill/android/personal_data_manager_android.cc |
diff --git a/chrome/browser/autofill/android/personal_data_manager_android.cc b/chrome/browser/autofill/android/personal_data_manager_android.cc |
index ad2750d4f802b6436035fdb4368650e99aea6bfb..bdb81b8e8a4cc7838b6c6246fe9978423497d900 100644 |
--- a/chrome/browser/autofill/android/personal_data_manager_android.cc |
+++ b/chrome/browser/autofill/android/personal_data_manager_android.cc |
@@ -285,7 +285,7 @@ class AddressNormalizationRequester |
} |
private: |
- virtual ~AddressNormalizationRequester() {} |
+ ~AddressNormalizationRequester() override {} |
void OnRulesSuccessfullyLoaded() override { |
if (personal_data_manager_android_) { |
@@ -580,6 +580,8 @@ void PersonalDataManagerAndroid::SetProfileUseStatsForTesting( |
ConvertJavaStringToUTF8(env, jguid)); |
profile->set_use_count(static_cast<size_t>(count)); |
profile->set_use_date(base::Time::FromTimeT(date)); |
+ |
+ personal_data_manager_->UpdateProfileForTest(*profile); |
personal_data_manager_->NotifyPersonalDataChangedForTest(); |
} |
@@ -623,6 +625,8 @@ void PersonalDataManagerAndroid::SetCreditCardUseStatsForTesting( |
ConvertJavaStringToUTF8(env, jguid)); |
card->set_use_count(static_cast<size_t>(count)); |
card->set_use_date(base::Time::FromTimeT(date)); |
+ |
+ personal_data_manager_->UpdateCreditCardForTest(*card); |
personal_data_manager_->NotifyPersonalDataChangedForTest(); |
} |
@@ -662,11 +666,13 @@ void PersonalDataManagerAndroid::OnAddressValidationRulesLoaded( |
const std::string& region_code, |
bool success) { |
// Check if an address normalization is pending. |
- std::map<std::string, Delegate*>::iterator it = |
+ std::map<std::string, std::vector<Delegate*>>::iterator it = |
pending_normalization_.find(region_code); |
if (it != pending_normalization_.end()) { |
- // The Delegate will self delete after normalizing. |
- it->second->OnRulesSuccessfullyLoaded(); |
+ // Each Delegate will self delete after normalizing. |
+ std::vector<Delegate*> delegates = it->second; |
+ for (size_t i = 0; i < it->second.size(); ++i) |
+ it->second[i]->OnRulesSuccessfullyLoaded(); |
pending_normalization_.erase(it); |
} |
} |
@@ -690,8 +696,17 @@ jboolean PersonalDataManagerAndroid::StartAddressNormalization( |
} else { |
// Setup the variables so the profile gets normalized when the rules have |
// finished loading. |
- pending_normalization_.insert( |
- std::pair<std::string, Delegate*>(region_code, requester)); |
+ if (pending_normalization_.find(region_code) == |
+ pending_normalization_.end()) { |
+ pending_normalization_.insert( |
+ std::pair<std::string, std::vector<Delegate*>>( |
+ region_code, std::vector<Delegate*>())); |
+ } |
+ |
+ std::map<std::string, std::vector<Delegate*>>::iterator it = |
+ pending_normalization_.find(region_code); |
+ it->second.push_back(requester); |
+ |
return true; |
} |
} |
@@ -723,9 +738,17 @@ ScopedJavaLocalRef<jobject> PersonalDataManagerAndroid::NormalizeAddress( |
return CreateJavaProfileFromNative(env, *profile); |
} |
-void PersonalDataManagerAndroid::CancelPendingAddressNormalization( |
+void PersonalDataManagerAndroid::CancelPendingAddressNormalizations( |
JNIEnv* env, |
const base::android::JavaParamRef<jobject>& unused_obj) { |
+ // Delete all the pending normalization delegates. |
+ for (auto it = pending_normalization_.begin(); |
+ it != pending_normalization_.end(); it++) { |
+ for (size_t i = 0; i < it->second.size(); ++i) { |
+ delete it->second[i]; |
+ } |
+ } |
+ |
pending_normalization_.clear(); |
} |