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

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: Inlined the variable androidUriSuffix Created 4 years, 9 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..4455bd7c047ed4d35a5395bf53d8fe2632a7158f 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,45 @@ void AffiliatedMatchHelper::GetAffiliatedWebRealms(
}
}
+void AffiliatedMatchHelper::InjectAffiliatedWebRealms(
+ ScopedVector<autofill::PasswordForm> forms,
+ const PasswordFormsCallback& result_callback) {
+ std::vector<autofill::PasswordForm*> android_credentials;
+ for (auto* form : forms) {
+ if (IsValidAndroidCredential(*form))
+ android_credentials.push_back(form);
+ }
+ base::Closure on_get_all_realms(
+ base::Bind(result_callback, base::Passed(&forms)));
+ base::Closure barrier_closure =
+ base::BarrierClosure(android_credentials.size(), on_get_all_realms);
+ for (auto* form : android_credentials) {
+ affiliation_service_->GetAffiliations(
+ FacetURI::FromPotentiallyInvalidSpec(form->signon_realm),
+ AffiliationService::StrategyOnCacheMiss::FAIL,
+ base::Bind(&AffiliatedMatchHelper::CompleteInjectAffiliatedWebRealm,
+ weak_ptr_factory_.GetWeakPtr(), base::Unretained(form),
+ barrier_closure));
+ }
+}
+
+void AffiliatedMatchHelper::CompleteInjectAffiliatedWebRealm(
+ 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