Commit 92651a33 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] CompromisedCredentialsReader in PostSaveCompromisedHelper

This patch doesn't introduce any behavioral change.

Bug: 1108422
Change-Id: I70121d37757774cb0f4eba5b10d7247d57419690
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375327
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804748}
parent 7bd535ed
...@@ -34,10 +34,16 @@ void PostSaveCompromisedHelper::AnalyzeLeakedCredentials( ...@@ -34,10 +34,16 @@ void PostSaveCompromisedHelper::AnalyzeLeakedCredentials(
DCHECK(prefs); DCHECK(prefs);
callback_ = std::move(callback); callback_ = std::move(callback);
prefs_ = prefs; prefs_ = prefs;
store->GetAllCompromisedCredentials(this); compromised_credentials_reader_ =
std::make_unique<CompromisedCredentialsReader>(store);
// Unretained(this) is safe here since `this` outlives
// `compromised_credentials_reader_`.
compromised_credentials_reader_->GetAllCompromisedCredentials(
base::BindOnce(&PostSaveCompromisedHelper::OnGetAllCompromisedCredentials,
base::Unretained(this)));
} }
void PostSaveCompromisedHelper::OnGetCompromisedCredentials( void PostSaveCompromisedHelper::OnGetAllCompromisedCredentials(
std::vector<CompromisedCredentials> compromised_credentials) { std::vector<CompromisedCredentials> compromised_credentials) {
const bool compromised_password_changed = const bool compromised_password_changed =
current_leak_ && !base::Contains(compromised_credentials, *current_leak_); current_leak_ && !base::Contains(compromised_credentials, *current_leak_);
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/password_manager/core/browser/compromised_credentials_consumer.h"
#include "components/password_manager/core/browser/compromised_credentials_table.h" #include "components/password_manager/core/browser/compromised_credentials_table.h"
#include "components/password_manager/core/browser/ui/compromised_credentials_reader.h"
class PrefService; class PrefService;
...@@ -20,7 +20,7 @@ namespace password_manager { ...@@ -20,7 +20,7 @@ namespace password_manager {
class PasswordStore; class PasswordStore;
// Helps to choose a compromised credential bubble after a password was saved. // Helps to choose a compromised credential bubble after a password was saved.
class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer { class PostSaveCompromisedHelper {
public: public:
enum class BubbleType { enum class BubbleType {
// No follow-up bubble should be shown. // No follow-up bubble should be shown.
...@@ -44,7 +44,7 @@ class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer { ...@@ -44,7 +44,7 @@ class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer {
PostSaveCompromisedHelper( PostSaveCompromisedHelper(
base::span<const CompromisedCredentials> compromised, base::span<const CompromisedCredentials> compromised,
const base::string16& current_username); const base::string16& current_username);
~PostSaveCompromisedHelper() override; ~PostSaveCompromisedHelper();
PostSaveCompromisedHelper(const PostSaveCompromisedHelper&) = delete; PostSaveCompromisedHelper(const PostSaveCompromisedHelper&) = delete;
PostSaveCompromisedHelper& operator=(const PostSaveCompromisedHelper&) = PostSaveCompromisedHelper& operator=(const PostSaveCompromisedHelper&) =
...@@ -60,8 +60,8 @@ class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer { ...@@ -60,8 +60,8 @@ class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer {
size_t compromised_count() const { return compromised_count_; } size_t compromised_count() const { return compromised_count_; }
private: private:
void OnGetCompromisedCredentials( void OnGetAllCompromisedCredentials(
std::vector<CompromisedCredentials> compromised_credentials) override; std::vector<CompromisedCredentials> compromised_credentials);
// Contains the entry for the currently leaked credentials if it was leaked. // Contains the entry for the currently leaked credentials if it was leaked.
base::Optional<CompromisedCredentials> current_leak_; base::Optional<CompromisedCredentials> current_leak_;
...@@ -73,6 +73,8 @@ class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer { ...@@ -73,6 +73,8 @@ class PostSaveCompromisedHelper : public CompromisedCredentialsConsumer {
BubbleType bubble_type_ = BubbleType::kNoBubble; BubbleType bubble_type_ = BubbleType::kNoBubble;
// Count of compromised credentials after the callback was executed. // Count of compromised credentials after the callback was executed.
size_t compromised_count_ = 0; size_t compromised_count_ = 0;
std::unique_ptr<CompromisedCredentialsReader> compromised_credentials_reader_;
}; };
} // namespace password_manager } // namespace password_manager
......
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