chromium/chrome/browser/dips/dips_service.cc

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

#include "chrome/browser/dips/dips_service.h"

#include <memory>
#include <optional>
#include <set>
#include <string_view>
#include <vector>

#include "base/check_deref.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/dips/chrome_dips_delegate.h"
#include "chrome/browser/dips/dips_browser_signin_detector.h"
#include "chrome/browser/dips/dips_redirect_info.h"
#include "chrome/browser/dips/dips_service_factory.h"
#include "chrome/browser/dips/dips_storage.h"
#include "chrome/browser/dips/dips_utils.h"
#include "chrome/browser/dips/persistent_repeating_timer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/tpcd/experiment/tpcd_experiment_features.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/common/content_features.h"
#include "content/public/common/dips_utils.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/cookie_partition_key.h"
#include "net/cookies/cookie_partition_key_collection.h"
#include "net/cookies/cookie_setting_override.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 "services/network/public/mojom/clear_data_filter.mojom.h"
#include "url/origin.h"

namespace {

// Controls whether UKM metrics are collected for DIPS.
BASE_FEATURE();

// Controls whether the database requests are executed on a foreground sequence.
BASE_FEATURE();

RedirectCategory ClassifyRedirect(SiteDataAccessType access,
                                  bool has_interaction) {}

inline void UmaHistogramBounceCategory(RedirectCategory category,
                                       DIPSCookieMode mode,
                                       DIPSRedirectType type) {}

inline void UmaHistogramDeletionLatency(base::Time deletion_start) {}

inline void UmaHistogramClearedSitesCount(DIPSCookieMode mode, int size) {}

inline void UmaHistogramDeletion(DIPSCookieMode mode,
                                 DIPSDeletionAction action) {}

void OnDeletionFinished(base::OnceClosure finished_callback,
                        base::Time deletion_start) {}

net::CookiePartitionKeyCollection CookiePartitionKeyCollectionForSites(
    const std::vector<std::string>& sites) {}

class StateClearer : public content::BrowsingDataRemover::Observer {};

class DipsTimerStorage : public dips::PersistentRepeatingTimer::Storage {};

DipsTimerStorage::DipsTimerStorage(
    base::SequenceBound<DIPSStorage>* dips_storage)
    :{}

DipsTimerStorage::~DipsTimerStorage() = default;

}  // namespace

/* static */
DIPSService* DIPSService::Get(content::BrowserContext* context) {}

DIPSServiceImpl::DIPSServiceImpl(content::BrowserContext* context)
    :{}

std::unique_ptr<dips::PersistentRepeatingTimer> DIPSServiceImpl::CreateTimer() {}

DIPSServiceImpl::~DIPSServiceImpl() = default;

/* static */
DIPSServiceImpl* DIPSServiceImpl::Get(content::BrowserContext* context) {}

void DIPSServiceImpl::Shutdown() {}

scoped_refptr<base::SequencedTaskRunner> DIPSServiceImpl::CreateTaskRunner() {}

bool DIPSServiceImpl::Are3PCAllowed(const GURL& first_party_url,
                                    const GURL& third_party_url) const {}

DIPSCookieMode DIPSServiceImpl::GetCookieMode() const {}

void DIPSServiceImpl::RemoveEvents(const base::Time& delete_begin,
                                   const base::Time& delete_end,
                                   network::mojom::ClearDataFilterPtr filter,
                                   DIPSEventRemovalType type) {}

void DIPSServiceImpl::HandleRedirectChain(
    std::vector<DIPSRedirectInfoPtr> redirects,
    DIPSRedirectChainInfoPtr chain,
    base::RepeatingCallback<void(const GURL&)> content_settings_callback) {}

void DIPSServiceImpl::RecordInteractionForTesting(const GURL& url) {}

void DIPSServiceImpl::DidSiteHaveInteractionSince(
    const GURL& url,
    base::Time bound,
    CheckInteractionCallback callback) const {}

void DIPSServiceImpl::GotState(
    std::vector<DIPSRedirectInfoPtr> redirects,
    DIPSRedirectChainInfoPtr chain,
    size_t index,
    base::RepeatingCallback<void(const GURL&)> content_settings_callback,
    const DIPSState url_state) {}

void DIPSServiceImpl::RecordBounce(
    const GURL& url,
    const GURL& initial_url,
    const GURL& final_url,
    base::Time time,
    bool stateful,
    base::RepeatingCallback<void(const GURL&)> content_settings_callback) {}

/*static*/
void DIPSServiceImpl::HandleRedirect(
    const DIPSRedirectInfo& redirect,
    const DIPSRedirectChainInfo& chain,
    RecordBounceCallback record_bounce,
    base::RepeatingCallback<void(const GURL&)> content_settings_callback) {}

void DIPSServiceImpl::OnTimerFired() {}

void DIPSServiceImpl::DeleteEligibleSitesImmediately(
    DeletedSitesCallback callback) {}

void DIPSServiceImpl::DeleteDIPSEligibleState(
    DeletedSitesCallback callback,
    std::vector<std::string> sites_to_clear) {}

void DIPSServiceImpl::RunDeletionTaskOnUIThread(std::vector<std::string> sites,
                                                base::OnceClosure callback) {}

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

void DIPSServiceImpl::RemoveObserver(const Observer* observer) {}

void DIPSServiceImpl::RecordBrowserSignIn(std::string_view domain) {}