2020-06-28 23:05:36 +02:00
|
|
|
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_COMMON_APP_MANAGER_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_APP_MANAGER_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "base/functional/callback.h"
|
2020-06-28 23:05:36 +02:00
|
|
|
#include "build/build_config.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_app.h"
|
|
|
|
#include "cef/include/cef_request_context.h"
|
2020-06-28 23:05:36 +02:00
|
|
|
#include "content/public/common/content_client.h"
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
class CefBrowserContext;
|
2020-06-28 23:05:36 +02:00
|
|
|
struct CefSchemeInfo;
|
|
|
|
|
|
|
|
// Exposes global application state in the main and render processes.
|
|
|
|
class CefAppManager {
|
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
CefAppManager(const CefAppManager&) = delete;
|
|
|
|
CefAppManager& operator=(const CefAppManager&) = delete;
|
|
|
|
|
2020-06-28 23:05:36 +02:00
|
|
|
// Returns the singleton instance that is scoped to CEF lifespan.
|
|
|
|
static CefAppManager* Get();
|
|
|
|
|
|
|
|
// The following methods are available in both processes.
|
|
|
|
|
|
|
|
virtual CefRefPtr<CefApp> GetApplication() = 0;
|
|
|
|
virtual content::ContentClient* GetContentClient() = 0;
|
|
|
|
|
|
|
|
// Custom scheme information will be registered first with all processes
|
|
|
|
// (url/url_util.h) via ContentClient::AddAdditionalSchemes which calls
|
|
|
|
// AddCustomScheme, and second with Blink (SchemeRegistry) via
|
|
|
|
// ContentRendererClient::WebKitInitialized which calls GetCustomSchemes.
|
2023-11-17 00:19:27 +01:00
|
|
|
void AddCustomScheme(const CefSchemeInfo* scheme_info);
|
2020-06-28 23:05:36 +02:00
|
|
|
bool HasCustomScheme(const std::string& scheme_name);
|
|
|
|
|
|
|
|
using SchemeInfoList = std::list<CefSchemeInfo>;
|
|
|
|
const SchemeInfoList* GetCustomSchemes();
|
|
|
|
|
|
|
|
// Called from ContentClient::AddAdditionalSchemes.
|
|
|
|
void AddAdditionalSchemes(content::ContentClient::Schemes* schemes);
|
|
|
|
|
|
|
|
// The following methods are only available in the main (browser) process.
|
|
|
|
|
2021-04-07 00:09:45 +02:00
|
|
|
// Called from CefRequestContextImpl. |initialized_cb| may be executed
|
|
|
|
// synchronously or asynchronously.
|
2020-06-28 23:05:36 +02:00
|
|
|
virtual CefRefPtr<CefRequestContext> GetGlobalRequestContext() = 0;
|
2020-07-01 02:57:00 +02:00
|
|
|
virtual CefBrowserContext* CreateNewBrowserContext(
|
2021-04-07 00:09:45 +02:00
|
|
|
const CefRequestContextSettings& settings,
|
|
|
|
base::OnceClosure initialized_cb) = 0;
|
2020-06-28 23:05:36 +02:00
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2020-06-28 23:05:36 +02:00
|
|
|
// Returns the module name (usually libcef.dll).
|
|
|
|
const wchar_t* GetResourceDllName();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CefAppManager();
|
|
|
|
virtual ~CefAppManager();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Custom schemes handled by the client.
|
|
|
|
SchemeInfoList scheme_info_list_;
|
|
|
|
bool scheme_info_list_locked_ = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_APP_MANAGER_H_
|