OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/password_manager/core/browser/password_store.h" | 5 #include "components/password_manager/core/browser/password_store.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 consumer_weak_, base::Passed(&results))); | 49 consumer_weak_, base::Passed(&results))); |
50 } | 50 } |
51 | 51 |
52 void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics( | 52 void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics( |
53 std::vector<InteractionsStats> stats) { | 53 std::vector<InteractionsStats> stats) { |
54 origin_task_runner_->PostTask( | 54 origin_task_runner_->PostTask( |
55 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetSiteStatistics, | 55 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetSiteStatistics, |
56 consumer_weak_, base::Passed(&stats))); | 56 consumer_weak_, base::Passed(&stats))); |
57 } | 57 } |
58 | 58 |
| 59 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 60 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
59 PasswordStore::CheckReuseRequest::CheckReuseRequest( | 61 PasswordStore::CheckReuseRequest::CheckReuseRequest( |
60 PasswordReuseDetectorConsumer* consumer) | 62 PasswordReuseDetectorConsumer* consumer) |
61 : origin_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 63 : origin_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
62 consumer_weak_(consumer->AsWeakPtr()) {} | 64 consumer_weak_(consumer->AsWeakPtr()) {} |
63 | 65 |
64 PasswordStore::CheckReuseRequest::~CheckReuseRequest() {} | 66 PasswordStore::CheckReuseRequest::~CheckReuseRequest() {} |
65 | 67 |
66 void PasswordStore::CheckReuseRequest::OnReuseFound( | 68 void PasswordStore::CheckReuseRequest::OnReuseFound( |
67 const base::string16& password, | 69 const base::string16& password, |
68 const std::string& saved_domain, | 70 const std::string& saved_domain, |
69 int saved_passwords, | 71 int saved_passwords, |
70 int number_matches) { | 72 int number_matches) { |
71 origin_task_runner_->PostTask( | 73 origin_task_runner_->PostTask( |
72 FROM_HERE, | 74 FROM_HERE, |
73 base::Bind(&PasswordReuseDetectorConsumer::OnReuseFound, consumer_weak_, | 75 base::Bind(&PasswordReuseDetectorConsumer::OnReuseFound, consumer_weak_, |
74 password, saved_domain, saved_passwords, number_matches)); | 76 password, saved_domain, saved_passwords, number_matches)); |
75 } | 77 } |
| 78 #endif |
76 | 79 |
77 PasswordStore::FormDigest::FormDigest(autofill::PasswordForm::Scheme new_scheme, | 80 PasswordStore::FormDigest::FormDigest(autofill::PasswordForm::Scheme new_scheme, |
78 const std::string& new_signon_realm, | 81 const std::string& new_signon_realm, |
79 const GURL& new_origin) | 82 const GURL& new_origin) |
80 : scheme(new_scheme), signon_realm(new_signon_realm), origin(new_origin) {} | 83 : scheme(new_scheme), signon_realm(new_signon_realm), origin(new_origin) {} |
81 | 84 |
82 PasswordStore::FormDigest::FormDigest(const PasswordForm& form) | 85 PasswordStore::FormDigest::FormDigest(const PasswordForm& form) |
83 : scheme(form.scheme), | 86 : scheme(form.scheme), |
84 signon_realm(form.signon_realm), | 87 signon_realm(form.signon_realm), |
85 origin(form.origin) {} | 88 origin(form.origin) {} |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 shutdown_called_ = true; | 301 shutdown_called_ = true; |
299 } | 302 } |
300 | 303 |
301 base::WeakPtr<syncer::SyncableService> | 304 base::WeakPtr<syncer::SyncableService> |
302 PasswordStore::GetPasswordSyncableService() { | 305 PasswordStore::GetPasswordSyncableService() { |
303 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 306 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
304 DCHECK(syncable_service_); | 307 DCHECK(syncable_service_); |
305 return syncable_service_->AsWeakPtr(); | 308 return syncable_service_->AsWeakPtr(); |
306 } | 309 } |
307 | 310 |
| 311 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 312 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
308 void PasswordStore::CheckReuse(const base::string16& input, | 313 void PasswordStore::CheckReuse(const base::string16& input, |
309 const std::string& domain, | 314 const std::string& domain, |
310 PasswordReuseDetectorConsumer* consumer) { | 315 PasswordReuseDetectorConsumer* consumer) { |
311 auto check_reuse_request = base::MakeUnique<CheckReuseRequest>(consumer); | 316 auto check_reuse_request = base::MakeUnique<CheckReuseRequest>(consumer); |
312 ScheduleTask(base::Bind(&PasswordStore::CheckReuseImpl, this, | 317 ScheduleTask(base::Bind(&PasswordStore::CheckReuseImpl, this, |
313 base::Passed(&check_reuse_request), input, domain)); | 318 base::Passed(&check_reuse_request), input, domain)); |
314 } | 319 } |
| 320 #endif |
315 | 321 |
316 PasswordStore::~PasswordStore() { | 322 PasswordStore::~PasswordStore() { |
317 DCHECK(shutdown_called_); | 323 DCHECK(shutdown_called_); |
318 } | 324 } |
319 | 325 |
320 scoped_refptr<base::SingleThreadTaskRunner> | 326 scoped_refptr<base::SingleThreadTaskRunner> |
321 PasswordStore::GetBackgroundTaskRunner() { | 327 PasswordStore::GetBackgroundTaskRunner() { |
322 return db_thread_runner_; | 328 return db_thread_runner_; |
323 } | 329 } |
324 | 330 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return RemoveLoginImpl(form); | 376 return RemoveLoginImpl(form); |
371 } | 377 } |
372 | 378 |
373 void PasswordStore::NotifyLoginsChanged( | 379 void PasswordStore::NotifyLoginsChanged( |
374 const PasswordStoreChangeList& changes) { | 380 const PasswordStoreChangeList& changes) { |
375 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 381 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
376 if (!changes.empty()) { | 382 if (!changes.empty()) { |
377 observers_->Notify(FROM_HERE, &Observer::OnLoginsChanged, changes); | 383 observers_->Notify(FROM_HERE, &Observer::OnLoginsChanged, changes); |
378 if (syncable_service_) | 384 if (syncable_service_) |
379 syncable_service_->ActOnPasswordStoreChanges(changes); | 385 syncable_service_->ActOnPasswordStoreChanges(changes); |
| 386 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 387 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
380 if (reuse_detector_) | 388 if (reuse_detector_) |
381 reuse_detector_->OnLoginsChanged(changes); | 389 reuse_detector_->OnLoginsChanged(changes); |
| 390 #endif |
382 } | 391 } |
383 } | 392 } |
384 | 393 |
| 394 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 395 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
385 void PasswordStore::CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request, | 396 void PasswordStore::CheckReuseImpl(std::unique_ptr<CheckReuseRequest> request, |
386 const base::string16& input, | 397 const base::string16& input, |
387 const std::string& domain) { | 398 const std::string& domain) { |
388 if (reuse_detector_) | 399 if (reuse_detector_) |
389 reuse_detector_->CheckReuse(input, domain, request.get()); | 400 reuse_detector_->CheckReuse(input, domain, request.get()); |
390 } | 401 } |
| 402 #endif |
391 | 403 |
392 void PasswordStore::Schedule( | 404 void PasswordStore::Schedule( |
393 void (PasswordStore::*func)(std::unique_ptr<GetLoginsRequest>), | 405 void (PasswordStore::*func)(std::unique_ptr<GetLoginsRequest>), |
394 PasswordStoreConsumer* consumer) { | 406 PasswordStoreConsumer* consumer) { |
395 std::unique_ptr<GetLoginsRequest> request(new GetLoginsRequest(consumer)); | 407 std::unique_ptr<GetLoginsRequest> request(new GetLoginsRequest(consumer)); |
396 consumer->cancelable_task_tracker()->PostTask( | 408 consumer->cancelable_task_tracker()->PostTask( |
397 GetBackgroundTaskRunner().get(), FROM_HERE, | 409 GetBackgroundTaskRunner().get(), FROM_HERE, |
398 base::Bind(func, this, base::Passed(&request))); | 410 base::Bind(func, this, base::Passed(&request))); |
399 } | 411 } |
400 | 412 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 ScheduleTask(base::Bind(&PasswordStore::UpdateAffiliatedWebLoginsImpl, this, | 706 ScheduleTask(base::Bind(&PasswordStore::UpdateAffiliatedWebLoginsImpl, this, |
695 updated_android_form, affiliated_web_realms)); | 707 updated_android_form, affiliated_web_realms)); |
696 } | 708 } |
697 | 709 |
698 void PasswordStore::InitOnBackgroundThread( | 710 void PasswordStore::InitOnBackgroundThread( |
699 const syncer::SyncableService::StartSyncFlare& flare) { | 711 const syncer::SyncableService::StartSyncFlare& flare) { |
700 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 712 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
701 DCHECK(!syncable_service_); | 713 DCHECK(!syncable_service_); |
702 syncable_service_.reset(new PasswordSyncableService(this)); | 714 syncable_service_.reset(new PasswordSyncableService(this)); |
703 syncable_service_->InjectStartSyncFlare(flare); | 715 syncable_service_->InjectStartSyncFlare(flare); |
| 716 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 717 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
704 reuse_detector_.reset(new PasswordReuseDetector); | 718 reuse_detector_.reset(new PasswordReuseDetector); |
705 GetAutofillableLoginsImpl( | 719 GetAutofillableLoginsImpl( |
706 base::MakeUnique<GetLoginsRequest>(reuse_detector_.get())); | 720 base::MakeUnique<GetLoginsRequest>(reuse_detector_.get())); |
| 721 #endif |
707 } | 722 } |
708 | 723 |
709 void PasswordStore::DestroyOnBackgroundThread() { | 724 void PasswordStore::DestroyOnBackgroundThread() { |
710 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 725 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
711 syncable_service_.reset(); | 726 syncable_service_.reset(); |
| 727 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 728 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
712 reuse_detector_.reset(); | 729 reuse_detector_.reset(); |
| 730 #endif |
713 } | 731 } |
714 | 732 |
715 std::ostream& operator<<(std::ostream& os, | 733 std::ostream& operator<<(std::ostream& os, |
716 const PasswordStore::FormDigest& digest) { | 734 const PasswordStore::FormDigest& digest) { |
717 return os << "FormDigest(scheme: " << digest.scheme | 735 return os << "FormDigest(scheme: " << digest.scheme |
718 << ", signon_realm: " << digest.signon_realm | 736 << ", signon_realm: " << digest.signon_realm |
719 << ", origin: " << digest.origin << ")"; | 737 << ", origin: " << digest.origin << ")"; |
720 } | 738 } |
721 | 739 |
722 } // namespace password_manager | 740 } // namespace password_manager |
OLD | NEW |