Commit b1917744 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Reland "Remove BlockThirdPartyCookies preference"

This is a reland of 1180542b

The internal CL is rolled in now. Let's try again...

Original change's description:
> Remove BlockThirdPartyCookies preference
>
> The boolean BlockThirdPartyCookies preference was replaced by
> CookieControlsMode enum. Existing settings were migrated since M83.
> Since all usage of the preference has been removed, the preference
> can be removed and existing settings cleared.
>
> Bug: 1104836
> Change-Id: Ie6e38b0a424981395c627459d684030ea84a58b7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387805
> Reviewed-by: Balazs Engedy <engedy@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Commit-Queue: Christian Dullweber <dullweber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#803844}

Tbr: engedy@chromium.org, gab@chromium.org
Bug: 1104836, 1124326
Change-Id: Iebe3205beb4426cda5305eb7c69eb4e575df2cfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391073Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804298}
parent eb19c3fe
......@@ -567,6 +567,9 @@ const char kHashedAvailablePages[] = "previews.offline_helper.available_pages";
// Deprecated 7/2020
const char kObservedSessionTime[] = "profile.observed_session_time";
// Deprecated 9/2020
const char kBlockThirdPartyCookies[] = "profile.block_third_party_cookies";
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
......@@ -675,6 +678,8 @@ void RegisterProfilePrefsForMigration(
registry->RegisterDictionaryPref(kHashedAvailablePages);
registry->RegisterDictionaryPref(kObservedSessionTime);
registry->RegisterBooleanPref(kBlockThirdPartyCookies, false);
}
} // namespace
......@@ -1341,4 +1346,7 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
// Added 7/2020
profile_prefs->ClearPref(kObservedSessionTime);
// Added 9/2020
profile_prefs->ClearPref(kBlockThirdPartyCookies);
}
......@@ -60,9 +60,6 @@ void CookieSettings::GetCookieSettings(
void CookieSettings::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(
prefs::kBlockThirdPartyCookies, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterIntegerPref(
prefs::kCookieControlsMode,
static_cast<int>(CookieControlsMode::kIncognitoOnly),
......@@ -240,7 +237,9 @@ void CookieSettings::GetCookieSettingInternal(
CookieSettings::~CookieSettings() = default;
bool CookieSettings::IsCookieControlsEnabled() {
bool CookieSettings::ShouldBlockThirdPartyCookiesInternal() {
DCHECK(thread_checker_.CalledOnValidThread());
#if defined(OS_IOS)
if (!base::FeatureList::IsEnabled(kImprovedCookieControls))
return false;
......@@ -274,8 +273,7 @@ void CookieSettings::OnContentSettingChanged(
void CookieSettings::OnCookiePreferencesChanged() {
DCHECK(thread_checker_.CalledOnValidThread());
bool new_block_third_party_cookies =
IsCookieControlsEnabled();
bool new_block_third_party_cookies = ShouldBlockThirdPartyCookiesInternal();
// Safe to read |block_third_party_cookies_| without locking here because the
// only place that writes to it is this method and it will always be run on
......
......@@ -140,9 +140,6 @@ class CookieSettings : public CookieSettingsBase,
void RemoveObserver(Observer* obs) { observers_.RemoveObserver(obs); }
// Returns true when the improved cookie control UI should be shown.
// TODO(dullweber): Fix grammar.
bool IsCookieControlsEnabled();
private:
~CookieSettings() override;
......@@ -173,6 +170,10 @@ class CookieSettings : public CookieSettingsBase,
void OnCookiePreferencesChanged();
// Evaluate if third-party cookies are blocked. Should only be called
// when the preference changes to update the internal state.
bool ShouldBlockThirdPartyCookiesInternal();
base::ThreadChecker thread_checker_;
base::ObserverList<Observer> observers_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
......
......@@ -6,10 +6,6 @@
namespace prefs {
// Boolean that is true if we should unconditionally block third-party cookies,
// regardless of other content settings.
const char kBlockThirdPartyCookies[] = "profile.block_third_party_cookies";
// CookieControlsMode enum value that decides when the cookie controls UI is
// enabled. This will block third-party cookies similar to
// kBlockThirdPartyCookies but with a new UI.
......
......@@ -13,9 +13,6 @@ namespace prefs {
// some of these are generated by WebsiteSettingsInfo from content settings
// names.
// TODO(crbug.com/967668): Remove direct access to these preferences and
// replace with CookieSettings::ShouldBlockThirdPartyCookies().
extern const char kBlockThirdPartyCookies[];
extern const char kCookieControlsMode[];
extern const char kContentSettingsVersion[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment