#include "content/browser/service_worker/service_worker_main_resource_loader_interceptor.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/overloaded.h"
#include "base/memory/ptr_util.h"
#include "base/types/optional_util.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/navigation_request_info.h"
#include "content/browser/service_worker/service_worker_client.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_main_resource_handle.h"
#include "content/browser/service_worker/service_worker_object_host.h"
#include "content/browser/worker_host/dedicated_worker_host.h"
#include "content/browser/worker_host/dedicated_worker_service_impl.h"
#include "content/browser/worker_host/shared_worker_host.h"
#include "content/browser/worker_host/shared_worker_service_impl.h"
#include "content/public/common/content_client.h"
#include "content/public/common/origin_util.h"
#include "content/public/common/url_constants.h"
#include "net/base/isolation_info.h"
#include "net/base/url_util.h"
#include "net/cookies/site_for_cookies.h"
#include "third_party/blink/public/common/loader/resource_type_util.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/storage_key/ancestor_chain_bit.mojom.h"
#include "url/origin.h"
#include "url/url_constants.h"
namespace content {
namespace {
bool SchemeMaySupportRedirectingToHTTPS(BrowserContext* browser_context,
const GURL& url) { … }
bool ShouldCreateForWorker(
const GURL& url,
base::WeakPtr<ServiceWorkerClient> parent_service_worker_client) { … }
}
std::unique_ptr<NavigationLoaderInterceptor>
ServiceWorkerMainResourceLoaderInterceptor::CreateForNavigation(
const GURL& url,
base::WeakPtr<ServiceWorkerMainResourceHandle> navigation_handle,
const NavigationRequestInfo& request_info) { … }
std::unique_ptr<ServiceWorkerMainResourceLoaderInterceptor>
ServiceWorkerMainResourceLoaderInterceptor::CreateForWorker(
const network::ResourceRequest& resource_request,
const net::IsolationInfo& isolation_info,
int process_id,
const DedicatedOrSharedWorkerToken& worker_token,
base::WeakPtr<ServiceWorkerMainResourceHandle> navigation_handle) { … }
ServiceWorkerMainResourceLoaderInterceptor::
~ServiceWorkerMainResourceLoaderInterceptor() { … }
void ServiceWorkerMainResourceLoaderInterceptor::MaybeCreateLoader(
const network::ResourceRequest& tentative_resource_request,
BrowserContext* browser_context,
LoaderCallback loader_callback,
FallbackCallback fallback_callback) { … }
void ServiceWorkerMainResourceLoaderInterceptor::CompleteWithoutLoader(
LoaderCallback loader_callback,
base::WeakPtr<ServiceWorkerClient> service_worker_client) { … }
ServiceWorkerMainResourceLoaderInterceptor::
ServiceWorkerMainResourceLoaderInterceptor(
base::WeakPtr<ServiceWorkerMainResourceHandle> handle,
network::mojom::RequestDestination request_destination,
bool skip_service_worker,
bool are_ancestors_secure,
int frame_tree_node_id,
int process_id,
const DedicatedOrSharedWorkerToken* worker_token,
const net::IsolationInfo& isolation_info)
: … { … }
bool ServiceWorkerMainResourceLoaderInterceptor::ShouldCreateForNavigation(
const GURL& url,
network::mojom::RequestDestination request_destination,
BrowserContext* browser_context) { … }
std::optional<blink::StorageKey>
ServiceWorkerMainResourceLoaderInterceptor::GetStorageKeyFromRenderFrameHost(
const url::Origin& origin,
const base::UnguessableToken* nonce) { … }
std::optional<blink::StorageKey>
ServiceWorkerMainResourceLoaderInterceptor::GetStorageKeyFromWorkerHost(
const url::Origin& origin) { … }
std::optional<blink::StorageKey>
ServiceWorkerMainResourceLoaderInterceptor::GetStorageKeyFromWorkerHost(
content::StoragePartition* storage_partition,
blink::DedicatedWorkerToken dedicated_worker_token,
const url::Origin& origin) { … }
std::optional<blink::StorageKey>
ServiceWorkerMainResourceLoaderInterceptor::GetStorageKeyFromWorkerHost(
content::StoragePartition* storage_partition,
blink::SharedWorkerToken shared_worker_token,
const url::Origin& origin) { … }
}