chromium/components/privacy_sandbox/privacy_sandbox_settings_impl.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/privacy_sandbox/privacy_sandbox_settings_impl.h"

#include <cstddef>
#include <vector>

#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/json/values_util.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/browsing_topics/common/common_types.h"
#include "components/browsing_topics/common/semantic_tree.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/privacy_sandbox/canonical_topic.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
#include "components/privacy_sandbox/privacy_sandbox_settings.h"
#include "components/privacy_sandbox/tpcd_experiment_eligibility.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/content_features.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/site_for_cookies.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace privacy_sandbox {

namespace {

constexpr char kBlockedTopicsTopicKey[] =;
constexpr char kBlockedTopicsBlockTimeKey[] =;

constexpr char kIsTopicsAllowedHistogram[] =;
constexpr char kIsTopicsAllowedForContextHistogram[] =;
constexpr char kIsAttributionReportingEverAllowedHistogram[] =;
constexpr char kIsAttributionReportingAllowedHistogram[] =;
constexpr char kMaySendAttributionReportHistogram[] =;
constexpr char kIsFledgeJoinAllowedHistogram[] =;
constexpr char kIsFledgeLeaveAllowedHistogram[] =;
constexpr char kIsFledgeUpdateAllowedHistogram[] =;
constexpr char kIsFledgeSellAllowedHistogram[] =;
constexpr char kIsFledgeBuyAllowedHistogram[] =;
constexpr char kIsPrivacySandboxReportingDestinationAttestedHistogram[] =;
constexpr char kIsSharedStorageAllowedHistogram[] =;
constexpr char kIsSharedStorageSelectURLAllowedHistogram[] =;
constexpr char kIsPrivateAggregationAllowedHistogram[] =;

bool IsCookiesClearOnExitEnabled(HostContentSettingsMap* map) {}

// Convert a stored FLEDGE block eTLD+1 into applicable content settings
// patterns. This ensures that if Public Suffix List membership changes, the
// stored item continues to match as when it was set. Multiple patterns are set
// to support IP address fallbacks, which do not support [*.] prefixes.
// TODO (crbug.com/1287153): This is somewhat hacky and can be removed when
// FLEDGE is controlled by a content setting directly.
std::vector<ContentSettingsPattern> FledgeBlockToContentSettingsPatterns(
    const std::string& entry) {}

// Returns a base::Value::Dict for storage in prefs that represents |topic|
// blocked at the current time.
base::Value::Dict CreateBlockedTopicEntry(const CanonicalTopic& topic) {}

std::set<browsing_topics::Topic> GetTopicsSetFromString(
    std::string topics_string) {}

}  // namespace

// static
bool PrivacySandboxSettingsImpl::IsAllowed(Status status) {}

// static
void PrivacySandboxSettingsImpl::JoinHistogram(const char* name,
                                               Status status) {}

// static
void PrivacySandboxSettingsImpl::JoinFledgeHistogram(
    content::InterestGroupApiOperation interest_group_api_operation,
    Status status) {}

PrivacySandboxSettingsImpl::PrivacySandboxSettingsImpl(
    std::unique_ptr<Delegate> delegate,
    HostContentSettingsMap* host_content_settings_map,
    scoped_refptr<content_settings::CookieSettings> cookie_settings,
    TrackingProtectionSettings* tracking_protection_settings,
    PrefService* pref_service)
    :{}

PrivacySandboxSettingsImpl::~PrivacySandboxSettingsImpl() = default;

void PrivacySandboxSettingsImpl::Shutdown() {}

PrivacySandboxSettingsImpl::Status
PrivacySandboxSettingsImpl::GetM1TopicAllowedStatus() const {}

const std::set<browsing_topics::Topic>&
PrivacySandboxSettingsImpl::GetFinchDisabledTopics() {}

const std::set<browsing_topics::Topic>&
PrivacySandboxSettingsImpl::GetFinchPrioritizedTopics() {}

bool PrivacySandboxSettingsImpl::IsTopicsAllowed() const {}

bool PrivacySandboxSettingsImpl::IsTopicsAllowedForContext(
    const url::Origin& top_frame_origin,
    const GURL& url,
    content::RenderFrameHost* console_frame) const {}

bool PrivacySandboxSettingsImpl::IsTopicAllowed(const CanonicalTopic& topic) {}

void PrivacySandboxSettingsImpl::SetTopicAllowed(const CanonicalTopic& topic,
                                                 bool allowed) {}

bool PrivacySandboxSettingsImpl::IsTopicPrioritized(
    const CanonicalTopic& topic) {}

void PrivacySandboxSettingsImpl::ClearTopicSettings(base::Time start_time,
                                                    base::Time end_time) {}

base::Time PrivacySandboxSettingsImpl::TopicsDataAccessibleSince() const {}

PrivacySandboxSettingsImpl::Status
PrivacySandboxSettingsImpl::GetM1AdMeasurementAllowedStatus(
    const url::Origin& top_frame_origin,
    const url::Origin& reporting_origin) const {}

bool PrivacySandboxSettingsImpl::IsAttributionReportingEverAllowed() const {}

bool PrivacySandboxSettingsImpl::IsAttributionReportingAllowed(
    const url::Origin& top_frame_origin,
    const url::Origin& reporting_origin,
    content::RenderFrameHost* console_frame) const {}

bool PrivacySandboxSettingsImpl::MaySendAttributionReport(
    const url::Origin& source_origin,
    const url::Origin& destination_origin,
    const url::Origin& reporting_origin,
    content::RenderFrameHost* console_frame) const {}

bool PrivacySandboxSettingsImpl::
    IsAttributionReportingTransitionalDebuggingAllowed(
        const url::Origin& top_frame_origin,
        const url::Origin& reporting_origin,
        bool& can_bypass) const {}

void PrivacySandboxSettingsImpl::SetFledgeJoiningAllowed(
    const std::string& top_frame_etld_plus1,
    bool allowed) {}

void PrivacySandboxSettingsImpl::ClearFledgeJoiningAllowedSettings(
    base::Time start_time,
    base::Time end_time) {}

bool PrivacySandboxSettingsImpl::IsFledgeJoiningAllowed(
    const url::Origin& top_frame_origin) const {}

PrivacySandboxSettingsImpl::Status
PrivacySandboxSettingsImpl::GetM1FledgeAllowedStatus(
    const url::Origin& top_frame_origin,
    const url::Origin& auction_party) const {}

bool PrivacySandboxSettingsImpl::IsEventReportingDestinationAttested(
    const url::Origin& destination_origin,
    privacy_sandbox::PrivacySandboxAttestationsGatedAPI invoking_api) const {}

bool PrivacySandboxSettingsImpl::IsFledgeAllowed(
    const url::Origin& top_frame_origin,
    const url::Origin& auction_party,
    content::InterestGroupApiOperation interest_group_api_operation,
    content::RenderFrameHost* console_frame) const {}

bool PrivacySandboxSettingsImpl::IsSharedStorageAllowed(
    const url::Origin& top_frame_origin,
    const url::Origin& accessing_origin,
    std::string* out_debug_message,
    content::RenderFrameHost* console_frame,
    bool* out_block_is_site_setting_specific) const {}

bool PrivacySandboxSettingsImpl::IsSharedStorageSelectURLAllowed(
    const url::Origin& top_frame_origin,
    const url::Origin& accessing_origin,
    std::string* out_debug_message,
    bool* out_block_is_site_setting_specific) const {}

bool PrivacySandboxSettingsImpl::IsPrivateAggregationAllowed(
    const url::Origin& top_frame_origin,
    const url::Origin& reporting_origin,
    bool* out_block_is_site_setting_specific) const {}

bool PrivacySandboxSettingsImpl::IsPrivateAggregationDebugModeAllowed(
    const url::Origin& top_frame_origin,
    const url::Origin& reporting_origin) const {}

void PrivacySandboxSettingsImpl::SetAllPrivacySandboxAllowedForTesting() {}

void PrivacySandboxSettingsImpl::SetTopicsBlockedForTesting() {}

bool PrivacySandboxSettingsImpl::IsPrivacySandboxRestricted() const {}

bool PrivacySandboxSettingsImpl::IsPrivacySandboxCurrentlyUnrestricted() const {}

bool PrivacySandboxSettingsImpl::IsSubjectToM1NoticeRestricted() const {}

bool PrivacySandboxSettingsImpl::IsRestrictedNoticeEnabled() const {}

void PrivacySandboxSettingsImpl::OnCookiesCleared() {}

void PrivacySandboxSettingsImpl::OnRelatedWebsiteSetsEnabledPrefChanged() {}

void PrivacySandboxSettingsImpl::AddObserver(Observer* observer) {}

void PrivacySandboxSettingsImpl::RemoveObserver(Observer* observer) {}

void PrivacySandboxSettingsImpl::SetDelegateForTesting(
    std::unique_ptr<Delegate> delegate) {}

void PrivacySandboxSettingsImpl::SetTopicsDataAccessibleFromNow() const {}

PrivacySandboxSettingsImpl::Status
PrivacySandboxSettingsImpl::GetSiteAccessAllowedStatus(
    const url::Origin& top_frame_origin,
    const GURL& url) const {}

PrivacySandboxSettingsImpl::Status
PrivacySandboxSettingsImpl::GetPrivacySandboxAllowedStatus(
    bool should_ignore_restriction /*=false*/) const {}

PrivacySandboxSettingsImpl::Status
PrivacySandboxSettingsImpl::GetM1PrivacySandboxApiEnabledStatus(
    const std::string& pref_name) const {}

TpcdExperimentEligibility
PrivacySandboxSettingsImpl::GetCookieDeprecationExperimentCurrentEligibility()
    const {}

bool PrivacySandboxSettingsImpl::IsCookieDeprecationLabelAllowed() const {}

bool PrivacySandboxSettingsImpl::IsCookieDeprecationLabelAllowedForContext(
    const url::Origin& top_frame_origin,
    const url::Origin& context_origin) const {}

void PrivacySandboxSettingsImpl::OnBlockAllThirdPartyCookiesChanged() {}

bool PrivacySandboxSettingsImpl::AreRelatedWebsiteSetsEnabled() const {}

void PrivacySandboxSettingsImpl::SetOutBlockIsSiteSettingSpecificFromStatus(
    Status status,
    bool* out_block_is_site_setting_specific) const {}

}  // namespace privacy_sandbox