#include "headless/lib/browser/headless_browser_context_impl.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/memory/ptr_util.h"
#include "base/not_fatal_until.h"
#include "base/path_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/simple_key_map.h"
#include "components/origin_trials/browser/leveldb_persistence_provider.h"
#include "components/origin_trials/browser/origin_trials.h"
#include "components/origin_trials/common/features.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "headless/lib/browser/headless_browser_context_options.h"
#include "headless/lib/browser/headless_browser_impl.h"
#include "headless/lib/browser/headless_browser_main_parts.h"
#include "headless/lib/browser/headless_client_hints_controller_delegate.h"
#include "headless/lib/browser/headless_permission_manager.h"
#include "headless/lib/browser/headless_web_contents_impl.h"
#include "third_party/blink/public/common/origin_trials/trial_token_validator.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(HEADLESS_USE_POLICY)
#include "components/user_prefs/user_prefs.h"
#endif
namespace headless {
namespace {
base::FilePath MakeAbsolutePath(const base::FilePath& path) { … }
}
HeadlessBrowserContextImpl::HeadlessBrowserContextImpl(
HeadlessBrowserImpl* browser,
std::unique_ptr<HeadlessBrowserContextOptions> context_options)
: … { … }
HeadlessBrowserContextImpl::~HeadlessBrowserContextImpl() { … }
HeadlessBrowserContextImpl* HeadlessBrowserContextImpl::From(
HeadlessBrowserContext* browser_context) { … }
HeadlessBrowserContextImpl* HeadlessBrowserContextImpl::From(
content::BrowserContext* browser_context) { … }
std::unique_ptr<HeadlessBrowserContextImpl> HeadlessBrowserContextImpl::Create(
HeadlessBrowserContext::Builder* builder) { … }
HeadlessWebContents::Builder
HeadlessBrowserContextImpl::CreateWebContentsBuilder() { … }
std::vector<HeadlessWebContents*>
HeadlessBrowserContextImpl::GetAllWebContents() { … }
void HeadlessBrowserContextImpl::Close() { … }
void HeadlessBrowserContextImpl::InitWhileIOAllowed() { … }
std::unique_ptr<content::ZoomLevelDelegate>
HeadlessBrowserContextImpl::CreateZoomLevelDelegate(
const base::FilePath& partition_path) { … }
base::FilePath HeadlessBrowserContextImpl::GetPath() { … }
bool HeadlessBrowserContextImpl::IsOffTheRecord() { … }
content::DownloadManagerDelegate*
HeadlessBrowserContextImpl::GetDownloadManagerDelegate() { … }
content::BrowserPluginGuestManager*
HeadlessBrowserContextImpl::GetGuestManager() { … }
storage::SpecialStoragePolicy*
HeadlessBrowserContextImpl::GetSpecialStoragePolicy() { … }
content::PlatformNotificationService*
HeadlessBrowserContextImpl::GetPlatformNotificationService() { … }
content::PushMessagingService*
HeadlessBrowserContextImpl::GetPushMessagingService() { … }
content::StorageNotificationService*
HeadlessBrowserContextImpl::GetStorageNotificationService() { … }
content::SSLHostStateDelegate*
HeadlessBrowserContextImpl::GetSSLHostStateDelegate() { … }
content::PermissionControllerDelegate*
HeadlessBrowserContextImpl::GetPermissionControllerDelegate() { … }
content::ClientHintsControllerDelegate*
HeadlessBrowserContextImpl::GetClientHintsControllerDelegate() { … }
content::BackgroundFetchDelegate*
HeadlessBrowserContextImpl::GetBackgroundFetchDelegate() { … }
content::BackgroundSyncController*
HeadlessBrowserContextImpl::GetBackgroundSyncController() { … }
content::BrowsingDataRemoverDelegate*
HeadlessBrowserContextImpl::GetBrowsingDataRemoverDelegate() { … }
content::ReduceAcceptLanguageControllerDelegate*
HeadlessBrowserContextImpl::GetReduceAcceptLanguageControllerDelegate() { … }
content::OriginTrialsControllerDelegate*
HeadlessBrowserContextImpl::GetOriginTrialsControllerDelegate() { … }
HeadlessWebContents* HeadlessBrowserContextImpl::CreateWebContents(
HeadlessWebContents::Builder* builder) { … }
void HeadlessBrowserContextImpl::RegisterWebContents(
std::unique_ptr<HeadlessWebContentsImpl> web_contents) { … }
void HeadlessBrowserContextImpl::DestroyWebContents(
HeadlessWebContentsImpl* web_contents) { … }
HeadlessWebContents*
HeadlessBrowserContextImpl::GetWebContentsForDevToolsAgentHostId(
const std::string& devtools_agent_host_id) { … }
HeadlessBrowserImpl* HeadlessBrowserContextImpl::browser() const { … }
const HeadlessBrowserContextOptions* HeadlessBrowserContextImpl::options()
const { … }
const std::string& HeadlessBrowserContextImpl::Id() { … }
void HeadlessBrowserContextImpl::ConfigureNetworkContextParams(
bool in_memory,
const base::FilePath& relative_partition_path,
::network::mojom::NetworkContextParams* network_context_params,
::cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) { … }
HeadlessBrowserContext::Builder::Builder(HeadlessBrowserImpl* browser)
: … { … }
HeadlessBrowserContext::Builder::~Builder() = default;
HeadlessBrowserContext::Builder::Builder(Builder&&) = default;
HeadlessBrowserContext::Builder& HeadlessBrowserContext::Builder::SetUserAgent(
const std::string& user_agent) { … }
HeadlessBrowserContext::Builder&
HeadlessBrowserContext::Builder::SetAcceptLanguage(
const std::string& accept_language) { … }
HeadlessBrowserContext::Builder&
HeadlessBrowserContext::Builder::SetProxyConfig(
std::unique_ptr<net::ProxyConfig> proxy_config) { … }
HeadlessBrowserContext::Builder& HeadlessBrowserContext::Builder::SetWindowSize(
const gfx::Size& window_size) { … }
HeadlessBrowserContext::Builder&
HeadlessBrowserContext::Builder::SetUserDataDir(
const base::FilePath& user_data_dir) { … }
HeadlessBrowserContext::Builder&
HeadlessBrowserContext::Builder::SetDiskCacheDir(
const base::FilePath& disk_cache_dir) { … }
HeadlessBrowserContext::Builder&
HeadlessBrowserContext::Builder::SetIncognitoMode(bool incognito_mode) { … }
HeadlessBrowserContext::Builder&
HeadlessBrowserContext::Builder::SetBlockNewWebContents(
bool block_new_web_contents) { … }
HeadlessBrowserContext* HeadlessBrowserContext::Builder::Build() { … }
}