Skip to content

Commit

Permalink
Expose compromised credentials via PasswordFormManager.
Browse files Browse the repository at this point in the history
Bug: 1049200
Change-Id: I0c133925b1ce5ca0fb735ad4572036dd2dcdc50e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187576
Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766442}
  • Loading branch information
Vasilii Sukhanov authored and Commit Bot committed May 7, 2020
1 parent ae4402c commit 714d27d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 26 deletions.
Expand Up @@ -6,6 +6,7 @@
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_MOCK_PASSWORD_FORM_MANAGER_FOR_UI_H_

#include "base/macros.h"
#include "components/password_manager/core/browser/compromised_credentials_table.h"
#include "components/password_manager/core/browser/password_form_manager_for_ui.h"
#include "components/password_manager/core/browser/statistics_table.h"
#include "testing/gmock/include/gmock/gmock.h"
Expand All @@ -17,32 +18,51 @@ class MockPasswordFormManagerForUI : public PasswordFormManagerForUI {
MockPasswordFormManagerForUI();
~MockPasswordFormManagerForUI() override;

MOCK_CONST_METHOD0(GetOrigin, const GURL&());
MOCK_CONST_METHOD0(GetBestMatches,
const std::vector<const autofill::PasswordForm*>&());
MOCK_CONST_METHOD0(GetFederatedMatches,
std::vector<const autofill::PasswordForm*>());
MOCK_CONST_METHOD0(GetPendingCredentials, const autofill::PasswordForm&());
MOCK_CONST_METHOD0(GetCredentialSource, metrics_util::CredentialSourceType());
MOCK_METHOD0(GetMetricsRecorder, PasswordFormMetricsRecorder*());
MOCK_CONST_METHOD0(GetInteractionsStats,
base::span<const InteractionsStats>());
MOCK_CONST_METHOD0(IsBlacklisted, bool());
MOCK_CONST_METHOD0(IsMovableToAccountStore, bool());
MOCK_METHOD0(Save, void());
MOCK_METHOD1(Update,
void(const autofill::PasswordForm& credentials_to_update));
MOCK_METHOD1(OnUpdateUsernameFromPrompt,
void(const base::string16& new_username));
MOCK_METHOD1(OnUpdatePasswordFromPrompt,
void(const base::string16& new_password));
MOCK_METHOD0(OnNopeUpdateClicked, void());
MOCK_METHOD0(OnNeverClicked, void());
MOCK_METHOD1(OnNoInteraction, void(bool));
MOCK_METHOD0(PermanentlyBlacklist, void());
MOCK_METHOD0(OnPasswordsRevealed, void());
MOCK_METHOD0(MoveCredentialsToAccountStore, void());
MOCK_METHOD0(BlockMovingCredentialsToAccountStore, void());
MOCK_METHOD(const GURL&, GetOrigin, (), (const override));
MOCK_METHOD(const std::vector<const autofill::PasswordForm*>&,
GetBestMatches,
(),
(const override));
MOCK_METHOD(std::vector<const autofill::PasswordForm*>,
GetFederatedMatches,
(),
(const override));
MOCK_METHOD(const autofill::PasswordForm&,
GetPendingCredentials,
(),
(const override));
MOCK_METHOD(metrics_util::CredentialSourceType,
GetCredentialSource,
(),
(const override));
MOCK_METHOD(PasswordFormMetricsRecorder*, GetMetricsRecorder, (), (override));
MOCK_METHOD(base::span<const InteractionsStats>,
GetInteractionsStats,
(),
(const override));
MOCK_METHOD(base::span<const CompromisedCredentials>,
GetCompromisedCredentials,
(),
(const override));
MOCK_METHOD(bool, IsBlacklisted, (), (const override));
MOCK_METHOD(bool, IsMovableToAccountStore, (), (const override));
MOCK_METHOD(void, Save, (), (override));
MOCK_METHOD(void, Update, (const autofill::PasswordForm&), (override));
MOCK_METHOD(void,
OnUpdateUsernameFromPrompt,
(const base::string16&),
(override));
MOCK_METHOD(void,
OnUpdatePasswordFromPrompt,
(const base::string16&),
(override));
MOCK_METHOD(void, OnNopeUpdateClicked, (), (override));
MOCK_METHOD(void, OnNeverClicked, (), (override));
MOCK_METHOD(void, OnNoInteraction, (bool), (override));
MOCK_METHOD(void, PermanentlyBlacklist, (), (override));
MOCK_METHOD(void, OnPasswordsRevealed, (), (override));
MOCK_METHOD(void, MoveCredentialsToAccountStore, (), (override));
MOCK_METHOD(void, BlockMovingCredentialsToAccountStore, (), (override));

DISALLOW_COPY_AND_ASSIGN(MockPasswordFormManagerForUI);
};
Expand Down
Expand Up @@ -262,6 +262,11 @@ base::span<const InteractionsStats> PasswordFormManager::GetInteractionsStats()
return base::make_span(form_fetcher_->GetInteractionsStats());
}

base::span<const CompromisedCredentials>
PasswordFormManager::GetCompromisedCredentials() const {
return form_fetcher_->GetCompromisedCredentials();
}

bool PasswordFormManager::IsBlacklisted() const {
return form_fetcher_->IsBlacklisted() || newly_blacklisted_;
}
Expand Down
Expand Up @@ -144,6 +144,8 @@ class PasswordFormManager : public PasswordFormManagerForUI,
metrics_util::CredentialSourceType GetCredentialSource() const override;
PasswordFormMetricsRecorder* GetMetricsRecorder() override;
base::span<const InteractionsStats> GetInteractionsStats() const override;
base::span<const CompromisedCredentials> GetCompromisedCredentials()
const override;
bool IsBlacklisted() const override;
bool IsMovableToAccountStore() const override;

Expand Down
Expand Up @@ -18,6 +18,7 @@ struct PasswordForm;

namespace password_manager {

struct CompromisedCredentials;
struct InteractionsStats;
class PasswordFormMetricsRecorder;

Expand Down Expand Up @@ -55,6 +56,10 @@ class PasswordFormManagerForUI {
// Statistics for recent password bubble usage.
virtual base::span<const InteractionsStats> GetInteractionsStats() const = 0;

// List of compromised passwords for the current site.
virtual base::span<const CompromisedCredentials> GetCompromisedCredentials()
const = 0;

// Determines if the user opted to 'never remember' passwords for this form.
virtual bool IsBlacklisted() const = 0;

Expand Down
Expand Up @@ -50,6 +50,8 @@ class PasswordDataForUI : public PasswordFormManagerForUI {
metrics_util::CredentialSourceType GetCredentialSource() const override;
PasswordFormMetricsRecorder* GetMetricsRecorder() override;
base::span<const InteractionsStats> GetInteractionsStats() const override;
base::span<const CompromisedCredentials> GetCompromisedCredentials()
const override;
bool IsBlacklisted() const override;
bool IsMovableToAccountStore() const override;
void Save() override;
Expand Down Expand Up @@ -126,6 +128,11 @@ base::span<const InteractionsStats> PasswordDataForUI::GetInteractionsStats()
return {};
}

base::span<const CompromisedCredentials>
PasswordDataForUI::GetCompromisedCredentials() const {
return {};
}

bool PasswordDataForUI::IsBlacklisted() const {
// 'true' would suppress the bubble.
return false;
Expand Down

0 comments on commit 714d27d

Please sign in to comment.