Bug 1698843 - Part 2: Make the private cookieBehavior getter to return the regular pref if there is a user value for the regular pref. r=johannh,dimi

If the user has a non-default regular cookieBehavior, we will make the
private cookieBehavior getter to return the regular pref to mirror the
cookieBehavior in ETP custom mode.

In addition, we don't need to do the pref migration because if the user
has a non-default cookieBehavior, it will directly mirror to the private
cookieBehavior pref so that the cookieBehavior is consistent for private
mode.

Differential Revision: https://phabricator.services.mozilla.com/D111002
This commit is contained in:
Tim Huang 2021-04-13 18:07:10 +00:00
Родитель 3678c2e133
Коммит 2b07a16765
1 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -50,6 +50,26 @@ uint32_t MakeCookieBehavior(uint32_t aCookieBehavior) {
// static
uint32_t nsICookieManager::GetCookieBehavior(bool aIsPrivate) {
if (aIsPrivate) {
// To sync the cookieBehavior pref between regular and private mode in ETP
// custom mode, we will return the regular cookieBehavior pref for private
// mode when
// 1. The regular cookieBehavior pref has a non-default value.
// 2. And the private cookieBehavior pref has a default value.
// Also, this can cover the migration case where the user has a non-default
// cookieBehavior before the private cookieBehavior was introduced. The
// getter here will directly return the regular cookieBehavior, so that the
// cookieBehavior for private mode is consistent.
if (mozilla::Preferences::HasUserValue(
"network.cookie.cookieBehavior.pbmode")) {
return MakeCookieBehavior(
mozilla::StaticPrefs::network_cookie_cookieBehavior_pbmode());
}
if (mozilla::Preferences::HasUserValue("network.cookie.cookieBehavior")) {
return MakeCookieBehavior(
mozilla::StaticPrefs::network_cookie_cookieBehavior());
}
return MakeCookieBehavior(
mozilla::StaticPrefs::network_cookie_cookieBehavior_pbmode());
}