| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/dump_without_crashing.h" | 8 #include "base/debug/dump_without_crashing.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | |
| 11 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 12 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "components/autofill/core/common/password_form.h" | 13 #include "components/autofill/core/common/password_form.h" |
| 14 #include "components/password_manager/core/browser/affiliated_match_helper.h" | 14 #include "components/password_manager/core/browser/affiliated_match_helper.h" |
| 15 #include "components/password_manager/core/browser/password_store_consumer.h" | 15 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 16 #include "components/password_manager/core/browser/password_syncable_service.h" | 16 #include "components/password_manager/core/browser/password_syncable_service.h" |
| 17 | 17 |
| 18 using autofill::PasswordForm; | 18 using autofill::PasswordForm; |
| 19 | 19 |
| 20 namespace password_manager { | 20 namespace password_manager { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // http://crbug.com/404012. Let's see where the empty fields come from. | 24 // http://crbug.com/404012. Let's see where the empty fields come from. |
| 25 void CheckForEmptyUsernameAndPassword(const PasswordForm& form) { | 25 void CheckForEmptyUsernameAndPassword(const PasswordForm& form) { |
| 26 if (form.username_value.empty() && | 26 if (form.username_value.empty() && |
| 27 form.password_value.empty() && | 27 form.password_value.empty() && |
| 28 !form.blacklisted_by_user) | 28 !form.blacklisted_by_user) |
| 29 base::debug::DumpWithoutCrashing(); | 29 base::debug::DumpWithoutCrashing(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 PasswordStore::GetLoginsRequest::GetLoginsRequest( | 34 PasswordStore::GetLoginsRequest::GetLoginsRequest( |
| 35 PasswordStoreConsumer* consumer) | 35 PasswordStoreConsumer* consumer) |
| 36 : consumer_weak_(consumer->GetWeakPtr()) { | 36 : consumer_weak_(consumer->GetWeakPtr()) { |
| 37 origin_loop_ = base::MessageLoopProxy::current(); | 37 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 PasswordStore::GetLoginsRequest::~GetLoginsRequest() { | 40 PasswordStore::GetLoginsRequest::~GetLoginsRequest() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 void PasswordStore::GetLoginsRequest::NotifyConsumerWithResults( | 43 void PasswordStore::GetLoginsRequest::NotifyConsumerWithResults( |
| 44 ScopedVector<autofill::PasswordForm> results) { | 44 ScopedVector<autofill::PasswordForm> results) { |
| 45 if (!ignore_logins_cutoff_.is_null()) { | 45 if (!ignore_logins_cutoff_.is_null()) { |
| 46 ScopedVector<autofill::PasswordForm> remaining_logins; | 46 ScopedVector<autofill::PasswordForm> remaining_logins; |
| 47 remaining_logins.reserve(results.size()); | 47 remaining_logins.reserve(results.size()); |
| 48 for (auto& login : results) { | 48 for (auto& login : results) { |
| 49 if (login->date_created >= ignore_logins_cutoff_) { | 49 if (login->date_created >= ignore_logins_cutoff_) { |
| 50 remaining_logins.push_back(login); | 50 remaining_logins.push_back(login); |
| 51 login = nullptr; | 51 login = nullptr; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 results = remaining_logins.Pass(); | 54 results = remaining_logins.Pass(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 origin_loop_->PostTask( | 57 origin_task_runner_->PostTask( |
| 58 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetPasswordStoreResults, | 58 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetPasswordStoreResults, |
| 59 consumer_weak_, base::Passed(&results))); | 59 consumer_weak_, base::Passed(&results))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics( | 62 void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics( |
| 63 scoped_ptr<InteractionsStats> stats) { | 63 scoped_ptr<InteractionsStats> stats) { |
| 64 origin_loop_->PostTask(FROM_HERE, | 64 origin_task_runner_->PostTask( |
| 65 base::Bind(&PasswordStoreConsumer::OnGetSiteStatistics, | 65 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetSiteStatistics, |
| 66 consumer_weak_, base::Passed(&stats))); | 66 consumer_weak_, base::Passed(&stats))); |
| 67 } | 67 } |
| 68 | 68 |
| 69 PasswordStore::PasswordStore( | 69 PasswordStore::PasswordStore( |
| 70 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 70 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 71 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner) | 71 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner) |
| 72 : main_thread_runner_(main_thread_runner), | 72 : main_thread_runner_(main_thread_runner), |
| 73 db_thread_runner_(db_thread_runner), | 73 db_thread_runner_(db_thread_runner), |
| 74 observers_(new ObserverListThreadSafe<Observer>()), | 74 observers_(new ObserverListThreadSafe<Observer>()), |
| 75 is_propagating_password_changes_to_web_credentials_enabled_(false), | 75 is_propagating_password_changes_to_web_credentials_enabled_(false), |
| 76 shutdown_called_(false) { | 76 shutdown_called_(false) { |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 syncable_service_.reset(new PasswordSyncableService(this)); | 500 syncable_service_.reset(new PasswordSyncableService(this)); |
| 501 syncable_service_->InjectStartSyncFlare(flare); | 501 syncable_service_->InjectStartSyncFlare(flare); |
| 502 } | 502 } |
| 503 | 503 |
| 504 void PasswordStore::DestroySyncableService() { | 504 void PasswordStore::DestroySyncableService() { |
| 505 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 505 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
| 506 syncable_service_.reset(); | 506 syncable_service_.reset(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 } // namespace password_manager | 509 } // namespace password_manager |
| OLD | NEW |