[cr142][Android] More Android passwords stuff deleted
- kLoginDataForProfileFileName; - kLoginDataJournalForProfileFileName; - MaybeDeleteLoginDatabases. Chromim change: https://source.chromium.org/chromium/chromium/src/+/62fdf60f5e40bb6fc6bf31d292482c353be23dcc [passwords/android] Drop fallback deletion of downloaded CSV on startup UMA indicates this code path isn't exercised. Worst case, if the deletion fails, the CSV can be downloaded again. Unrelated to that: inline the code that deletes the LoginDatabase files in browser_prefs.cc and move it to the bottom of the file. This means the code will go away 1 year from now during browser_prefs clean-up, without requiring any additional clean-up password manager code. OBSOLETE_HISTOGRAM[PasswordManager.AccountLoginData.RemovalStatus]=The deletion is done unconditionally and does not need metrics anymore OBSOLETE_HISTOGRAM[PasswordManager.ProfileLoginData.RemovalStatus]=The deletion is done unconditionally and does not need metrics anymore OBSOLETE_HISTOGRAM[PasswordManager.UPM.AutoExportedCsvStartupDeletionSuccess]=The startup CSV deletion was removed Bug: 442347616 Change-Id: I5c18bdbb9cda6b37ae6f05540746bfb9cc4fe12c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6913683
This commit is contained in:
@@ -7,25 +7,13 @@ import("//build/config/android/rules.gni")
|
||||
|
||||
source_set("unit_tests") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"//chrome/browser/password_manager/android/mock_password_manager_util_bridge.cc",
|
||||
"//chrome/browser/password_manager/android/mock_password_manager_util_bridge.h",
|
||||
"brave_password_manager_android_util_unittest.cc",
|
||||
"password_ui_view_android_unittest.cc",
|
||||
]
|
||||
sources = [ "password_ui_view_android_unittest.cc" ]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//chrome/browser/password_manager/android:utils",
|
||||
"//chrome/test:test_support",
|
||||
"//components/password_manager/core/browser",
|
||||
"//components/password_manager/core/browser:password_manager_buildflags",
|
||||
"//components/password_manager/core/browser/export",
|
||||
"//components/password_manager/core/browser/features:password_features",
|
||||
"//components/prefs:test_support",
|
||||
"//components/sync/base",
|
||||
"//content/test:test_support",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
]
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/* Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/test/test_file_util.h"
|
||||
#include "chrome/browser/password_manager/android/mock_password_manager_util_bridge.h"
|
||||
#include "chrome/browser/password_manager/android/password_manager_android_util.h"
|
||||
#include "components/password_manager/core/browser/password_manager_buildflags.h"
|
||||
#include "components/password_manager/core/browser/password_manager_constants.h"
|
||||
#include "components/password_manager/core/browser/split_stores_and_local_upm.h"
|
||||
#include "components/password_manager/core/common/password_manager_pref_names.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/testing_pref_service.h"
|
||||
#include "components/sync/base/data_type.h"
|
||||
#include "components/sync/base/pref_names.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace password_manager_android_util {
|
||||
namespace {
|
||||
|
||||
class BravePasswordManagerAndroidUtilTest : public testing::Test {
|
||||
public:
|
||||
BravePasswordManagerAndroidUtilTest() {
|
||||
pref_service_.registry()->RegisterBooleanPref(
|
||||
password_manager::prefs::kCredentialsEnableService, false);
|
||||
pref_service_.registry()->RegisterBooleanPref(
|
||||
password_manager::prefs::kCredentialsEnableAutosignin, false);
|
||||
pref_service_.registry()->RegisterBooleanPref(
|
||||
syncer::prefs::internal::kSyncInitialSyncFeatureSetupComplete, false);
|
||||
pref_service_.registry()->RegisterBooleanPref(
|
||||
syncer::prefs::internal::kSyncKeepEverythingSynced, false);
|
||||
pref_service_.registry()->RegisterBooleanPref(
|
||||
base::StrCat(
|
||||
{syncer::prefs::internal::
|
||||
kSyncDataTypeStatusForSyncToSigninMigrationPrefix,
|
||||
".", syncer::DataTypeToStableLowerCaseString(syncer::PASSWORDS)}),
|
||||
false);
|
||||
|
||||
base::WriteFile(login_db_directory_.Append(
|
||||
password_manager::kLoginDataForProfileFileName),
|
||||
"");
|
||||
}
|
||||
|
||||
TestingPrefServiceSimple* pref_service() { return &pref_service_; }
|
||||
|
||||
const base::FilePath& login_db_directory() { return login_db_directory_; }
|
||||
|
||||
std::unique_ptr<MockPasswordManagerUtilBridge>
|
||||
GetMockBridgeWithBackendPresent() {
|
||||
auto mock_bridge = std::make_unique<MockPasswordManagerUtilBridge>();
|
||||
ON_CALL(*mock_bridge, IsInternalBackendPresent)
|
||||
.WillByDefault(testing::Return(true));
|
||||
return mock_bridge;
|
||||
}
|
||||
|
||||
private:
|
||||
TestingPrefServiceSimple pref_service_;
|
||||
const base::FilePath login_db_directory_ =
|
||||
base::CreateUniqueTempDirectoryScopedToTest();
|
||||
};
|
||||
|
||||
// We don't want password db to be deleted on Android
|
||||
// Based on DeletesLoginDataFilesAfterUnmigratedPasswordsExported
|
||||
TEST_F(BravePasswordManagerAndroidUtilTest, DoNotDeleteLoginDataFiles) {
|
||||
// Creating the login data files for testing.
|
||||
base::FilePath profile_db_path = login_db_directory().Append(
|
||||
password_manager::kLoginDataForProfileFileName);
|
||||
base::FilePath account_db_path = login_db_directory().Append(
|
||||
password_manager::kLoginDataForAccountFileName);
|
||||
base::FilePath profile_db_journal_path = login_db_directory().Append(
|
||||
password_manager::kLoginDataJournalForProfileFileName);
|
||||
base::FilePath account_db_journal_path = login_db_directory().Append(
|
||||
password_manager::kLoginDataJournalForAccountFileName);
|
||||
|
||||
base::WriteFile(profile_db_path, "Test content");
|
||||
base::WriteFile(account_db_path, "Test content");
|
||||
base::WriteFile(profile_db_journal_path, "Test content");
|
||||
base::WriteFile(account_db_journal_path, "Test content");
|
||||
|
||||
EXPECT_TRUE(PathExists(profile_db_path));
|
||||
EXPECT_TRUE(PathExists(account_db_path));
|
||||
EXPECT_TRUE(PathExists(profile_db_journal_path));
|
||||
EXPECT_TRUE(PathExists(account_db_journal_path));
|
||||
|
||||
MaybeDeleteLoginDatabases(pref_service(), login_db_directory(),
|
||||
GetMockBridgeWithBackendPresent());
|
||||
|
||||
EXPECT_TRUE(PathExists(profile_db_path));
|
||||
EXPECT_TRUE(PathExists(account_db_path));
|
||||
EXPECT_TRUE(PathExists(profile_db_journal_path));
|
||||
EXPECT_TRUE(PathExists(account_db_journal_path));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace password_manager_android_util
|
||||
@@ -1,26 +0,0 @@
|
||||
/* Copyright (c) 2025 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "chrome/browser/password_manager/android/password_manager_util_bridge_interface.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
|
||||
#define MaybeDeleteLoginDatabases MaybeDeleteLoginDatabases_ChromiumImpl
|
||||
|
||||
#include <chrome/browser/password_manager/android/password_manager_android_util.cc>
|
||||
|
||||
#undef MaybeDeleteLoginDatabases
|
||||
|
||||
namespace password_manager_android_util {
|
||||
|
||||
// Prevent any ability to delete passwords db on Android
|
||||
void MaybeDeleteLoginDatabases(
|
||||
PrefService* pref_service,
|
||||
const base::FilePath& login_db_directory,
|
||||
std::unique_ptr<PasswordManagerUtilBridgeInterface> util_bridge) {}
|
||||
|
||||
} // namespace password_manager_android_util
|
||||
Reference in New Issue
Block a user