Commit 8e8eb151 authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

[b4p/sign-out] Do not notify bubble for unsynced blacklists

Blacklists that are unsynced at the time a b4p user signs out should
not be offered for fallback saving in the profile store.

Bug: 1060132
Change-Id: Iac615a525e92f7c60055bfbd00957bb819b6c7bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250108Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Victor Vianna <victorvianna@google.com>
Cr-Commit-Position: refs/heads/master@{#779758}
parent a4a3a1a6
...@@ -817,7 +817,8 @@ void PasswordSyncBridge::ApplyStopSyncChanges( ...@@ -817,7 +817,8 @@ void PasswordSyncBridge::ApplyStopSyncChanges(
const autofill::PasswordForm& form = *primary_key_and_form.second; const autofill::PasswordForm& form = *primary_key_and_form.second;
password_store_changes.emplace_back(PasswordStoreChange::REMOVE, form, password_store_changes.emplace_back(PasswordStoreChange::REMOVE, form,
primary_key); primary_key);
if (unsynced_passwords_storage_keys.count(primary_key) != 0) { if (unsynced_passwords_storage_keys.count(primary_key) != 0 &&
!form.blacklisted_by_user) {
unsynced_logins_being_deleted.push_back(form); unsynced_logins_being_deleted.push_back(form);
} }
} }
......
...@@ -97,6 +97,14 @@ autofill::PasswordForm MakePasswordForm(const std::string& signon_realm) { ...@@ -97,6 +97,14 @@ autofill::PasswordForm MakePasswordForm(const std::string& signon_realm) {
return form; return form;
} }
autofill::PasswordForm MakeBlacklistedForm(const std::string& signon_realm) {
autofill::PasswordForm form;
form.url = GURL("http://www.origin.com");
form.signon_realm = signon_realm;
form.blacklisted_by_user = true;
return form;
}
// A mini database class the supports Add/Update/Remove functionality. It also // A mini database class the supports Add/Update/Remove functionality. It also
// supports an auto increment primary key that starts from 1. It will be used to // supports an auto increment primary key that starts from 1. It will be used to
// empower the MockPasswordStoreSync be forwarding all database calls to an // empower the MockPasswordStoreSync be forwarding all database calls to an
...@@ -902,12 +910,15 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotifyUnsyncedCredentialsIfAccountStore) { ...@@ -902,12 +910,15 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotifyUnsyncedCredentialsIfAccountStore) {
const std::string kPrimaryKeyUnsyncedCredentialStr = "1000"; const std::string kPrimaryKeyUnsyncedCredentialStr = "1000";
const std::string kPrimaryKeySyncedCredentialStr = "1001"; const std::string kPrimaryKeySyncedCredentialStr = "1001";
const std::string kPrimaryKeyUnsyncedDeletionStr = "1002"; const std::string kPrimaryKeyUnsyncedDeletionStr = "1002";
const std::string kPrimaryKeyUnsyncedBlacklistStr = "1003";
ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeyUnsyncedCredentialStr)) ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeyUnsyncedCredentialStr))
.WillByDefault(Return(true)); .WillByDefault(Return(true));
ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeySyncedCredentialStr)) ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeySyncedCredentialStr))
.WillByDefault(Return(false)); .WillByDefault(Return(false));
ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeyUnsyncedDeletionStr)) ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeyUnsyncedDeletionStr))
.WillByDefault(Return(true)); .WillByDefault(Return(true));
ON_CALL(mock_processor(), IsEntityUnsynced(kPrimaryKeyUnsyncedBlacklistStr))
.WillByDefault(Return(true));
sync_pb::EntityMetadata is_deletion_metadata; sync_pb::EntityMetadata is_deletion_metadata;
is_deletion_metadata.set_is_deleted(true); is_deletion_metadata.set_is_deleted(true);
...@@ -925,6 +936,9 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotifyUnsyncedCredentialsIfAccountStore) { ...@@ -925,6 +936,9 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotifyUnsyncedCredentialsIfAccountStore) {
batch->AddMetadata( batch->AddMetadata(
kPrimaryKeyUnsyncedDeletionStr, kPrimaryKeyUnsyncedDeletionStr,
std::make_unique<sync_pb::EntityMetadata>(is_deletion_metadata)); std::make_unique<sync_pb::EntityMetadata>(is_deletion_metadata));
batch->AddMetadata(kPrimaryKeyUnsyncedBlacklistStr,
std::make_unique<sync_pb::EntityMetadata>(
is_not_deletion_metadata));
return batch; return batch;
}); });
...@@ -932,15 +946,20 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotifyUnsyncedCredentialsIfAccountStore) { ...@@ -932,15 +946,20 @@ TEST_F(PasswordSyncBridgeTest, ShouldNotifyUnsyncedCredentialsIfAccountStore) {
// because the deletion is supposed to have already removed such form. // because the deletion is supposed to have already removed such form.
const int kPrimaryKeyUnsyncedCredential = 1000; const int kPrimaryKeyUnsyncedCredential = 1000;
const int kPrimaryKeySyncedCredential = 1001; const int kPrimaryKeySyncedCredential = 1001;
const int kPrimaryKeyUnsyncedBlacklist = 1003;
autofill::PasswordForm unsynced_credential = MakePasswordForm(kSignonRealm1); autofill::PasswordForm unsynced_credential = MakePasswordForm(kSignonRealm1);
autofill::PasswordForm synced_credential = MakePasswordForm(kSignonRealm2); autofill::PasswordForm synced_credential = MakePasswordForm(kSignonRealm2);
autofill::PasswordForm unsynced_blacklist =
MakeBlacklistedForm(kSignonRealm3);
fake_db()->AddLoginForPrimaryKey(kPrimaryKeyUnsyncedCredential, fake_db()->AddLoginForPrimaryKey(kPrimaryKeyUnsyncedCredential,
unsynced_credential); unsynced_credential);
fake_db()->AddLoginForPrimaryKey(kPrimaryKeySyncedCredential, fake_db()->AddLoginForPrimaryKey(kPrimaryKeySyncedCredential,
synced_credential); synced_credential);
fake_db()->AddLoginForPrimaryKey(kPrimaryKeyUnsyncedBlacklist,
unsynced_blacklist);
// The notification should only contain new credentials that are unsynced, // The notification should only contain new credentials that are unsynced,
// ignoring both synced ones and deletion entries. // ignoring both synced ones, deletion entries and blacklists.
EXPECT_CALL(*mock_password_store_sync(), EXPECT_CALL(*mock_password_store_sync(),
NotifyUnsyncedCredentialsWillBeDeleted( NotifyUnsyncedCredentialsWillBeDeleted(
UnorderedElementsAre(unsynced_credential))); UnorderedElementsAre(unsynced_credential)));
......
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