Commit 7dd2ac40 authored by Christos Froussios's avatar Christos Froussios Committed by Commit Bot

[Password Manager] Restore UMA metric for how many linux users don't have encryption

The existing UMA uploads don't separate new profiles from existing
profiles which couldn't be migrated.

Bug: 950267
Change-Id: I0f8f823e843bd2127a71438c347031f6a7b23346
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720630
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Auto-Submit: Christos Froussios <cfroussios@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681348}
parent 341d33c3
...@@ -136,19 +136,19 @@ PasswordStoreChangeList PasswordStoreX::DisableAutoSignInForOriginsImpl( ...@@ -136,19 +136,19 @@ PasswordStoreChangeList PasswordStoreX::DisableAutoSignInForOriginsImpl(
std::vector<std::unique_ptr<PasswordForm>> PasswordStoreX::FillMatchingLogins( std::vector<std::unique_ptr<PasswordForm>> PasswordStoreX::FillMatchingLogins(
const FormDigest& form) { const FormDigest& form) {
CheckMigration(); CheckMigration();
return PasswordStoreDefault::FillMatchingLogins(form); return PasswordStoreDefault::FillMatchingLogins(form);
} }
bool PasswordStoreX::FillAutofillableLogins( bool PasswordStoreX::FillAutofillableLogins(
std::vector<std::unique_ptr<PasswordForm>>* forms) { std::vector<std::unique_ptr<PasswordForm>>* forms) {
CheckMigration(); CheckMigration();
return PasswordStoreDefault::FillAutofillableLogins(forms); return PasswordStoreDefault::FillAutofillableLogins(forms);
} }
bool PasswordStoreX::FillBlacklistLogins( bool PasswordStoreX::FillBlacklistLogins(
std::vector<std::unique_ptr<PasswordForm>>* forms) { std::vector<std::unique_ptr<PasswordForm>>* forms) {
CheckMigration(); CheckMigration();
return PasswordStoreDefault::FillBlacklistLogins(forms); return PasswordStoreDefault::FillBlacklistLogins(forms);
} }
void PasswordStoreX::CheckMigration() { void PasswordStoreX::CheckMigration() {
...@@ -165,13 +165,18 @@ void PasswordStoreX::CheckMigration() { ...@@ -165,13 +165,18 @@ void PasswordStoreX::CheckMigration() {
// it a completed migration. // it a completed migration.
if (login_db()->IsEmpty()) { if (login_db()->IsEmpty()) {
UpdateMigrationToLoginDBStep(LOGIN_DB_REPLACED); UpdateMigrationToLoginDBStep(LOGIN_DB_REPLACED);
return; } else {
// The migration hasn't completed yes. The records in the database aren't
// encrypted, so we must disable the encryption.
// TODO(crbug/950267): Handle users who have unencrypted entries in the
// database.
login_db()->disable_encryption();
UpdateMigrationToLoginDBStep(POSTPONED);
} }
// The migration hasn't completed yes. The records in the database aren't
// encrypted, so we must disable the encryption. base::UmaHistogramEnumeration(
// TODO(crbug/950267): Handle users who have unencrypted entries in the "PasswordManager.LinuxBackendMigration.AttemptResult",
// database. StepForMetrics(migration_to_login_db_step_));
login_db()->disable_encryption();
} }
void PasswordStoreX::UpdateMigrationToLoginDBStep(MigrationToLoginDBStep step) { void PasswordStoreX::UpdateMigrationToLoginDBStep(MigrationToLoginDBStep step) {
......
...@@ -99,6 +99,9 @@ class PasswordStoreXTest : public testing::Test { ...@@ -99,6 +99,9 @@ class PasswordStoreXTest : public testing::Test {
void WaitForPasswordStore() { task_environment_.RunUntilIdle(); } void WaitForPasswordStore() { task_environment_.RunUntilIdle(); }
protected:
base::HistogramTester histogram_tester_;
private: private:
TestingPrefServiceSimple fake_pref_service_; TestingPrefServiceSimple fake_pref_service_;
base::test::ScopedTaskEnvironment task_environment_; base::test::ScopedTaskEnvironment task_environment_;
...@@ -152,6 +155,10 @@ TEST_F(PasswordStoreXTest, MigrationCompleted) { ...@@ -152,6 +155,10 @@ TEST_F(PasswordStoreXTest, MigrationCompleted) {
// Password values don't match because they have been stored encrypted and // Password values don't match because they have been stored encrypted and
// read unencrypted. // read unencrypted.
EXPECT_NE(kPassword, base::UTF16ToUTF8(stored_forms[0]->password_value)); EXPECT_NE(kPassword, base::UTF16ToUTF8(stored_forms[0]->password_value));
EXPECT_THAT(migration_step_pref_.GetValue(),
PasswordStoreX::LOGIN_DB_REPLACED);
histogram_tester_.ExpectTotalCount(
"PasswordManager.LinuxBackendMigration.AttemptResult", 0);
} }
TEST_F(PasswordStoreXTest, MigrationNotAttemptedEmptyDB) { TEST_F(PasswordStoreXTest, MigrationNotAttemptedEmptyDB) {
...@@ -190,6 +197,11 @@ TEST_F(PasswordStoreXTest, MigrationNotAttemptedEmptyDB) { ...@@ -190,6 +197,11 @@ TEST_F(PasswordStoreXTest, MigrationNotAttemptedEmptyDB) {
// Password values don't match because they have been stored encrypted and // Password values don't match because they have been stored encrypted and
// read unencrypted. // read unencrypted.
EXPECT_NE(kPassword, base::UTF16ToUTF8(stored_forms[0]->password_value)); EXPECT_NE(kPassword, base::UTF16ToUTF8(stored_forms[0]->password_value));
EXPECT_THAT(migration_step_pref_.GetValue(),
PasswordStoreX::LOGIN_DB_REPLACED);
histogram_tester_.ExpectBucketCount(
"PasswordManager.LinuxBackendMigration.AttemptResult",
LinuxBackendMigrationStatus::kLoginDBReplaced, 1);
} }
TEST_F(PasswordStoreXTest, MigrationNotAttemptedNonEmptyDB) { TEST_F(PasswordStoreXTest, MigrationNotAttemptedNonEmptyDB) {
...@@ -202,6 +214,7 @@ TEST_F(PasswordStoreXTest, MigrationNotAttemptedNonEmptyDB) { ...@@ -202,6 +214,7 @@ TEST_F(PasswordStoreXTest, MigrationNotAttemptedNonEmptyDB) {
// Add existing credential into loginDB. // Add existing credential into loginDB.
auto login_db = std::make_unique<password_manager::LoginDatabase>( auto login_db = std::make_unique<password_manager::LoginDatabase>(
test_login_db_file_path()); test_login_db_file_path());
login_db->disable_encryption();
ASSERT_TRUE(login_db->Init()); ASSERT_TRUE(login_db->Init());
ignore_result(login_db->AddLogin(MakePasswordForm())); ignore_result(login_db->AddLogin(MakePasswordForm()));
login_db.reset(); login_db.reset();
...@@ -243,4 +256,8 @@ TEST_F(PasswordStoreXTest, MigrationNotAttemptedNonEmptyDB) { ...@@ -243,4 +256,8 @@ TEST_F(PasswordStoreXTest, MigrationNotAttemptedNonEmptyDB) {
EXPECT_EQ(kPassword, base::UTF16ToUTF8(stored_form->password_value)); EXPECT_EQ(kPassword, base::UTF16ToUTF8(stored_form->password_value));
} }
} }
EXPECT_THAT(migration_step_pref_.GetValue(), PasswordStoreX::POSTPONED);
histogram_tester_.ExpectBucketCount(
"PasswordManager.LinuxBackendMigration.AttemptResult",
LinuxBackendMigrationStatus::kPostponed, 1);
} }
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