#include "content/browser/cookie_store/cookie_store_manager.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/sequence_checker.h"
#include "content/browser/cookie_store/cookie_change_subscriptions.pb.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_metrics.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cookies/cookie_partition_key.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
#include "third_party/blink/public/common/service_worker/service_worker_scope_match.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom.h"
#include "url/gurl.h"
namespace content {
namespace {
const char kSubscriptionsUserKey[] = …;
}
CookieStoreManager::CookieStoreManager(
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
: … { … }
CookieStoreManager::~CookieStoreManager() { … }
void CookieStoreManager::BindReceiver(
mojo::PendingReceiver<blink::mojom::CookieStore> receiver,
const blink::StorageKey& storage_key) { … }
void CookieStoreManager::LoadAllSubscriptions(
base::OnceCallback<void(bool)> callback) { … }
void CookieStoreManager::ListenToCookieChanges(
network::mojom::NetworkContext* network_context,
base::OnceCallback<void(bool)> callback) { … }
void CookieStoreManager::ProcessOnDiskSubscriptions(
base::OnceCallback<void(bool)> load_callback,
const std::vector<std::pair<int64_t, std::string>>& user_data,
blink::ServiceWorkerStatusCode status) { … }
void CookieStoreManager::DidLoadAllSubscriptions(
bool succeeded,
base::OnceCallback<void(bool)> load_callback) { … }
void CookieStoreManager::AddSubscriptions(
int64_t service_worker_registration_id,
const blink::StorageKey& storage_key,
std::vector<blink::mojom::CookieChangeSubscriptionPtr> mojo_subscriptions,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::CookieStore::AddSubscriptionsCallback callback) { … }
void CookieStoreManager::RemoveSubscriptions(
int64_t service_worker_registration_id,
const blink::StorageKey& storage_key,
std::vector<blink::mojom::CookieChangeSubscriptionPtr> mojo_subscriptions,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::CookieStore::RemoveSubscriptionsCallback callback) { … }
void CookieStoreManager::GetSubscriptions(
int64_t service_worker_registration_id,
const blink::StorageKey& storage_key,
mojo::ReportBadMessageCallback bad_message_callback,
blink::mojom::CookieStore::GetSubscriptionsCallback callback) { … }
void CookieStoreManager::StoreSubscriptions(
int64_t service_worker_registration_id,
const blink::StorageKey& storage_key,
const std::vector<std::unique_ptr<CookieChangeSubscription>>& subscriptions,
base::OnceCallback<void(bool)> callback) { … }
void CookieStoreManager::OnRegistrationDeleted(
int64_t service_worker_registration_id,
const GURL& pattern,
const blink::StorageKey& key) { … }
void CookieStoreManager::ActivateSubscriptions(
base::span<const std::unique_ptr<CookieChangeSubscription>> subscriptions) { … }
void CookieStoreManager::DeactivateSubscriptions(
base::span<const std::unique_ptr<CookieChangeSubscription>> subscriptions) { … }
void CookieStoreManager::OnStorageWiped() { … }
void CookieStoreManager::OnCookieChange(const net::CookieChangeInfo& change) { … }
void CookieStoreManager::BindReceiverForFrame(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::CookieStore> receiver) { … }
void CookieStoreManager::BindReceiverForWorker(
const ServiceWorkerVersionBaseInfo& info,
mojo::PendingReceiver<blink::mojom::CookieStore> receiver) { … }
void CookieStoreManager::DispatchChangeEvent(
scoped_refptr<ServiceWorkerRegistration> registration,
const net::CookieChangeInfo& change) { … }
void CookieStoreManager::DidStartWorkerForChangeEvent(
scoped_refptr<ServiceWorkerRegistration> registration,
const net::CookieChangeInfo& change,
blink::ServiceWorkerStatusCode start_worker_status) { … }
}