Skip to content

Commit

Permalink
[Passwords Grouping] Encapsulate grouping utils into a class
Browse files Browse the repository at this point in the history
This CL creates PasswordsGrouper class which encapsulates all the
passwords grouping logic. It allows to simplify testing and remove
cluttered code. This CL doesn't change current behavior.

Bug: 1354196
Change-Id: Ic1fce59203ae58dc5f88dfb920d483114720fdd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4231980
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1103863}
  • Loading branch information
Viktor Semeniuk authored and Chromium LUCI CQ committed Feb 10, 2023
1 parent d3cb2cb commit 99008c5
Show file tree
Hide file tree
Showing 11 changed files with 365 additions and 569 deletions.
6 changes: 3 additions & 3 deletions components/password_manager/core/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ static_library("browser") {
"ui/insecure_credentials_manager.h",
"ui/password_check_referrer.cc",
"ui/password_check_referrer.h",
"ui/password_grouping_util.cc",
"ui/password_grouping_util.h",
"ui/password_undo_helper.cc",
"ui/password_undo_helper.h",
"ui/passwords_grouper.cc",
"ui/passwords_grouper.h",
"ui/post_save_compromised_helper.cc",
"ui/post_save_compromised_helper.h",
"ui/saved_passwords_presenter.cc",
Expand Down Expand Up @@ -684,8 +684,8 @@ source_set("unit_tests") {
"ui/bulk_leak_check_service_adapter_unittest.cc",
"ui/credential_ui_entry_unittest.cc",
"ui/insecure_credentials_manager_unittest.cc",
"ui/password_grouping_util_unittest.cc",
"ui/password_undo_helper_unittest.cc",
"ui/passwords_grouper_unittest.cc",
"ui/post_save_compromised_helper_unittest.cc",
"ui/saved_passwords_presenter_unittest.cc",
"vote_uploads_test_matchers.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
namespace password_manager {

AffiliatedGroup::AffiliatedGroup() = default;
AffiliatedGroup::AffiliatedGroup(std::vector<CredentialUIEntry> credentials,
const FacetBrandingInfo& branding)
: branding_info_(branding), credential_groups_(std::move(credentials)) {}
AffiliatedGroup::AffiliatedGroup(const AffiliatedGroup& other) = default;
AffiliatedGroup::AffiliatedGroup(AffiliatedGroup&& other) = default;

AffiliatedGroup::~AffiliatedGroup() = default;

AffiliatedGroup& AffiliatedGroup::operator=(const AffiliatedGroup& other) =
default;

AffiliatedGroup& AffiliatedGroup::operator=(AffiliatedGroup&& other) = default;

void AffiliatedGroup::AddCredential(const CredentialUIEntry& credential) {
credential_groups_.insert(credential);
}

bool operator==(const AffiliatedGroup& lhs, const AffiliatedGroup& rhs) {
if (!base::ranges::equal(lhs.GetCredentials(), rhs.GetCredentials())) {
return false;
Expand Down
12 changes: 3 additions & 9 deletions components/password_manager/core/browser/ui/affiliated_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,20 @@ namespace password_manager {
class AffiliatedGroup {
public:
AffiliatedGroup();
AffiliatedGroup(std::vector<CredentialUIEntry> credentials,
const FacetBrandingInfo& branding);
AffiliatedGroup(const AffiliatedGroup& other);
AffiliatedGroup(AffiliatedGroup&& other);
AffiliatedGroup& operator=(const AffiliatedGroup& other);
AffiliatedGroup& operator=(AffiliatedGroup&& other);
~AffiliatedGroup();

// Method to add a credential to the credential group in order.
void AddCredential(const CredentialUIEntry& credential);

// Credential Groups Getter.
base::span<const CredentialUIEntry> GetCredentials() const {
return base::make_span(credential_groups_.begin(),
credential_groups_.end());
}

// Branding Info Setter.
void SetBrandingInfo(const FacetBrandingInfo& branding_info) {
branding_info_ = branding_info;
}

// Method that returns the display name for this affiliated group.
const std::string& GetDisplayName() const { return branding_info_.name; }

Expand All @@ -47,7 +41,7 @@ class AffiliatedGroup {
FacetBrandingInfo branding_info_;

// List of credential groups in the affiliated group.
base::flat_set<CredentialUIEntry> credential_groups_;
std::vector<CredentialUIEntry> credential_groups_;
};

bool operator==(const AffiliatedGroup& lhs, const AffiliatedGroup& rhs);
Expand Down

This file was deleted.

0 comments on commit 99008c5

Please sign in to comment.