Index: components/password_manager/core/browser/affiliated_match_helper.cc |
diff --git a/components/password_manager/core/browser/affiliated_match_helper.cc b/components/password_manager/core/browser/affiliated_match_helper.cc |
index 283b7e7be5337fa97caa9dd0968b5faf35c33a2d..dea85b5936d712695053c06bc88b3600d381c6a7 100644 |
--- a/components/password_manager/core/browser/affiliated_match_helper.cc |
+++ b/components/password_manager/core/browser/affiliated_match_helper.cc |
@@ -6,6 +6,7 @@ |
#include <utility> |
+#include "base/barrier_closure.h" |
#include "base/bind.h" |
#include "base/callback.h" |
#include "base/single_thread_task_runner.h" |
@@ -85,6 +86,40 @@ void AffiliatedMatchHelper::GetAffiliatedWebRealms( |
} |
} |
+void AffiliatedMatchHelper::FillAffiliatedWebRealms( |
+ const ScopedVector<autofill::PasswordForm>& forms, |
+ const base::Closure& result_callback) { |
+ std::vector<autofill::PasswordForm*> android_credentials; |
+ for (auto* form : forms) |
+ if (IsValidAndroidCredential(*form)) |
+ android_credentials.push_back(form); |
+ base::Closure barrier_closure = |
+ base::BarrierClosure(android_credentials.size(), result_callback); |
+ for (auto* form : android_credentials) |
+ affiliation_service_->GetAffiliations( |
+ FacetURI::FromPotentiallyInvalidSpec(form->signon_realm), |
+ AffiliationService::StrategyOnCacheMiss::FAIL, |
+ base::Bind(&AffiliatedMatchHelper::FillAffiliatedWebRealm, |
+ weak_ptr_factory_.GetWeakPtr(), base::Unretained(form), |
+ barrier_closure)); |
+} |
+ |
+void AffiliatedMatchHelper::FillAffiliatedWebRealm( |
+ autofill::PasswordForm* form, |
+ base::Closure barrier_closure, |
+ const AffiliatedFacets& results, |
+ bool success) { |
+ // If there is a number of realms, choose the first in the list. |
+ if (success) { |
+ for (const FacetURI& affiliated_facet : results) |
+ if (affiliated_facet.IsValidWebFacetURI()) { |
+ form->affiliated_web_realm = affiliated_facet.canonical_spec(); |
+ break; |
+ } |
+ } |
+ barrier_closure.Run(); |
+} |
+ |
void AffiliatedMatchHelper::TrimAffiliationCache() { |
affiliation_service_->TrimCache(); |
} |