diff --git a/browser/profiles/brave_profile_manager.cc b/browser/profiles/brave_profile_manager.cc index 47ca7520092..90ae5b62348 100644 --- a/browser/profiles/brave_profile_manager.cc +++ b/browser/profiles/brave_profile_manager.cc @@ -108,7 +108,6 @@ void RecordInitialP3AValues(Profile* profile) { BraveProfileManager::BraveProfileManager(const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { - MigrateProfileNames(); } size_t BraveProfileManager::GetNumberOfProfiles() { @@ -231,29 +230,6 @@ void BraveProfileManager::SetNonPersonalProfilePrefs(Profile* profile) { prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, false); } -void BraveProfileManager::MigrateProfileNames() { -#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS) - // If any profiles have a default name using an - // older version of the default name string format, - // then name it with the new default name string format. - // e.g. 'Person X' --> 'Profile X'. - ProfileAttributesStorage& storage = GetProfileAttributesStorage(); - std::vector entries = - storage.GetAllProfilesAttributesSortedByNameWithCheck(); - // Make sure we keep the numbering the same. - for (auto* entry : entries) { - // Rename the necessary profiles. Don't check for legacy names as profile - // info cache should have migrated them by now. - if (entry->IsUsingDefaultName() && - !storage.IsDefaultProfileName( - entry->GetName(), - /*include_check_for_legacy_profile_name=*/false)) { - entry->SetLocalProfileName(storage.ChooseNameForNewProfile(), - /*is_default_name=*/true); - } - } -#endif -} BraveProfileManagerWithoutInit::BraveProfileManagerWithoutInit( const base::FilePath& user_data_dir) diff --git a/browser/profiles/brave_profile_manager.h b/browser/profiles/brave_profile_manager.h index b8ab57a7b55..c93a6fb089d 100644 --- a/browser/profiles/brave_profile_manager.h +++ b/browser/profiles/brave_profile_manager.h @@ -27,8 +27,6 @@ class BraveProfileManager : public ProfileManager { void DoFinalInitForServices(Profile* profile, bool go_off_the_record) override; - private: - void MigrateProfileNames(); }; class BraveProfileManagerWithoutInit : public BraveProfileManager { diff --git a/browser/profiles/brave_profile_manager_browsertest.cc b/browser/profiles/brave_profile_manager_browsertest.cc index b0bd2889c2e..b8a3575a1e5 100644 --- a/browser/profiles/brave_profile_manager_browsertest.cc +++ b/browser/profiles/brave_profile_manager_browsertest.cc @@ -30,87 +30,10 @@ #include "chrome/test/base/ui_test_utils.h" #endif -namespace { - -struct TestProfileData { - std::u16string profile_name; - std::u16string profile_name_expected_after_migration; - bool force_default_name; - base::FilePath profile_path; -}; - -std::vector GetTestProfileData( - ProfileManager* profile_manager) { - const std::vector profile_data = { - {u"Person 1", u"Profile 1", true, - profile_manager->user_data_dir().Append( - profile_manager->GetInitialProfileDir())}, - {u"Person 2", u"Profile 2", true, - profile_manager->user_data_dir().Append( - FILE_PATH_LITERAL("testprofile2"))}, - {u"ZZCustom 3", u"ZZCustom 3", false, - profile_manager->user_data_dir().Append( - FILE_PATH_LITERAL("testprofile3"))}, - }; - return profile_data; -} - -} // namespace class BraveProfileManagerTest : public PlatformBrowserTest { }; -// Test that legacy profile names (Person X) that have -// not been user-modified are automatically renamed -// to brave profile names (Profile X). -IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest, - DISABLED_PRE_MigrateProfileNames) { - ProfileManager* profile_manager = g_browser_process->profile_manager(); - ProfileAttributesStorage& storage = - profile_manager->GetProfileAttributesStorage(); - auto profile_data = GetTestProfileData(profile_manager); - // Create profiles with old default name - // Two profiles with legacy default names, to check rename happens - // in correct order. - // One profile with a custom name to check that it is not renamed. - // First is the existing default profile. - ProfileAttributesEntry* entry1 = - storage.GetProfileAttributesWithPath(profile_data[0].profile_path); - ASSERT_NE(entry1, nullptr); - entry1->SetLocalProfileName(profile_data[0].profile_name, - profile_data[0].force_default_name); - // Rest are generated - for (auto& profile : profile_data) { - profiles::testing::CreateProfileSync(profile_manager, profile.profile_path); - ProfileAttributesEntry* entry = - storage.GetProfileAttributesWithPath(profile.profile_path); - ASSERT_NE(entry, nullptr); - entry->SetLocalProfileName(profile.profile_name, - profile.force_default_name); - } -} - -IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest, - DISABLED_MigrateProfileNames) { - ProfileManager* profile_manager = g_browser_process->profile_manager(); - ProfileAttributesStorage& storage = - profile_manager->GetProfileAttributesStorage(); - auto profile_data = GetTestProfileData(profile_manager); - auto entries = storage.GetAllProfilesAttributesSortedByNameWithCheck(); - // Verify we still have the expected number of profiles. - ASSERT_EQ(entries.size(), profile_data.size()); - // Order of items in entries and profile_data should be the same - // since we manually ensure profile_data is alphabetical. - for (size_t i = 0; i != entries.size(); i++) { - // Verify the names changed - ASSERT_EQ(entries[i]->GetName(), - profile_data[i].profile_name_expected_after_migration); - // Verify the path matches, i.e. it is the same profile that got the number - // that the profile had before migration, so we're sure that profile numbers - // aren't re-assigned. - ASSERT_EQ(entries[i]->GetPath(), profile_data[i].profile_path); - } -} // We use x86 builds on Android to run tests and rewards with ads // are off on x86 builds