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

Unified Diff: components/password_manager/core/browser/affiliated_match_helper.cc

Issue 1615653005: [Password manager] Human readable origins for Android credentials on chrome://settings/passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Transfer multi-request logic from PasswordStore to AffiliatedMatchHelper Created 4 years, 10 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: 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();
}

Powered by Google App Engine
This is Rietveld 408576698