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

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

Issue 2585253002: Integration of PasswordReuseDetector into PasswordStore. (Closed)
Patch Set: more tests Created 4 years 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 b5a8a13605cf2539709359b5c94c38420fd84480..08caa79f2c5be86453ebd860d4582ce88597580b 100644
--- a/components/password_manager/core/browser/password_store.cc
+++ b/components/password_manager/core/browser/password_store.cc
@@ -59,6 +59,23 @@ void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics(
consumer_weak_, base::Passed(&stats)));
}
+PasswordStore::CheckReuseRequest::CheckReuseRequest(
+ PasswordReuseDetectorConsumer* consumer)
+ : consumer_(consumer) {
+ origin_task_runner_ = base::ThreadTaskRunnerHandle::Get();
vabr (Chromium) 2016/12/20 18:11:44 Why not add , origin_task_runner_(base::ThreadTask
dvadym 2016/12/21 12:15:35 Done.
+}
vabr (Chromium) 2016/12/20 18:11:44 DCHECK(consumer) ?
dvadym 2016/12/21 12:15:35 Done.
+
+PasswordStore::CheckReuseRequest::~CheckReuseRequest() {}
+
+void PasswordStore::CheckReuseRequest::OnReuseFound(
+ const base::string16& password,
+ const std::string& saved_domain) {
+ origin_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&PasswordReuseDetectorConsumer::OnReuseFound,
+ base::Unretained(consumer_), password, saved_domain));
vabr (Chromium) 2016/12/20 18:11:44 PasswordStoreConsumer is called with a weak pointe
dvadym 2016/12/21 12:15:35 Thanks, that's a very good point. I've done with w
+}
+
PasswordStore::FormDigest::FormDigest(autofill::PasswordForm::Scheme new_scheme,
const std::string& new_signon_realm,
const GURL& new_origin)
@@ -90,12 +107,13 @@ PasswordStore::PasswordStore(
: main_thread_runner_(main_thread_runner),
db_thread_runner_(db_thread_runner),
observers_(new base::ObserverListThreadSafe<Observer>()),
+ reuse_detector_(new PasswordReuseDetector),
is_propagating_password_changes_to_web_credentials_enabled_(false),
- shutdown_called_(false) {
-}
+ shutdown_called_(false) {}
bool PasswordStore::Init(const syncer::SyncableService::StartSyncFlare& flare) {
ScheduleTask(base::Bind(&PasswordStore::InitSyncableService, this, flare));
+ GetAutofillableLogins(reuse_detector_.get());
return true;
}
@@ -285,6 +303,15 @@ PasswordStore::GetPasswordSyncableService() {
return syncable_service_->AsWeakPtr();
}
+void PasswordStore::CheckReuse(const base::string16& input,
+ const std::string& domain,
+ PasswordReuseDetectorConsumer* consumer) {
+ std::unique_ptr<CheckReuseRequest> check_reuse_request(
vabr (Chromium) 2016/12/20 18:11:44 nit: auto check_reuse_request = base::MakeUnique<C
dvadym 2016/12/21 12:15:35 Thanks
+ new CheckReuseRequest(consumer));
+ ScheduleTask(base::Bind(&PasswordStore::CheckReuseImpl, this,
+ base::Passed(&check_reuse_request), input, domain));
+}
+
PasswordStore::~PasswordStore() {
DCHECK(shutdown_called_);
}
@@ -349,9 +376,16 @@ void PasswordStore::NotifyLoginsChanged(
observers_->Notify(FROM_HERE, &Observer::OnLoginsChanged, changes);
if (syncable_service_)
syncable_service_->ActOnPasswordStoreChanges(changes);
+ reuse_detector_->OnLoginsChanged(changes);
}
}
+void PasswordStore::CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request,
+ const base::string16& input,
+ const std::string& domain) {
+ reuse_detector_->CheckReuse(input, domain, request.get());
+}
+
void PasswordStore::Schedule(
void (PasswordStore::*func)(std::unique_ptr<GetLoginsRequest>),
PasswordStoreConsumer* consumer) {

Powered by Google App Engine
This is Rietveld 408576698