#include "components/content_settings/browser/ui/cookie_controls_controller.h"
#include <memory>
#include <string>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/json/values_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/observer_list.h"
#include "components/browsing_data/content/browsing_data_helper.h"
#include "components/content_settings/browser/page_specific_content_settings.h"
#include "components/content_settings/browser/ui/cookie_controls_view.h"
#include "components/content_settings/core/browser/content_settings_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/cookie_blocking_3pcd_status.h"
#include "components/content_settings/core/common/cookie_controls_enforcement.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/content_settings/core/common/third_party_site_data_access_type.h"
#include "components/content_settings/core/common/tracking_protection_feature.h"
#include "components/fingerprinting_protection_filter/browser/fingerprinting_protection_web_contents_helper.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/strings/grit/privacy_sandbox_strings.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/reload_type.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "net/cookies/site_for_cookies.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
UserMetricsAction;
TrackingProtectionFeature;
SiteEngagementService;
BlockingStatus;
FeatureType;
constexpr char kEntryPointAnimatedKey[] = …;
constexpr char kLastExpirationKey[] = …;
constexpr char kLastVisitedActiveException[] = …;
constexpr char kActivationsCountKey[] = …;
base::Value::Dict GetMetadata(HostContentSettingsMap* settings_map,
const GURL& url) { … }
bool WasEntryPointAlreadyAnimated(const base::Value::Dict& metadata) { … }
int GetActivationCount(const base::Value::Dict& metadata) { … }
bool HasExceptionExpiredSinceLastVisit(const base::Value::Dict& metadata) { … }
void ApplyMetadataChanges(HostContentSettingsMap* settings_map,
const GURL& url,
base::Value::Dict&& dict) { … }
ThirdPartySiteDataAccessType GetSiteDataAccessType(int allowed_sites,
int blocked_sites) { … }
}
namespace content_settings {
CookieControlsController::CookieControlsController(
scoped_refptr<CookieSettings> cookie_settings,
scoped_refptr<CookieSettings> original_cookie_settings,
HostContentSettingsMap* settings_map,
privacy_sandbox::TrackingProtectionSettings* tracking_protection_settings)
: … { … }
CookieControlsController::Status::Status(
bool controls_visible,
bool protections_on,
CookieControlsEnforcement enforcement,
CookieBlocking3pcdStatus blocking_status,
base::Time expiration,
std::vector<TrackingProtectionFeature> features)
: … { … }
CookieControlsController::Status::~Status() = default;
CookieControlsController::~CookieControlsController() = default;
void CookieControlsController::OnUiClosing() { … }
void CookieControlsController::Update(content::WebContents* web_contents) { … }
void CookieControlsController::OnSubresourceBlocked() { … }
CookieControlsController::Status CookieControlsController::GetStatus(
content::WebContents* web_contents) { … }
bool CookieControlsController::ShowIpProtection() const { … }
bool CookieControlsController::ShowFingerprintingProtection() const { … }
bool CookieControlsController::ShowActFeatures() { … }
std::vector<TrackingProtectionFeature>
CookieControlsController::CreateTrackingProtectionFeatureList(
CookieControlsEnforcement enforcement,
bool cookies_allowed,
bool protections_on) { … }
CookieControlsEnforcement
CookieControlsController::GetEnforcementForThirdPartyCookieBlocking(
CookieBlocking3pcdStatus status,
const GURL url,
SettingInfo info,
bool cookies_allowed) { … }
bool CookieControlsController::HasOriginSandboxedTopLevelDocument() const { … }
void CookieControlsController::OnCookieBlockingEnabledForSite(
bool block_third_party_cookies) { … }
void CookieControlsController::OnEntryPointAnimated() { … }
bool CookieControlsController::FirstPartyCookiesBlocked() { … }
bool CookieControlsController::HasUserChangedCookieBlockingForSite() { … }
void CookieControlsController::SetUserChangedCookieBlockingForSite(
bool changed) { … }
int CookieControlsController::GetAllowedThirdPartyCookiesSitesCount() const { … }
int CookieControlsController::GetBlockedThirdPartyCookiesSitesCount() const { … }
int CookieControlsController::GetStatefulBounceCount() const { … }
bool CookieControlsController::GetIsSubresourceBlocked() const { … }
void CookieControlsController::UpdateUserBypass() { … }
void CookieControlsController::UpdateLastVisitedSitesMap() { … }
void CookieControlsController::UpdatePageReloadStatus(
int recent_reloads_count) { … }
void CookieControlsController::OnPageFinishedLoading() { … }
void CookieControlsController::OnThirdPartyCookieBlockingChanged(
bool block_third_party_cookies) { … }
void CookieControlsController::OnCookieSettingChanged() { … }
content::WebContents* CookieControlsController::GetWebContents() const { … }
void CookieControlsController::AddObserver(CookieControlsObserver* obs) { … }
void CookieControlsController::RemoveObserver(CookieControlsObserver* obs) { … }
double CookieControlsController::GetSiteEngagementScore() { … }
void CookieControlsController::RecordActivationMetrics() { … }
bool CookieControlsController::ShouldHighlightUserBypass() { … }
bool CookieControlsController::ShouldUserBypassIconBeVisible(
std::vector<TrackingProtectionFeature> features,
bool protections_on,
bool controls_visible) { … }
CookieControlsController::TabObserver::TabObserver(
CookieControlsController* cookie_controls,
content::WebContents* web_contents)
: … { … }
CookieControlsController::TabObserver::~TabObserver() = default;
void CookieControlsController::TabObserver::WebContentsDestroyed() { … }
void CookieControlsController::TabObserver::OnSiteDataAccessed(
const AccessDetails& access_details) { … }
void CookieControlsController::TabObserver::OnStatefulBounceDetected() { … }
void CookieControlsController::TabObserver::OnSubresourceBlocked() { … }
void CookieControlsController::TabObserver::PrimaryPageChanged(
content::Page& page) { … }
void CookieControlsController::TabObserver::DidStopLoading() { … }
void CookieControlsController::TabObserver::ResetReloadCounter() { … }
}