Commit 3dbdc73a authored by Stephen Nusko's avatar Stephen Nusko Committed by Commit Bot

Revert "Remove BlockThirdPartyCookies preference"

This reverts commit 1180542b.

Reason for revert: Breaks android perf bots.

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=gab@chromium.org,engedy@chromium.org,dullweber@chromium.org

Change-Id: Id0b1094a32d0c4f8f2ab60ad3744c0e71b8dc085
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1104836
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391120Reviewed-by: default avatarStephen Nusko <nuskos@chromium.org>
Commit-Queue: Stephen Nusko <nuskos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803873}
parent d3f199e6
...@@ -566,9 +566,6 @@ const char kHashedAvailablePages[] = "previews.offline_helper.available_pages"; ...@@ -566,9 +566,6 @@ const char kHashedAvailablePages[] = "previews.offline_helper.available_pages";
// Deprecated 7/2020 // Deprecated 7/2020
const char kObservedSessionTime[] = "profile.observed_session_time"; 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 // Register local state used only for migration (clearing or moving to a new
// key). // key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) { void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
...@@ -677,8 +674,6 @@ void RegisterProfilePrefsForMigration( ...@@ -677,8 +674,6 @@ void RegisterProfilePrefsForMigration(
registry->RegisterDictionaryPref(kHashedAvailablePages); registry->RegisterDictionaryPref(kHashedAvailablePages);
registry->RegisterDictionaryPref(kObservedSessionTime); registry->RegisterDictionaryPref(kObservedSessionTime);
registry->RegisterBooleanPref(kBlockThirdPartyCookies, false);
} }
} // namespace } // namespace
...@@ -1344,7 +1339,4 @@ void MigrateObsoleteProfilePrefs(Profile* profile) { ...@@ -1344,7 +1339,4 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
// Added 7/2020 // Added 7/2020
profile_prefs->ClearPref(kObservedSessionTime); profile_prefs->ClearPref(kObservedSessionTime);
// Added 9/2020
profile_prefs->ClearPref(kBlockThirdPartyCookies);
} }
...@@ -60,6 +60,9 @@ void CookieSettings::GetCookieSettings( ...@@ -60,6 +60,9 @@ void CookieSettings::GetCookieSettings(
void CookieSettings::RegisterProfilePrefs( void CookieSettings::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(
prefs::kBlockThirdPartyCookies, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterIntegerPref( registry->RegisterIntegerPref(
prefs::kCookieControlsMode, prefs::kCookieControlsMode,
static_cast<int>(CookieControlsMode::kIncognitoOnly), static_cast<int>(CookieControlsMode::kIncognitoOnly),
...@@ -237,9 +240,7 @@ void CookieSettings::GetCookieSettingInternal( ...@@ -237,9 +240,7 @@ void CookieSettings::GetCookieSettingInternal(
CookieSettings::~CookieSettings() = default; CookieSettings::~CookieSettings() = default;
bool CookieSettings::ShouldBlockThirdPartyCookiesInternal() { bool CookieSettings::IsCookieControlsEnabled() {
DCHECK(thread_checker_.CalledOnValidThread());
#if defined(OS_IOS) #if defined(OS_IOS)
if (!base::FeatureList::IsEnabled(kImprovedCookieControls)) if (!base::FeatureList::IsEnabled(kImprovedCookieControls))
return false; return false;
...@@ -273,7 +274,8 @@ void CookieSettings::OnContentSettingChanged( ...@@ -273,7 +274,8 @@ void CookieSettings::OnContentSettingChanged(
void CookieSettings::OnCookiePreferencesChanged() { void CookieSettings::OnCookiePreferencesChanged() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
bool new_block_third_party_cookies = ShouldBlockThirdPartyCookiesInternal(); bool new_block_third_party_cookies =
IsCookieControlsEnabled();
// Safe to read |block_third_party_cookies_| without locking here because the // 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 // only place that writes to it is this method and it will always be run on
......
...@@ -140,6 +140,9 @@ class CookieSettings : public CookieSettingsBase, ...@@ -140,6 +140,9 @@ class CookieSettings : public CookieSettingsBase,
void RemoveObserver(Observer* obs) { observers_.RemoveObserver(obs); } 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: private:
~CookieSettings() override; ~CookieSettings() override;
...@@ -170,10 +173,6 @@ class CookieSettings : public CookieSettingsBase, ...@@ -170,10 +173,6 @@ class CookieSettings : public CookieSettingsBase,
void OnCookiePreferencesChanged(); 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::ThreadChecker thread_checker_;
base::ObserverList<Observer> observers_; base::ObserverList<Observer> observers_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_; scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
namespace prefs { 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 // CookieControlsMode enum value that decides when the cookie controls UI is
// enabled. This will block third-party cookies similar to // enabled. This will block third-party cookies similar to
// kBlockThirdPartyCookies but with a new UI. // kBlockThirdPartyCookies but with a new UI.
......
...@@ -13,6 +13,9 @@ namespace prefs { ...@@ -13,6 +13,9 @@ namespace prefs {
// some of these are generated by WebsiteSettingsInfo from content settings // some of these are generated by WebsiteSettingsInfo from content settings
// names. // 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 kCookieControlsMode[];
extern const char kContentSettingsVersion[]; 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