Remove leftover lacros profile migration code [3/N].
Lacros profile migration is already gone in crrev.com/c/5904867.
This patch removes some code that were left but has no more use.
Bug: 361267995
Change-Id: I5485a87424a7c3023df7cbe1fe78b4fbb67351ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5937288
Reviewed-by: Hidehiko Abe <[email protected]>
Commit-Queue: Yuta Hijikata <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1373698}
diff --git a/chrome/browser/ash/crosapi/browser_manager.cc b/chrome/browser/ash/crosapi/browser_manager.cc
index 3eac03d..07730db 100644
--- a/chrome/browser/ash/crosapi/browser_manager.cc
+++ b/chrome/browser/ash/crosapi/browser_manager.cc
@@ -83,7 +83,6 @@
#include "chromeos/ash/components/standalone_browser/browser_support.h"
#include "chromeos/ash/components/standalone_browser/channel_util.h"
#include "chromeos/ash/components/standalone_browser/lacros_selection.h"
-#include "chromeos/ash/components/standalone_browser/migrator_util.h"
#include "chromeos/crosapi/cpp/crosapi_constants.h"
#include "chromeos/crosapi/cpp/lacros_startup_state.h"
#include "chromeos/crosapi/mojom/crosapi.mojom-shared.h"
@@ -127,10 +126,6 @@
const char kLacrosLaunchModeAndSourceDaily[] =
"Ash.Lacros.Launch.ModeAndSource.Daily";
-// Used to get field data on how much users have migrated to Lacros.
-const char kLacrosMigrationStatus[] = "Ash.LacrosMigrationStatus2";
-const char kLacrosMigrationStatusDaily[] = "Ash.LacrosMigrationStatus2.Daily";
-
// The interval at which the daily UMA reporting function should be
// called. De-duping of events will be happening on the server side.
constexpr base::TimeDelta kDailyLaunchModeTimeDelta = base::Minutes(30);
@@ -543,9 +538,8 @@
PrepareLacrosPolicies(this);
- // Perform the UMA recording for the current Lacros launch mode and migration
- // status.
- RecordLacrosLaunchModeAndMigrationStatus();
+ // Perform the UMA recording for the current Lacros launch mode.
+ RecordLacrosLaunchMode();
// As a switch between Ash and Lacros mode requires an Ash restart plus
// profile migration, the state will not change while the system is up.
@@ -956,9 +950,6 @@
if (state_ == State::NOT_INITIALIZED) {
InitializeAndStartIfNeeded();
}
-
- // If "Go to files" on the migration error page was clicked, launch it here.
- HandleGoToFiles();
}
void BrowserManager::OnStoreLoaded(policy::CloudPolicyStore* store) {
@@ -1014,11 +1005,6 @@
return;
}
- // Record data version for primary user profile.
- ash::standalone_browser::migrator_util::RecordDataVer(
- g_browser_process->local_state(), user.username_hash(),
- version_info::GetVersion());
-
// Check if Lacros is enabled for crash reporting. This must happen after the
// primary user has been set as priamry user state is used in when evaluating
// the correct value for IsLacrosEnabled().
@@ -1057,21 +1043,6 @@
}
}
-void BrowserManager::HandleGoToFiles() {
- // If "Go to files" on the migration error page was clicked, launch it here.
- Profile* profile = ProfileManager::GetPrimaryUserProfile();
- std::string user_id_hash =
- ash::BrowserContextHelper::GetUserIdHashFromBrowserContext(profile);
- if (browser_util::WasGotoFilesClicked(g_browser_process->local_state(),
- user_id_hash)) {
- files_app_launcher_ = std::make_unique<FilesAppLauncher>(
- apps::AppServiceProxyFactory::GetForProfile(profile));
- files_app_launcher_->Launch(base::BindOnce(
- browser_util::ClearGotoFilesClicked, g_browser_process->local_state(),
- std::move(user_id_hash)));
- }
-}
-
void BrowserManager::SetDeviceAccountPolicy(const std::string& policy_blob) {
if (browser_service_.has_value()) {
browser_service_->service->UpdateDeviceAccountPolicy(
@@ -1122,21 +1093,6 @@
browser_service_->service->UpdateKeepAlive(enabled);
}
-void BrowserManager::SetLacrosMigrationStatus() {
- const std::optional<browser_util::MigrationStatus> status =
- browser_util::GetMigrationStatus();
-
- if (!status.has_value()) {
- // This should only happen in tests.
- return;
- }
-
- CHECK(!migration_status_.has_value() || *migration_status_ == *status)
- << "Lacros migration status should not change in-session.";
-
- migration_status_ = status;
-}
-
void BrowserManager::SetLacrosLaunchMode() {
LacrosLaunchMode lacros_mode;
LacrosLaunchModeAndSource lacros_mode_and_source;
@@ -1188,30 +1144,19 @@
}
}
-void BrowserManager::RecordLacrosLaunchModeAndMigrationStatus() {
- SetLacrosMigrationStatus();
- if (!migration_status_.has_value()) {
- // `SetLacrosMigrationStatus()` does not set `migration_status_` if primary
- // user is not yet set at the time of calling (see
- // `browser_util::GetMigrationMode()` for details). This should only happen
- // in tests.
- CHECK_IS_TEST();
- return;
- }
+void BrowserManager::RecordLacrosLaunchMode() {
SetLacrosLaunchMode();
base::UmaHistogramEnumeration("Ash.Lacros.Launch.Mode", *lacros_mode_);
base::UmaHistogramEnumeration("Ash.Lacros.Launch.ModeAndSource",
*lacros_mode_and_source_);
- base::UmaHistogramEnumeration(kLacrosMigrationStatus, *migration_status_);
// Call our Daily reporting once now to make sure we have an event. If it's a
// dupe, the server will de-dupe.
- OnDailyLaunchModeAndMigrationStatusTimer();
+ OnDailyLaunchModeTimer();
if (!daily_event_timer_.IsRunning()) {
- daily_event_timer_.Start(
- FROM_HERE, kDailyLaunchModeTimeDelta, this,
- &BrowserManager::OnDailyLaunchModeAndMigrationStatusTimer);
+ daily_event_timer_.Start(FROM_HERE, kDailyLaunchModeTimeDelta, this,
+ &BrowserManager::OnDailyLaunchModeTimer);
}
}
@@ -1289,9 +1234,7 @@
}
// Callback called when the daily event happens.
-void BrowserManager::OnDailyLaunchModeAndMigrationStatusTimer() {
- base::UmaHistogramEnumeration(kLacrosMigrationStatusDaily,
- *migration_status_);
+void BrowserManager::OnDailyLaunchModeTimer() {
base::UmaHistogramEnumeration(kLacrosLaunchModeDaily, *lacros_mode_);
base::UmaHistogramEnumeration(kLacrosLaunchModeAndSourceDaily,
*lacros_mode_and_source_);
diff --git a/chrome/browser/ash/crosapi/browser_manager.h b/chrome/browser/ash/crosapi/browser_manager.h
index d718f156..55baabd 100644
--- a/chrome/browser/ash/crosapi/browser_manager.h
+++ b/chrome/browser/ash/crosapi/browser_manager.h
@@ -534,12 +534,9 @@
void OnActionPerformed(std::unique_ptr<BrowserAction> action, bool retry);
- // Remembers lacros launch mode and migration status by calling
- // `SetLacrosMigrationStatus()` and `SetLacrosLaunchMode()`, then kicks off
- // the daily reporting for the metrics.
- void RecordLacrosLaunchModeAndMigrationStatus();
- // Sets `migration_mode_`.
- void SetLacrosMigrationStatus();
+ // Remembers lacros launch mode by calling `SetLacrosLaunchMode()`, then kicks
+ // off the daily reporting for the metrics.
+ void RecordLacrosLaunchMode();
// Sets `lacros_mode_` and `lacros_mode_and_source_`.
void SetLacrosLaunchMode();
@@ -577,9 +574,6 @@
base::expected<BrowserLauncher::LaunchResults,
BrowserLauncher::LaunchFailureReason> launch_results);
- // Launch "Go to files" if the migration error page was clicked.
- void HandleGoToFiles();
-
// BrowserServiceHostObserver:
void OnBrowserRelaunchRequested(CrosapiId id) override;
@@ -636,9 +630,9 @@
// Creates windows from template data.
void RestoreWindowsFromTemplate();
- // Sending the LaunchMode and MigrationStatus state at least once a day.
+ // Sending the LaunchMode state at least once a day.
// multiple events will get de-duped on the server side.
- void OnDailyLaunchModeAndMigrationStatusTimer();
+ void OnDailyLaunchModeTimer();
void PerformAction(std::unique_ptr<BrowserAction> action);
@@ -721,8 +715,6 @@
// deciding if Lacros should be used or not.
std::optional<LacrosLaunchMode> lacros_mode_;
std::optional<LacrosLaunchModeAndSource> lacros_mode_and_source_;
- // The migration status used to emit UMA reports.
- std::optional<browser_util::MigrationStatus> migration_status_;
base::ScopedObservation<user_manager::UserManager,
user_manager::UserManager::Observer>
diff --git a/chrome/browser/ash/crosapi/browser_util.cc b/chrome/browser/ash/crosapi/browser_util.cc
index fa3b681..295b0b09 100644
--- a/chrome/browser/ash/crosapi/browser_util.cc
+++ b/chrome/browser/ash/crosapi/browser_util.cc
@@ -64,30 +64,10 @@
// result is stored in this variable which is used after that as a cache.
std::optional<LacrosAvailability> g_lacros_availability_cache;
-// At session start the value for LacrosDataBackwardMigrationMode logic is
-// applied and the result is stored in this variable which is used after that as
-// a cache.
-std::optional<LacrosDataBackwardMigrationMode>
- g_lacros_data_backward_migration_mode;
-
// The rootfs lacros-chrome metadata keys.
constexpr char kLacrosMetadataContentKey[] = "content";
constexpr char kLacrosMetadataVersionKey[] = "version";
-// The conversion map for LacrosDataBackwardMigrationMode policy data. The
-// values must match the ones from LacrosDataBackwardMigrationMode.yaml.
-constexpr auto kLacrosDataBackwardMigrationModeMap =
- base::MakeFixedFlatMap<std::string_view, LacrosDataBackwardMigrationMode>({
- {kLacrosDataBackwardMigrationModePolicyNone,
- LacrosDataBackwardMigrationMode::kNone},
- {kLacrosDataBackwardMigrationModePolicyKeepNone,
- LacrosDataBackwardMigrationMode::kKeepNone},
- {kLacrosDataBackwardMigrationModePolicyKeepSafeData,
- LacrosDataBackwardMigrationMode::kKeepSafeData},
- {kLacrosDataBackwardMigrationModePolicyKeepAll,
- LacrosDataBackwardMigrationMode::kKeepAll},
- });
-
// Returns primary user's User instance.
const user_manager::User* GetPrimaryUser() {
// TODO(crbug.com/40753373): TaskManagerImplTest is not ready to run with
@@ -121,77 +101,14 @@
return LacrosAvailability::kUserChoice;
}
-// Returns appropriate LacrosAvailability.
-std::optional<LacrosAvailability> GetLacrosAvailability(
- const user_manager::User* user,
- ash::standalone_browser::migrator_util::PolicyInitState policy_init_state) {
- auto* user_manager = user_manager::UserManager::Get();
- auto* primary_user = user_manager->GetPrimaryUser();
-
- switch (policy_init_state) {
- case ash::standalone_browser::migrator_util::PolicyInitState::kBeforeInit: {
- // If the value is needed before policy initialization, actually,
- // this should be the case where ash process was restarted, and so
- // the calculated value in the previous session should be carried
- // via command line flag.
- // See also LacrosAvailabilityPolicyObserver how it will be propergated.
-
- // Check whether given `user` is the one for kLoginUser.
- CHECK(!primary_user);
- const user_manager::CryptohomeId cryptohome_id(
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- ash::switches::kLoginUser));
- user_manager::KnownUser known_user(user_manager->GetLocalState());
- const AccountId login_account_id(
- known_user.GetAccountIdByCryptohomeId(cryptohome_id));
- if (user->GetAccountId() != login_account_id) {
- // TODO(b/40286020): Record log once the number of this call is
- // reduced.
- return std::nullopt;
- }
-
- return ash::standalone_browser::
- DetermineLacrosAvailabilityFromPolicyValue(
- user,
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- ash::standalone_browser::kLacrosAvailabilityPolicySwitch));
- }
- case ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit: {
- // If policy initialization is done, the calculated value should be
- // cached.
- CHECK(primary_user);
- if (primary_user != user) {
- // TODO(b/40286020): Record log once the number of this call is
- // reduced.
- return std::nullopt;
- }
- return GetCachedLacrosAvailability();
- }
- }
-}
-
} // namespace
const char kLaunchOnLoginPref[] = "lacros.launch_on_login";
-const char kProfileDataBackwardMigrationCompletedForUserPref[] =
- "lacros.profile_data_backward_migration_completed_for_user";
-// This pref is to record whether the user clicks "Go to files" button
-// on error page of the data migration.
-const char kGotoFilesPref[] = "lacros.goto_files";
-const char kProfileMigrationCompletionTimeForUserPref[] =
- "lacros.profile_migration_completion_time_for_user";
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kLaunchOnLoginPref, /*default_value=*/false);
}
-void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
- registry->RegisterDictionaryPref(
- kProfileDataBackwardMigrationCompletedForUserPref);
- registry->RegisterListPref(kGotoFilesPref);
- registry->RegisterDictionaryPref(kProfileMigrationCompletionTimeForUserPref);
-}
-
base::FilePath GetUserDataDir() {
if (base::SysInfo::IsRunningOnChromeOS()) {
// NOTE: On device this function is privacy/security sensitive. The
@@ -223,45 +140,6 @@
/*check_migration_status=*/true);
}
-bool IsLacrosEnabledForMigration(
- const User* user,
- ash::standalone_browser::migrator_util::PolicyInitState policy_init_state) {
- std::optional<LacrosAvailability> lacros_availability =
- GetLacrosAvailability(user, policy_init_state);
- if (!lacros_availability.has_value()) {
- return false;
- }
- return ash::standalone_browser::BrowserSupport::IsEnabledInternal(
- user, *lacros_availability, /*check_migration_status=*/false);
-}
-
-bool IsProfileMigrationEnabled(
- const user_manager::User* user,
- ash::standalone_browser::migrator_util::PolicyInitState policy_init_state) {
- return !base::FeatureList::IsEnabled(ash::standalone_browser::features::
- kLacrosProfileMigrationForceOff) &&
- IsLacrosEnabledForMigration(user, policy_init_state);
-}
-
-bool IsProfileMigrationAvailable() {
- auto* user_manager = UserManager::Get();
- auto* primary_user = user_manager->GetPrimaryUser();
- if (!IsProfileMigrationEnabled(primary_user,
- ash::standalone_browser::migrator_util::
- PolicyInitState::kAfterInit)) {
- return false;
- }
-
- // If migration is already completed, it is not necessary to run again.
- if (ash::standalone_browser::migrator_util::
- IsProfileMigrationCompletedForUser(user_manager->GetLocalState(),
- primary_user->username_hash())) {
- return false;
- }
-
- return true;
-}
-
bool IsAshWebBrowserEnabled() {
return !IsLacrosEnabled();
}
@@ -398,33 +276,10 @@
GetPrimaryUser(), value ? value->GetString() : std::string_view());
}
-void CacheLacrosDataBackwardMigrationMode(const policy::PolicyMap& map) {
- if (g_lacros_data_backward_migration_mode.has_value()) {
- // Some browser tests might call this multiple times.
- LOG(ERROR) << "Trying to cache LacrosDataBackwardMigrationMode and the "
- "value was set";
- return;
- }
-
- const base::Value* value = map.GetValue(
- policy::key::kLacrosDataBackwardMigrationMode, base::Value::Type::STRING);
- g_lacros_data_backward_migration_mode = ParseLacrosDataBackwardMigrationMode(
- value ? value->GetString() : std::string_view());
-}
-
LacrosAvailability GetCachedLacrosAvailabilityForTesting() {
return GetCachedLacrosAvailability();
}
-// Returns the cached value of the LacrosDataBackwardMigrationMode policy.
-LacrosDataBackwardMigrationMode GetCachedLacrosDataBackwardMigrationMode() {
- if (g_lacros_data_backward_migration_mode.has_value())
- return g_lacros_data_backward_migration_mode.value();
-
- // By default migration should be disabled.
- return LacrosDataBackwardMigrationMode::kNone;
-}
-
void SetLacrosLaunchSwitchSourceForTest(LacrosAvailability test_value) {
g_lacros_availability_cache = test_value;
}
@@ -433,110 +288,6 @@
g_lacros_availability_cache.reset();
}
-void ClearLacrosDataBackwardMigrationModeCacheForTest() {
- g_lacros_data_backward_migration_mode.reset();
-}
-
-std::optional<MigrationStatus> GetMigrationStatus() {
- PrefService* local_state = g_browser_process->local_state();
- if (!local_state) {
- // This can happen in tests.
- CHECK_IS_TEST();
- return std::nullopt;
- }
-
- const auto* user = GetPrimaryUser();
- if (!user) {
- // The function is intended to be run after primary user is initialized.
- // The function might be run in tests without primary user being set.
- CHECK_IS_TEST();
- return std::nullopt;
- }
-
- return GetMigrationStatusForUser(local_state, user);
-}
-
-MigrationStatus GetMigrationStatusForUser(PrefService* local_state,
- const user_manager::User* user) {
- if (!crosapi::browser_util::IsLacrosEnabledForMigration(
- user, ash::standalone_browser::migrator_util::PolicyInitState::
- kAfterInit)) {
- return MigrationStatus::kLacrosNotEnabled;
- }
-
- std::optional<ash::standalone_browser::migrator_util::MigrationMode> mode =
- ash::standalone_browser::migrator_util::GetCompletedMigrationMode(
- local_state, user->username_hash());
-
- if (!mode.has_value()) {
- if (ash::standalone_browser::migrator_util::
- IsMigrationAttemptLimitReachedForUser(local_state,
- user->username_hash())) {
- return MigrationStatus::kMaxAttemptReached;
- }
-
- return MigrationStatus::kUncompleted;
- }
-
- switch (mode.value()) {
- case ash::standalone_browser::migrator_util::MigrationMode::kCopy:
- return MigrationStatus::kCopyCompleted;
- case ash::standalone_browser::migrator_util::MigrationMode::kMove:
- return MigrationStatus::kMoveCompleted;
- case ash::standalone_browser::migrator_util::MigrationMode::kSkipForNewUser:
- return MigrationStatus::kSkippedForNewUser;
- }
-}
-
-void SetProfileMigrationCompletionTimeForUser(PrefService* local_state,
- const std::string& user_id_hash) {
- ScopedDictPrefUpdate update(local_state,
- kProfileMigrationCompletionTimeForUserPref);
- update->Set(user_id_hash, base::TimeToValue(base::Time::Now()));
-}
-
-std::optional<base::Time> GetProfileMigrationCompletionTimeForUser(
- PrefService* local_state,
- const std::string& user_id_hash) {
- const auto* pref =
- local_state->FindPreference(kProfileMigrationCompletionTimeForUserPref);
-
- if (!pref) {
- return std::nullopt;
- }
-
- const base::Value* value = pref->GetValue();
- DCHECK(value->is_dict());
-
- return base::ValueToTime(value->GetDict().Find(user_id_hash));
-}
-
-void ClearProfileMigrationCompletionTimeForUser(
- PrefService* local_state,
- const std::string& user_id_hash) {
- ScopedDictPrefUpdate update(local_state,
- kProfileMigrationCompletionTimeForUserPref);
- base::Value::Dict& dict = update.Get();
- dict.Remove(user_id_hash);
-}
-
-void SetProfileDataBackwardMigrationCompletedForUser(
- PrefService* local_state,
- const std::string& user_id_hash) {
- ScopedDictPrefUpdate update(
- local_state, kProfileDataBackwardMigrationCompletedForUserPref);
- update->Set(user_id_hash, true);
-}
-
-void ClearProfileDataBackwardMigrationCompletedForUser(
- PrefService* local_state,
- const std::string& user_id_hash) {
- ScopedDictPrefUpdate update(
- local_state, kProfileDataBackwardMigrationCompletedForUserPref);
- base::Value::Dict& dict = update.Get();
- dict.Remove(user_id_hash);
-}
-
LacrosLaunchSwitchSource GetLacrosLaunchSwitchSource() {
if (!g_lacros_availability_cache.has_value())
return LacrosLaunchSwitchSource::kUnknown;
@@ -554,30 +305,6 @@
: LacrosLaunchSwitchSource::kForcedByPolicy;
}
-std::optional<LacrosDataBackwardMigrationMode>
-ParseLacrosDataBackwardMigrationMode(std::string_view value) {
- auto it = kLacrosDataBackwardMigrationModeMap.find(value);
- if (it != kLacrosDataBackwardMigrationModeMap.end())
- return it->second;
-
- if (!value.empty()) {
- LOG(ERROR) << "Unknown LacrosDataBackwardMigrationMode policy value: "
- << value;
- }
- return std::nullopt;
-}
-
-std::string_view GetLacrosDataBackwardMigrationModeName(
- LacrosDataBackwardMigrationMode value) {
- for (const auto& entry : kLacrosDataBackwardMigrationModeMap) {
- if (entry.second == value)
- return entry.first;
- }
-
- NOTREACHED_IN_MIGRATION();
- return std::string_view();
-}
-
bool IsAshBrowserSyncEnabled() {
// Turn off sync from Ash if Lacros is enabled and Ash web browser is
// disabled.
@@ -587,27 +314,6 @@
return true;
}
-void SetGotoFilesClicked(PrefService* local_state,
- const std::string& user_id_hash) {
- ScopedListPrefUpdate update(local_state, kGotoFilesPref);
- base::Value::List& list = update.Get();
- base::Value user_id_hash_value(user_id_hash);
- if (!base::Contains(list, user_id_hash_value))
- list.Append(std::move(user_id_hash_value));
-}
-
-void ClearGotoFilesClicked(PrefService* local_state,
- const std::string& user_id_hash) {
- ScopedListPrefUpdate update(local_state, kGotoFilesPref);
- update->EraseValue(base::Value(user_id_hash));
-}
-
-bool WasGotoFilesClicked(PrefService* local_state,
- const std::string& user_id_hash) {
- const base::Value::List& list = local_state->GetList(kGotoFilesPref);
- return base::Contains(list, base::Value(user_id_hash));
-}
-
bool ShouldEnforceAshExtensionKeepList() {
return IsLacrosEnabled() && base::FeatureList::IsEnabled(
ash::features::kEnforceAshExtensionKeeplist);
diff --git a/chrome/browser/ash/crosapi/browser_util.h b/chrome/browser/ash/crosapi/browser_util.h
index 95f4e721..d64da023 100644
--- a/chrome/browser/ash/crosapi/browser_util.h
+++ b/chrome/browser/ash/crosapi/browser_util.h
@@ -5,10 +5,6 @@
#ifndef CHROME_BROWSER_ASH_CROSAPI_BROWSER_UTIL_H_
#define CHROME_BROWSER_ASH_CROSAPI_BROWSER_UTIL_H_
-#include <optional>
-#include <string>
-#include <string_view>
-
#include "base/auto_reset.h"
#include "base/feature_list.h"
#include "base/time/time.h"
@@ -16,7 +12,6 @@
#include "chromeos/ash/components/standalone_browser/lacros_selection.h"
class PrefRegistrySimple;
-class PrefService;
namespace ash::standalone_browser::migrator_util {
enum class PolicyInitState;
@@ -134,9 +129,6 @@
// Registers user profile preferences related to the lacros-chrome binary.
void RegisterProfilePrefs(PrefRegistrySimple* registry);
-// Registers prefs used via local state PrefService.
-void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
-
// Returns the user directory for lacros-chrome.
base::FilePath GetUserDataDir();
@@ -147,14 +139,6 @@
// Returns true if the Lacros feature is enabled for the primary user.
bool IsLacrosEnabled();
-// Similar to `IsLacrosEnabled()` but does not check if profile migration has
-// been completed. This is to be used inside `BrowserDataMigrator`. Unlike
-// `IsLacrosEnabled()` it can be called before the primary user profile is
-// created.
-bool IsLacrosEnabledForMigration(
- const user_manager::User* user,
- ash::standalone_browser::migrator_util::PolicyInitState policy_init_state);
-
// Returns true if Ash browser is enabled. Returns false iff Lacros is
// enabled and is the only browser.
// DEPRECATED. Please use !IsLacrosEnabled().
@@ -202,10 +186,6 @@
// availability.
void CacheLacrosAvailability(const policy::PolicyMap& map);
-// To be called at primary user login, to cache the policy value for the
-// LacrosDataBackwardMigrationMode policy.
-void CacheLacrosDataBackwardMigrationMode(const policy::PolicyMap& map);
-
// Returns the lacros ComponentInfo for a given channel.
ComponentInfo GetLacrosComponentInfoForChannel(version_info::Channel channel);
@@ -231,60 +211,9 @@
ash::standalone_browser::LacrosAvailability
GetCachedLacrosAvailabilityForTesting();
-// GetCachedLacrosDataBackwardMigrationMode returns the cached value of the
-// LacrosDataBackwardMigrationMode policy.
-LacrosDataBackwardMigrationMode GetCachedLacrosDataBackwardMigrationMode();
-
// Clears the cached values for lacros availability policy.
void ClearLacrosAvailabilityCacheForTest();
-// Clears the cached value for LacrosDataBackwardMigrationMode.
-void ClearLacrosDataBackwardMigrationModeCacheForTest();
-
-// Returns true if profile migraiton is enabled. If profile migration is
-// enabled, the completion of it is required to enable Lacros.
-bool IsProfileMigrationEnabled(
- const user_manager::User* user,
- ash::standalone_browser::migrator_util::PolicyInitState policy_init_state);
-
-// Returns true if the profile migration is enabled, but not yet completed.
-bool IsProfileMigrationAvailable();
-
-// Returns migration status for the primary user. Returns nullopt if the primary
-// user is not yet set, which should only happen in tests.
-std::optional<MigrationStatus> GetMigrationStatus();
-MigrationStatus GetMigrationStatusForUser(PrefService* local_state,
- const user_manager::User* user);
-
-// Sets the value of `kProfileMigrationCompletionTimeForUserPref` for the user
-// identified by `user_id_hash` to the current time.
-void SetProfileMigrationCompletionTimeForUser(PrefService* local_state,
- const std::string& user_id_hash);
-
-// Gets the value of `kProfileMigrationCompletionTimeForUserPref` for the user
-// identified by `user_id_hash`.
-std::optional<base::Time> GetProfileMigrationCompletionTimeForUser(
- PrefService* local_state,
- const std::string& user_id_hash);
-
-// Clears the value of `kProfileMigrationCompletionTimeForUserPref` for the user
-// identified by `user_id_hash`.
-void ClearProfileMigrationCompletionTimeForUser(
- PrefService* local_state,
- const std::string& user_id_hash);
-
-// Sets the value of `kProfileDataBackwardMigrationCompletedForUserPref` for the
-// user identified by `user_id_hash`.
-void SetProfileDataBackwardMigrationCompletedForUser(
- PrefService* local_state,
- const std::string& user_id_hash);
-
-// Clears the value of `kProfileDataBackwardMigrationCompletedForUserPref` for
-// the user identified by `user_id_hash`.
-void ClearProfileDataBackwardMigrationCompletedForUser(
- PrefService* local_state,
- const std::string& user_id_hash);
-
// Indicate whether sync on Ash should be enabled for browser data. Sync should
// stop syncing browser items from Ash if Lacros is enabled and once browser
// data is migrated to Lacros making it safe to turn off web browser on
@@ -301,28 +230,6 @@
void SetLacrosLaunchSwitchSourceForTest(
ash::standalone_browser::LacrosAvailability test_value);
-// Parses the string representation of LacrosDataBackwardMigrationMode policy
-// value into the enum value. Returns nullopt on unknown value.
-std::optional<LacrosDataBackwardMigrationMode>
-ParseLacrosDataBackwardMigrationMode(std::string_view value);
-
-// Returns the policy string representation from the given enum value.
-std::string_view GetLacrosDataBackwardMigrationModeName(
- LacrosDataBackwardMigrationMode value);
-
-// Stores that "Go to files button" on the migration error screen is clicked.
-void SetGotoFilesClicked(PrefService* local_state,
- const std::string& user_id_hash);
-
-// Forgets that "Go to files button" on the migration error screen was clicked.
-void ClearGotoFilesClicked(PrefService* local_state,
- const std::string& user_id_hash);
-
-// Returns true if "Go to files button" on the migration error screen was
-// clicked.
-bool WasGotoFilesClicked(PrefService* local_state,
- const std::string& user_id_hash);
-
// Returns true if ash 1st party extension keep list should be enforced.
bool ShouldEnforceAshExtensionKeepList();
diff --git a/chrome/browser/ash/crosapi/browser_util_unittest.cc b/chrome/browser/ash/crosapi/browser_util_unittest.cc
index b774ccb..d60c6343 100644
--- a/chrome/browser/ash/crosapi/browser_util_unittest.cc
+++ b/chrome/browser/ash/crosapi/browser_util_unittest.cc
@@ -144,86 +144,6 @@
EXPECT_TRUE(browser_util::IsLacrosAllowedToBeEnabled());
}
-TEST_F(BrowserUtilTest, LacrosDisabledWithoutMigration) {
- const user_manager::User* const user = AddRegularUser("[email protected]");
-
- // Lacros is enabled only after profile migration for LacrosOnly mode.
- {
- base::test::ScopedCommandLine command_line;
- command_line.GetProcessCommandLine()->AppendSwitch(
- ash::switches::kEnableLacrosForTesting);
-
- EXPECT_TRUE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
- // Since profile migration hasn't been marked as completed, this returns
- // false.
- EXPECT_FALSE(browser_util::IsLacrosEnabled());
-
- ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
- local_state(), user->username_hash(),
- ash::standalone_browser::migrator_util::MigrationMode::kCopy);
-
- EXPECT_TRUE(browser_util::IsLacrosEnabled());
- }
-}
-
-TEST_F(BrowserUtilTest, IsLacrosEnabledForMigrationBeforePolicyInit) {
- constexpr char kUserEmail[] = "[email protected]";
- const user_manager::User* const user =
- AddRegularUser(kUserEmail, /*login=*/false);
-
- // Lacros is not enabled yet for profile migration to happen.
- EXPECT_FALSE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kBeforeInit));
-
- // Sets command line flag to emulate the situation where the Chrome
- // restart happens.
- base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
- cmdline->AppendSwitchASCII(
- ash::standalone_browser::kLacrosAvailabilityPolicySwitch,
- ash::standalone_browser::kLacrosAvailabilityPolicyLacrosOnly);
- cmdline->AppendSwitchASCII(ash::switches::kLoginUser, kUserEmail);
-
- // Policy should not enable Lacros anymore.
- EXPECT_FALSE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kBeforeInit));
-}
-
-TEST_F(BrowserUtilTest, LacrosEnabled) {
- const user_manager::User* const user = AddRegularUser("[email protected]");
- ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
- local_state(), user->username_hash(),
- ash::standalone_browser::migrator_util::MigrationMode::kMove);
-
- EXPECT_FALSE(browser_util::IsLacrosEnabled());
-
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kEnableLacrosForTesting);
- EXPECT_TRUE(browser_util::IsLacrosEnabled());
-}
-
-TEST_F(BrowserUtilTest, ManagedAccountLacros) {
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kEnableLacrosForTesting);
- const user_manager::User* const user =
- AddRegularUser("[email protected]");
- ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
- local_state(), user->username_hash(),
- ash::standalone_browser::migrator_util::MigrationMode::kMove);
-
- {
- ScopedLacrosAvailabilityCache cache(LacrosAvailability::kLacrosDisallowed);
- EXPECT_FALSE(browser_util::IsLacrosEnabled());
- }
- {
- ScopedLacrosAvailabilityCache cache(LacrosAvailability::kLacrosOnly);
- EXPECT_TRUE(browser_util::IsLacrosEnabled());
- }
-}
-
TEST_F(BrowserUtilTest, BlockedForChildUser) {
AccountId account_id = AccountId::FromUserEmail("[email protected]");
const User* user = fake_user_manager_->AddChildUser(account_id);
@@ -250,9 +170,6 @@
EXPECT_FALSE(browser_util::IsLacrosAllowedToBeEnabled());
EXPECT_FALSE(browser_util::IsLacrosEnabled());
EXPECT_TRUE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_FALSE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
// Lacros is allowed but not enabled.
@@ -262,9 +179,6 @@
EXPECT_TRUE(browser_util::IsLacrosAllowedToBeEnabled());
EXPECT_FALSE(browser_util::IsLacrosEnabled());
EXPECT_TRUE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_FALSE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
// Lacros is allowed and enabled by flag.
@@ -277,9 +191,6 @@
EXPECT_TRUE(browser_util::IsLacrosAllowedToBeEnabled());
EXPECT_TRUE(browser_util::IsLacrosEnabled());
EXPECT_FALSE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_TRUE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
// Lacros cannot be enabled via policy.
@@ -289,9 +200,6 @@
EXPECT_TRUE(browser_util::IsLacrosAllowedToBeEnabled());
EXPECT_FALSE(browser_util::IsLacrosEnabled());
EXPECT_TRUE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_FALSE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
}
@@ -306,9 +214,6 @@
// Lacros cannot be enabled via policy.
EXPECT_FALSE(browser_util::IsLacrosEnabled());
EXPECT_TRUE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_FALSE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
TEST_F(BrowserUtilTest, IsAshWebBrowserDisabledByFlags) {
@@ -321,9 +226,6 @@
base::CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kEnableLacrosForTesting);
EXPECT_FALSE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_TRUE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
TEST_F(BrowserUtilTest, LacrosOnlyBrowserByFlags) {
@@ -494,78 +396,6 @@
EXPECT_FALSE(browser_util::GetRootfsLacrosVersionMayBlock(path).IsValid());
}
-TEST_F(BrowserUtilTest, GetMigrationStatusForUser) {
- using ash::standalone_browser::migrator_util::MigrationMode;
- using browser_util::GetMigrationStatusForUser;
- using browser_util::MigrationStatus;
-
- const user_manager::User* const user = AddRegularUser("[email protected]");
-
- EXPECT_EQ(GetMigrationStatusForUser(local_state(), user),
- MigrationStatus::kLacrosNotEnabled);
-
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kEnableLacrosForTesting);
-
- EXPECT_EQ(GetMigrationStatusForUser(local_state(), user),
- MigrationStatus::kUncompleted);
-
- {
- for (int i = 0;
- i < ash::standalone_browser::migrator_util::kMaxMigrationAttemptCount;
- i++) {
- ash::standalone_browser::migrator_util::
- UpdateMigrationAttemptCountForUser(local_state(),
- user->username_hash());
- }
-
- EXPECT_EQ(GetMigrationStatusForUser(local_state(), user),
- MigrationStatus::kMaxAttemptReached);
-
- ash::standalone_browser::migrator_util::ClearMigrationAttemptCountForUser(
- local_state(), user->username_hash());
- }
-
- {
- ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
- local_state(), user->username_hash(),
- ash::standalone_browser::migrator_util::MigrationMode::kCopy);
-
- EXPECT_EQ(GetMigrationStatusForUser(local_state(), user),
- MigrationStatus::kCopyCompleted);
-
- ash::standalone_browser::migrator_util::
- ClearProfileMigrationCompletedForUser(local_state(),
- user->username_hash());
- }
-
- {
- ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
- local_state(), user->username_hash(),
- ash::standalone_browser::migrator_util::MigrationMode::kMove);
-
- EXPECT_EQ(GetMigrationStatusForUser(local_state(), user),
- MigrationStatus::kMoveCompleted);
-
- ash::standalone_browser::migrator_util::
- ClearProfileMigrationCompletedForUser(local_state(),
- user->username_hash());
- }
-
- {
- ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
- local_state(), user->username_hash(),
- ash::standalone_browser::migrator_util::MigrationMode::kSkipForNewUser);
-
- EXPECT_EQ(GetMigrationStatusForUser(local_state(), user),
- MigrationStatus::kSkippedForNewUser);
-
- ash::standalone_browser::migrator_util::
- ClearProfileMigrationCompletedForUser(local_state(),
- user->username_hash());
- }
-}
-
TEST_F(BrowserUtilTest, IsAshBrowserSyncEnabled) {
const user_manager::User* const user = AddRegularUser("[email protected]");
ash::standalone_browser::migrator_util::SetProfileMigrationCompletedForUser(
@@ -720,9 +550,6 @@
EXPECT_TRUE(browser_util::IsLacrosAllowedToBeEnabled());
EXPECT_TRUE(browser_util::IsLacrosEnabled());
EXPECT_FALSE(browser_util::IsAshWebBrowserEnabled());
- EXPECT_TRUE(browser_util::IsLacrosEnabledForMigration(
- user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
}
} // namespace crosapi
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 2319a2e..ae975df 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -367,7 +367,6 @@
#include "chrome/browser/ash/child_accounts/screen_time_controller.h"
#include "chrome/browser/ash/child_accounts/time_limits/app_activity_registry.h"
#include "chrome/browser/ash/child_accounts/time_limits/app_time_controller.h"
-#include "chrome/browser/ash/crosapi/browser_util.h"
#include "chrome/browser/ash/crostini/crostini_pref_names.h"
#include "chrome/browser/ash/cryptauth/client_app_metadata_provider_service.h"
#include "chrome/browser/ash/cryptauth/cryptauth_device_id_provider_impl.h"
@@ -1095,6 +1094,11 @@
"lacros.profile_move_migration_completed_for_user";
constexpr char kProfileMigrationCompletedForNewUserPref[] =
"lacros.profile_migration_completed_for_new_user";
+const char kProfileDataBackwardMigrationCompletedForUserPref[] =
+ "lacros.profile_data_backward_migration_completed_for_user";
+const char kGotoFilesPref[] = "lacros.goto_files";
+const char kProfileMigrationCompletionTimeForUserPref[] =
+ "lacros.profile_migration_completion_time_for_user";
#endif
#if !BUILDFLAG(IS_ANDROID)
@@ -1219,6 +1223,10 @@
registry->RegisterDictionaryPref(kProfileMigrationCompletedForUserPref);
registry->RegisterDictionaryPref(kProfileMoveMigrationCompletedForUserPref);
registry->RegisterDictionaryPref(kProfileMigrationCompletedForNewUserPref);
+ registry->RegisterDictionaryPref(
+ kProfileDataBackwardMigrationCompletedForUserPref);
+ registry->RegisterListPref(kGotoFilesPref);
+ registry->RegisterDictionaryPref(kProfileMigrationCompletionTimeForUserPref);
#endif
#if !BUILDFLAG(IS_ANDROID)
@@ -1756,7 +1764,6 @@
ash::ManagedCellularPrefHandler::RegisterLocalStatePrefs(registry);
ash::ChromeSessionManager::RegisterPrefs(registry);
user_manager::UserManagerImpl::RegisterPrefs(registry);
- crosapi::browser_util::RegisterLocalStatePrefs(registry);
ash::CupsPrintersManager::RegisterLocalStatePrefs(registry);
ash::bluetooth_config::BluetoothPowerControllerImpl::RegisterLocalStatePrefs(
registry);
@@ -2498,6 +2505,9 @@
local_state->ClearPref(kProfileMigrationCompletedForUserPref);
local_state->ClearPref(kProfileMoveMigrationCompletedForUserPref);
local_state->ClearPref(kProfileMigrationCompletedForNewUserPref);
+ local_state->ClearPref(kProfileDataBackwardMigrationCompletedForUserPref);
+ local_state->ClearPref(kGotoFilesPref);
+ local_state->ClearPref(kProfileMigrationCompletionTimeForUserPref);
#endif
#if !BUILDFLAG(IS_ANDROID)
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 694de94e..0fde9cf 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -646,7 +646,6 @@
ash::standalone_browser::BrowserSupport::InitializeForPrimaryUser(
map, IsNewProfile(), IsRegularProfile());
crosapi::browser_util::CacheLacrosAvailability(map);
- crosapi::browser_util::CacheLacrosDataBackwardMigrationMode(map);
ash::standalone_browser::CacheLacrosSelection(map);
}
#endif
@@ -1183,7 +1182,6 @@
ash::standalone_browser::BrowserSupport::InitializeForPrimaryUser(
map, IsNewProfile(), IsRegularProfile());
crosapi::browser_util::CacheLacrosAvailability(map);
- crosapi::browser_util::CacheLacrosDataBackwardMigrationMode(map);
ash::standalone_browser::CacheLacrosSelection(map);
}
diff --git a/chrome/browser/ui/ash/session/session_controller_client_impl.cc b/chrome/browser/ui/ash/session/session_controller_client_impl.cc
index 0a275c7d..ed5c863 100644
--- a/chrome/browser/ui/ash/session/session_controller_client_impl.cc
+++ b/chrome/browser/ui/ash/session/session_controller_client_impl.cc
@@ -19,8 +19,6 @@
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
-#include "chrome/browser/ash/crosapi/browser_manager.h"
-#include "chrome/browser/ash/crosapi/browser_util.h"
#include "chrome/browser/ash/floating_workspace/floating_workspace_service.h"
#include "chrome/browser/ash/floating_workspace/floating_workspace_service_factory.h"
#include "chrome/browser/ash/floating_workspace/floating_workspace_util.h"
@@ -286,13 +284,6 @@
// Launch sign in screen to add another user to current session.
DCHECK(!UserManager::Get()->GetUsersAllowedForMultiUserSignIn().empty());
- // Lacros and multiprofile are mutually exclusive.
- const auto* primary_user = UserManager::Get()->GetPrimaryUser();
- DCHECK(primary_user);
- DCHECK(!crosapi::browser_util::IsLacrosEnabledForMigration(
- primary_user,
- ash::standalone_browser::migrator_util::PolicyInitState::kAfterInit));
-
// Don't show the dialog if any logged-in user in the multi-profile session
// dismissed it.
bool show_intro = true;
@@ -376,13 +367,7 @@
ash::SessionTerminationManager::Get()->IsLockedToSingleUser()) {
return false;
}
- // Multiprofile mode is not allowed if Lacros is enabled.
- const auto* primary_user = UserManager::Get()->GetPrimaryUser();
- if (primary_user && crosapi::browser_util::IsLacrosEnabledForMigration(
- primary_user, ash::standalone_browser::migrator_util::
- PolicyInitState::kAfterInit)) {
- return false;
- }
+
size_t users_logged_in = UserManager::Get()->GetLoggedInUsers().size();
// Does not include users that are logged in.
size_t users_available_to_add =
@@ -470,15 +455,6 @@
return ash::AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED;
}
- const auto* primary_user = user_manager->GetPrimaryUser();
- if (primary_user) {
- if (crosapi::browser_util::IsLacrosEnabledForMigration(
- primary_user, ash::standalone_browser::migrator_util::
- PolicyInitState::kAfterInit)) {
- return ash::AddUserSessionPolicy::ERROR_LACROS_ENABLED;
- }
- }
-
return ash::AddUserSessionPolicy::ALLOWED;
}