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

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

Issue 999073002: Integrate serving affiliation-based matches into the PasswordStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aff_integration
Patch Set: Reduce scope of CL, test utils are fixed in a separate CL. Created 5 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/password_store.cc
diff --git a/components/password_manager/core/browser/password_store.cc b/components/password_manager/core/browser/password_store.cc
index 8a5792ceb7470c039d81050968ff4d786a2896eb..75cad5434884dbbb40ea271b638d57f269807bda 100644
--- a/components/password_manager/core/browser/password_store.cc
+++ b/components/password_manager/core/browser/password_store.cc
@@ -11,6 +11,7 @@
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "components/autofill/core/common/password_form.h"
+#include "components/password_manager/core/browser/affiliated_match_helper.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#if defined(PASSWORD_MANAGER_ENABLE_SYNC)
@@ -77,6 +78,13 @@ bool PasswordStore::Init(const syncer::SyncableService::StartSyncFlare& flare) {
return true;
}
+void PasswordStore::SetAffiliatedMatchHelper(
+ scoped_ptr<AffiliatedMatchHelper> helper) {
+ DCHECK(helper);
+ DCHECK(!affiliated_match_helper_);
+ affiliated_match_helper_ = helper.Pass();
+}
+
void PasswordStore::AddLogin(const PasswordForm& form) {
CheckForEmptyUsernameAndPassword(form);
ScheduleTask(base::Bind(&PasswordStore::AddLoginInternal, this, form));
@@ -125,8 +133,15 @@ void PasswordStore::GetLogins(const PasswordForm& form,
}
scoped_ptr<GetLoginsRequest> request(new GetLoginsRequest(consumer));
request->set_ignore_logins_cutoff(ignore_logins_cutoff);
- ScheduleTask(base::Bind(&PasswordStore::GetLoginsImpl, this, form,
- prompt_policy, base::Passed(&request)));
+
+ if (affiliated_match_helper_) {
+ affiliated_match_helper_->GetAffiliatedAndroidRealms(
+ form, base::Bind(&PasswordStore::ScheduleGetLoginsWithAffiliations,
+ this, form, prompt_policy, base::Passed(&request)));
+ } else {
+ ScheduleTask(base::Bind(&PasswordStore::GetLoginsImpl, this, form,
+ prompt_policy, base::Passed(&request)));
+ }
}
void PasswordStore::GetAutofillableLogins(PasswordStoreConsumer* consumer) {
@@ -170,6 +185,8 @@ void PasswordStore::Shutdown() {
#if defined(PASSWORD_MANAGER_ENABLE_SYNC)
ScheduleTask(base::Bind(&PasswordStore::DestroySyncableService, this));
#endif
+ // The AffiliationService must be destroyed from the main thread.
+ affiliated_match_helper_.reset();
shutdown_called_ = true;
}
@@ -263,6 +280,36 @@ void PasswordStore::RemoveLoginsSyncedBetweenInternal(base::Time delete_begin,
NotifyLoginsChanged(changes);
}
+void PasswordStore::GetLoginsWithAffiliationsImpl(
+ const PasswordForm& form,
+ AuthorizationPromptPolicy prompt_policy,
+ scoped_ptr<GetLoginsRequest> request,
+ const std::vector<std::string>& additional_android_realms) {
+ DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread());
+ ScopedVector<PasswordForm> results(FillMatchingLogins(form, prompt_policy));
+ for (const std::string& realm : additional_android_realms) {
+ PasswordForm android_form;
+ android_form.scheme = PasswordForm::SCHEME_HTML;
+ android_form.signon_realm = realm;
+ ScopedVector<PasswordForm> more_results(
+ AffiliatedMatchHelper::TransformAffiliatedAndroidCredentials(
+ form, FillMatchingLogins(android_form, DISALLOW_PROMPT)));
+ results.insert(results.end(), more_results.begin(), more_results.end());
+ more_results.weak_clear();
+ }
+ request->NotifyConsumerWithResults(results.Pass());
+}
+
+void PasswordStore::ScheduleGetLoginsWithAffiliations(
+ const PasswordForm& form,
+ AuthorizationPromptPolicy prompt_policy,
+ scoped_ptr<GetLoginsRequest> request,
+ const std::vector<std::string>& additional_android_realms) {
+ ScheduleTask(base::Bind(&PasswordStore::GetLoginsWithAffiliationsImpl, this,
+ form, prompt_policy, base::Passed(&request),
+ additional_android_realms));
+}
+
#if defined(PASSWORD_MANAGER_ENABLE_SYNC)
void PasswordStore::InitSyncableService(
const syncer::SyncableService::StartSyncFlare& flare) {

Powered by Google App Engine
This is Rietveld 408576698