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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/dump_without_crashing.h" | 10 #include "base/debug/dump_without_crashing.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ScopedVector<autofill::PasswordForm> results) { | 50 ScopedVector<autofill::PasswordForm> results) { |
51 if (!ignore_logins_cutoff_.is_null()) { | 51 if (!ignore_logins_cutoff_.is_null()) { |
52 ScopedVector<autofill::PasswordForm> remaining_logins; | 52 ScopedVector<autofill::PasswordForm> remaining_logins; |
53 remaining_logins.reserve(results.size()); | 53 remaining_logins.reserve(results.size()); |
54 for (auto& login : results) { | 54 for (auto& login : results) { |
55 if (login->date_created >= ignore_logins_cutoff_) { | 55 if (login->date_created >= ignore_logins_cutoff_) { |
56 remaining_logins.push_back(login); | 56 remaining_logins.push_back(login); |
57 login = nullptr; | 57 login = nullptr; |
58 } | 58 } |
59 } | 59 } |
60 results = remaining_logins.Pass(); | 60 results = std::move(remaining_logins); |
61 } | 61 } |
62 | 62 |
63 origin_task_runner_->PostTask( | 63 origin_task_runner_->PostTask( |
64 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetPasswordStoreResults, | 64 FROM_HERE, base::Bind(&PasswordStoreConsumer::OnGetPasswordStoreResults, |
65 consumer_weak_, base::Passed(&results))); | 65 consumer_weak_, base::Passed(&results))); |
66 } | 66 } |
67 | 67 |
68 void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics( | 68 void PasswordStore::GetLoginsRequest::NotifyWithSiteStatistics( |
69 std::vector<scoped_ptr<InteractionsStats>> stats) { | 69 std::vector<scoped_ptr<InteractionsStats>> stats) { |
70 auto passed_stats(make_scoped_ptr( | 70 auto passed_stats(make_scoped_ptr( |
(...skipping 13 matching lines...) Expand all Loading... |
84 shutdown_called_(false) { | 84 shutdown_called_(false) { |
85 } | 85 } |
86 | 86 |
87 bool PasswordStore::Init(const syncer::SyncableService::StartSyncFlare& flare) { | 87 bool PasswordStore::Init(const syncer::SyncableService::StartSyncFlare& flare) { |
88 ScheduleTask(base::Bind(&PasswordStore::InitSyncableService, this, flare)); | 88 ScheduleTask(base::Bind(&PasswordStore::InitSyncableService, this, flare)); |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 void PasswordStore::SetAffiliatedMatchHelper( | 92 void PasswordStore::SetAffiliatedMatchHelper( |
93 scoped_ptr<AffiliatedMatchHelper> helper) { | 93 scoped_ptr<AffiliatedMatchHelper> helper) { |
94 affiliated_match_helper_ = helper.Pass(); | 94 affiliated_match_helper_ = std::move(helper); |
95 } | 95 } |
96 | 96 |
97 void PasswordStore::AddLogin(const PasswordForm& form) { | 97 void PasswordStore::AddLogin(const PasswordForm& form) { |
98 CheckForEmptyUsernameAndPassword(form); | 98 CheckForEmptyUsernameAndPassword(form); |
99 ScheduleTask(base::Bind(&PasswordStore::AddLoginInternal, this, form)); | 99 ScheduleTask(base::Bind(&PasswordStore::AddLoginInternal, this, form)); |
100 } | 100 } |
101 | 101 |
102 void PasswordStore::UpdateLogin(const PasswordForm& form) { | 102 void PasswordStore::UpdateLogin(const PasswordForm& form) { |
103 CheckForEmptyUsernameAndPassword(form); | 103 CheckForEmptyUsernameAndPassword(form); |
104 ScheduleTask(base::Bind(&PasswordStore::UpdateLoginInternal, this, form)); | 104 ScheduleTask(base::Bind(&PasswordStore::UpdateLoginInternal, this, form)); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 RemoveStatisticsCreatedBetweenImpl(delete_begin, delete_end); | 395 RemoveStatisticsCreatedBetweenImpl(delete_begin, delete_end); |
396 if (!completion.is_null()) | 396 if (!completion.is_null()) |
397 main_thread_runner_->PostTask(FROM_HERE, completion); | 397 main_thread_runner_->PostTask(FROM_HERE, completion); |
398 } | 398 } |
399 | 399 |
400 void PasswordStore::GetAutofillableLoginsImpl( | 400 void PasswordStore::GetAutofillableLoginsImpl( |
401 scoped_ptr<GetLoginsRequest> request) { | 401 scoped_ptr<GetLoginsRequest> request) { |
402 ScopedVector<PasswordForm> obtained_forms; | 402 ScopedVector<PasswordForm> obtained_forms; |
403 if (!FillAutofillableLogins(&obtained_forms)) | 403 if (!FillAutofillableLogins(&obtained_forms)) |
404 obtained_forms.clear(); | 404 obtained_forms.clear(); |
405 request->NotifyConsumerWithResults(obtained_forms.Pass()); | 405 request->NotifyConsumerWithResults(std::move(obtained_forms)); |
406 } | 406 } |
407 | 407 |
408 void PasswordStore::GetBlacklistLoginsImpl( | 408 void PasswordStore::GetBlacklistLoginsImpl( |
409 scoped_ptr<GetLoginsRequest> request) { | 409 scoped_ptr<GetLoginsRequest> request) { |
410 ScopedVector<PasswordForm> obtained_forms; | 410 ScopedVector<PasswordForm> obtained_forms; |
411 if (!FillBlacklistLogins(&obtained_forms)) | 411 if (!FillBlacklistLogins(&obtained_forms)) |
412 obtained_forms.clear(); | 412 obtained_forms.clear(); |
413 request->NotifyConsumerWithResults(obtained_forms.Pass()); | 413 request->NotifyConsumerWithResults(std::move(obtained_forms)); |
414 } | 414 } |
415 | 415 |
416 void PasswordStore::NotifySiteStats(const GURL& origin_domain, | 416 void PasswordStore::NotifySiteStats(const GURL& origin_domain, |
417 scoped_ptr<GetLoginsRequest> request) { | 417 scoped_ptr<GetLoginsRequest> request) { |
418 request->NotifyWithSiteStatistics(GetSiteStatsImpl(origin_domain)); | 418 request->NotifyWithSiteStatistics(GetSiteStatsImpl(origin_domain)); |
419 } | 419 } |
420 | 420 |
421 void PasswordStore::GetLoginsWithAffiliationsImpl( | 421 void PasswordStore::GetLoginsWithAffiliationsImpl( |
422 const PasswordForm& form, | 422 const PasswordForm& form, |
423 AuthorizationPromptPolicy prompt_policy, | 423 AuthorizationPromptPolicy prompt_policy, |
(...skipping 10 matching lines...) Expand all Loading... |
434 for (PasswordForm* form : more_results) | 434 for (PasswordForm* form : more_results) |
435 form->is_affiliation_based_match = true; | 435 form->is_affiliation_based_match = true; |
436 ScopedVector<PasswordForm>::iterator it_first_federated = std::partition( | 436 ScopedVector<PasswordForm>::iterator it_first_federated = std::partition( |
437 more_results.begin(), more_results.end(), | 437 more_results.begin(), more_results.end(), |
438 [](PasswordForm* form) { return form->federation_url.is_empty(); }); | 438 [](PasswordForm* form) { return form->federation_url.is_empty(); }); |
439 more_results.erase(it_first_federated, more_results.end()); | 439 more_results.erase(it_first_federated, more_results.end()); |
440 password_manager_util::TrimUsernameOnlyCredentials(&more_results); | 440 password_manager_util::TrimUsernameOnlyCredentials(&more_results); |
441 results.insert(results.end(), more_results.begin(), more_results.end()); | 441 results.insert(results.end(), more_results.begin(), more_results.end()); |
442 more_results.weak_clear(); | 442 more_results.weak_clear(); |
443 } | 443 } |
444 request->NotifyConsumerWithResults(results.Pass()); | 444 request->NotifyConsumerWithResults(std::move(results)); |
445 } | 445 } |
446 | 446 |
447 void PasswordStore::ScheduleGetLoginsWithAffiliations( | 447 void PasswordStore::ScheduleGetLoginsWithAffiliations( |
448 const PasswordForm& form, | 448 const PasswordForm& form, |
449 AuthorizationPromptPolicy prompt_policy, | 449 AuthorizationPromptPolicy prompt_policy, |
450 scoped_ptr<GetLoginsRequest> request, | 450 scoped_ptr<GetLoginsRequest> request, |
451 const std::vector<std::string>& additional_android_realms) { | 451 const std::vector<std::string>& additional_android_realms) { |
452 ScheduleTask(base::Bind(&PasswordStore::GetLoginsWithAffiliationsImpl, this, | 452 ScheduleTask(base::Bind(&PasswordStore::GetLoginsWithAffiliationsImpl, this, |
453 form, prompt_policy, base::Passed(&request), | 453 form, prompt_policy, base::Passed(&request), |
454 additional_android_realms)); | 454 additional_android_realms)); |
455 } | 455 } |
456 | 456 |
457 scoped_ptr<PasswordForm> PasswordStore::GetLoginImpl( | 457 scoped_ptr<PasswordForm> PasswordStore::GetLoginImpl( |
458 const PasswordForm& primary_key) { | 458 const PasswordForm& primary_key) { |
459 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 459 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
460 ScopedVector<PasswordForm> candidates( | 460 ScopedVector<PasswordForm> candidates( |
461 FillMatchingLogins(primary_key, DISALLOW_PROMPT)); | 461 FillMatchingLogins(primary_key, DISALLOW_PROMPT)); |
462 for (PasswordForm*& candidate : candidates) { | 462 for (PasswordForm*& candidate : candidates) { |
463 if (ArePasswordFormUniqueKeyEqual(*candidate, primary_key) && | 463 if (ArePasswordFormUniqueKeyEqual(*candidate, primary_key) && |
464 !candidate->is_public_suffix_match) { | 464 !candidate->is_public_suffix_match) { |
465 scoped_ptr<PasswordForm> result(candidate); | 465 scoped_ptr<PasswordForm> result(candidate); |
466 candidate = nullptr; | 466 candidate = nullptr; |
467 return result.Pass(); | 467 return result; |
468 } | 468 } |
469 } | 469 } |
470 return make_scoped_ptr<PasswordForm>(nullptr); | 470 return make_scoped_ptr<PasswordForm>(nullptr); |
471 } | 471 } |
472 | 472 |
473 void PasswordStore::FindAndUpdateAffiliatedWebLogins( | 473 void PasswordStore::FindAndUpdateAffiliatedWebLogins( |
474 const PasswordForm& added_or_updated_android_form) { | 474 const PasswordForm& added_or_updated_android_form) { |
475 if (!affiliated_match_helper_ || | 475 if (!affiliated_match_helper_ || |
476 !is_propagating_password_changes_to_web_credentials_enabled_) { | 476 !is_propagating_password_changes_to_web_credentials_enabled_) { |
477 return; | 477 return; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 // TODO(ttr314@googlemail.com): Once crbug.com/113973 is done, remove default | 597 // TODO(ttr314@googlemail.com): Once crbug.com/113973 is done, remove default |
598 // implementation and mark method as pure virtual. | 598 // implementation and mark method as pure virtual. |
599 PasswordStoreChangeList PasswordStore::RemoveLoginsByOriginAndTimeImpl( | 599 PasswordStoreChangeList PasswordStore::RemoveLoginsByOriginAndTimeImpl( |
600 const url::Origin& origin, | 600 const url::Origin& origin, |
601 base::Time delete_begin, | 601 base::Time delete_begin, |
602 base::Time delete_end) { | 602 base::Time delete_end) { |
603 return PasswordStoreChangeList(); | 603 return PasswordStoreChangeList(); |
604 } | 604 } |
605 | 605 |
606 } // namespace password_manager | 606 } // namespace password_manager |
OLD | NEW |