Commit 62046aa7 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Introduce CompromisedCredentials::in_store

This is analogous to PasswordForm::in_store and reflects in which store
those credentials are stored.


Bug: 1108422
Change-Id: I1b60e2cc2725959342abf1a0d1dad9df09d10edd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364508Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799733}
parent 5b459ed8
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/util/type_safety/strong_alias.h" #include "base/util/type_safety/strong_alias.h"
#include "components/autofill/core/common/password_form.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace sql { namespace sql {
...@@ -47,6 +48,9 @@ struct CompromisedCredentials { ...@@ -47,6 +48,9 @@ struct CompromisedCredentials {
base::Time create_time; base::Time create_time;
// The type of the credentials that was compromised. // The type of the credentials that was compromised.
CompromiseType compromise_type = CompromiseType::kLeaked; CompromiseType compromise_type = CompromiseType::kLeaked;
// The store in which those credentials are stored.
autofill::PasswordForm::Store in_store =
autofill::PasswordForm::Store::kNotSet;
}; };
bool operator==(const CompromisedCredentials& lhs, bool operator==(const CompromisedCredentials& lhs,
......
...@@ -687,9 +687,8 @@ class PasswordStore : protected PasswordStoreSync, ...@@ -687,9 +687,8 @@ class PasswordStore : protected PasswordStoreSync,
using StatsResult = std::vector<InteractionsStats>; using StatsResult = std::vector<InteractionsStats>;
using StatsTask = base::OnceCallback<StatsResult()>; using StatsTask = base::OnceCallback<StatsResult()>;
using CompromisedCredentialsResult = std::vector<CompromisedCredentials>;
using CompromisedCredentialsTask = using CompromisedCredentialsTask =
base::OnceCallback<CompromisedCredentialsResult()>; base::OnceCallback<std::vector<CompromisedCredentials>()>;
// Called on the main thread after initialization is completed. // Called on the main thread after initialization is completed.
// |success| is true if initialization was successful. Sets the // |success| is true if initialization was successful. Sets the
......
...@@ -160,9 +160,8 @@ bool PasswordStoreDefault::RemoveStatisticsByOriginAndTimeImpl( ...@@ -160,9 +160,8 @@ bool PasswordStoreDefault::RemoveStatisticsByOriginAndTimeImpl(
const base::RepeatingCallback<bool(const GURL&)>& origin_filter, const base::RepeatingCallback<bool(const GURL&)>& origin_filter,
base::Time delete_begin, base::Time delete_begin,
base::Time delete_end) { base::Time delete_end) {
return login_db_ && return login_db_ && login_db_->stats_table().RemoveStatsByOriginAndTime(
login_db_->stats_table().RemoveStatsByOriginAndTime( origin_filter, delete_begin, delete_end);
origin_filter, delete_begin, delete_end);
} }
std::vector<std::unique_ptr<PasswordForm>> std::vector<std::unique_ptr<PasswordForm>>
...@@ -257,17 +256,31 @@ bool PasswordStoreDefault::RemoveCompromisedCredentialsImpl( ...@@ -257,17 +256,31 @@ bool PasswordStoreDefault::RemoveCompromisedCredentialsImpl(
std::vector<CompromisedCredentials> std::vector<CompromisedCredentials>
PasswordStoreDefault::GetAllCompromisedCredentialsImpl() { PasswordStoreDefault::GetAllCompromisedCredentialsImpl() {
DCHECK(background_task_runner()->RunsTasksInCurrentSequence()); DCHECK(background_task_runner()->RunsTasksInCurrentSequence());
return login_db_ ? login_db_->compromised_credentials_table().GetAllRows() std::vector<CompromisedCredentials> compromised_credentials =
: std::vector<CompromisedCredentials>(); login_db_ ? login_db_->compromised_credentials_table().GetAllRows()
: std::vector<CompromisedCredentials>();
PasswordForm::Store store = IsAccountStore()
? PasswordForm::Store::kAccountStore
: PasswordForm::Store::kProfileStore;
for (CompromisedCredentials& cred : compromised_credentials)
cred.in_store = store;
return compromised_credentials;
} }
std::vector<CompromisedCredentials> std::vector<CompromisedCredentials>
PasswordStoreDefault::GetMatchingCompromisedCredentialsImpl( PasswordStoreDefault::GetMatchingCompromisedCredentialsImpl(
const std::string& signon_realm) { const std::string& signon_realm) {
DCHECK(background_task_runner()->RunsTasksInCurrentSequence()); DCHECK(background_task_runner()->RunsTasksInCurrentSequence());
return login_db_ std::vector<CompromisedCredentials> compromised_credentials =
? login_db_->compromised_credentials_table().GetRows(signon_realm) login_db_
: std::vector<CompromisedCredentials>(); ? login_db_->compromised_credentials_table().GetRows(signon_realm)
: std::vector<CompromisedCredentials>();
PasswordForm::Store store = IsAccountStore()
? PasswordForm::Store::kAccountStore
: PasswordForm::Store::kProfileStore;
for (CompromisedCredentials& cred : compromised_credentials)
cred.in_store = store;
return compromised_credentials;
} }
bool PasswordStoreDefault::RemoveCompromisedCredentialsByUrlAndTimeImpl( bool PasswordStoreDefault::RemoveCompromisedCredentialsByUrlAndTimeImpl(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment