Skip to content

Commit

Permalink
[profiles] Make kSessionExitedCleanly pref obsolete
Browse files Browse the repository at this point in the history
kSessionExitedCleanly pref is deprecated but still checked in the code
as a fallback. The code contains a TODO to remove this pref around M28
release which makes me believe that this fallback is no longer needed.

The pref should be deleted from disk though, so this CL moves it
into the MigrateObsoleteProfilePrefs() function that takes care of it.

Change-Id: I84cddb655dd50d23578d4b9020d3efb9ca652ea5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2891790
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#882093}
  • Loading branch information
Alex Ilin authored and Chromium LUCI CQ committed May 12, 2021
1 parent e6a01f3 commit 243803e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
7 changes: 5 additions & 2 deletions chrome/browser/prefs/browser_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,11 @@ const char kTranslateLastDeniedTimeForLanguage[] =
const char kTranslateTooOftenDeniedForLanguage[] =
"translate_too_often_denied_for_language";

#if BUILDFLAG(ENABLE_EXTENSIONS)
// Deprecated 05/2021.
#if BUILDFLAG(ENABLE_EXTENSIONS)
const char kToolbarSize[] = "extensions.toolbarsize";
#endif
const char kSessionExitedCleanly[] = "profile.exited_cleanly";

// Register local state used only for migration (clearing or moving to a new
// key).
Expand Down Expand Up @@ -698,6 +699,7 @@ void RegisterProfilePrefsForMigration(
#if BUILDFLAG(ENABLE_EXTENSIONS)
registry->RegisterIntegerPref(kToolbarSize, -1);
#endif
registry->RegisterBooleanPref(kSessionExitedCleanly, true);
}

} // namespace
Expand Down Expand Up @@ -1407,10 +1409,11 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
profile_prefs->ClearPref(kTranslateLastDeniedTimeForLanguage);
profile_prefs->ClearPref(kTranslateTooOftenDeniedForLanguage);

#if BUILDFLAG(ENABLE_EXTENSIONS)
// Added 05/2021.
#if BUILDFLAG(ENABLE_EXTENSIONS)
profile_prefs->ClearPref(kToolbarSize);
#endif
profile_prefs->ClearPref(kSessionExitedCleanly);

// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_PROFILE_PREFS
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/profiles/profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
std::string(),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
#endif // defined(OS_ANDROID)
registry->RegisterBooleanPref(prefs::kSessionExitedCleanly, true);
registry->RegisterStringPref(prefs::kSessionExitType, std::string());
registry->RegisterBooleanPref(prefs::kDisableExtensions, false);
#if BUILDFLAG(ENABLE_EXTENSIONS)
Expand Down
17 changes: 2 additions & 15 deletions chrome/browser/profiles/profile_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ base::Time CreateProfileDirectory(base::SequencedTaskRunner* io_task_runner,
return base::Time::Now();
}

// Converts the kSessionExitedCleanly pref to the corresponding EXIT_TYPE.
// Converts the `kSessionExitType` pref to the corresponding EXIT_TYPE.
Profile::ExitType SessionTypePrefValueToExitType(const std::string& value) {
if (value == kPrefExitTypeSessionEnded)
return Profile::EXIT_SESSION_ENDED;
Expand Down Expand Up @@ -1080,23 +1080,10 @@ void ProfileImpl::OnLocaleReady() {
}
#endif

// |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref
// value is empty fallback to checking for |kSessionExitedCleanly|.
const std::string exit_type_pref_value(
last_session_exit_type_ = SessionTypePrefValueToExitType(
prefs_->GetString(prefs::kSessionExitType));
if (exit_type_pref_value.empty()) {
last_session_exit_type_ = prefs_->GetBoolean(prefs::kSessionExitedCleanly)
? EXIT_NORMAL
: EXIT_CRASHED;
} else {
last_session_exit_type_ =
SessionTypePrefValueToExitType(exit_type_pref_value);
}
// Mark the session as open.
prefs_->SetString(prefs::kSessionExitType, kPrefExitTypeCrashed);
// Force this to true in case we fallback and use it.
// TODO(sky): remove this in a couple of releases (m28ish).
prefs_->SetBoolean(prefs::kSessionExitedCleanly, true);

g_browser_process->profile_manager()->InitProfileUserPrefs(this);

Expand Down
7 changes: 0 additions & 7 deletions chrome/common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ const char kNewTabPageLocationOverride[] = "newtab_page_location_override";
// determine the state of the profile icon for icon format changes.
const char kProfileIconVersion[] = "profile.icon_version";

// Used to determine if the last session exited cleanly. Set to false when
// first opened, and to true when closing. On startup if the value is false,
// it means the profile didn't exit cleanly.
// DEPRECATED: this is replaced by kSessionExitType and exists for backwards
// compatibility.
const char kSessionExitedCleanly[] = "profile.exited_cleanly";

// A string pref whose values is one of the values defined by
// |ProfileImpl::kPrefExitTypeXXX|. Set to |kPrefExitTypeCrashed| on startup and
// one of |kPrefExitTypeNormal| or |kPrefExitTypeSessionEnded| during
Expand Down
1 change: 0 additions & 1 deletion chrome/common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ extern const char kChromeCleanerScanCompletionTime[];
extern const char kNewTabPageLocationOverride[];
extern const char kProfileIconVersion[];
extern const char kRestoreOnStartup[];
extern const char kSessionExitedCleanly[];
extern const char kSessionExitType[];
#if !defined(OS_ANDROID)
extern const char kManagedSerialAllowAllPortsForUrls[];
Expand Down

0 comments on commit 243803e

Please sign in to comment.