2020-06-25 04:34:12 +02:00
|
|
|
// Copyright 2020 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright 2012 The Chromium 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_CHROME_CHROME_MAIN_DELEGATE_CEF_
|
|
|
|
#define CEF_LIBCEF_COMMON_CHROME_CHROME_MAIN_DELEGATE_CEF_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_app.h"
|
|
|
|
#include "cef/libcef/common/app_manager.h"
|
|
|
|
#include "cef/libcef/common/chrome/chrome_content_client_cef.h"
|
|
|
|
#include "cef/libcef/common/main_runner_handler.h"
|
2024-05-03 18:50:23 +02:00
|
|
|
#include "cef/libcef/common/resource_bundle_delegate.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/common/task_runner_manager.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
#include "chrome/app/chrome_main_delegate.h"
|
|
|
|
|
|
|
|
class ChromeContentBrowserClientCef;
|
2020-09-25 03:40:47 +02:00
|
|
|
class ChromeContentRendererClientCef;
|
2020-06-25 04:34:12 +02:00
|
|
|
|
|
|
|
// CEF override of ChromeMainDelegate
|
|
|
|
class ChromeMainDelegateCef : public ChromeMainDelegate,
|
2020-06-28 23:05:36 +02:00
|
|
|
public CefAppManager,
|
2020-06-25 04:34:12 +02:00
|
|
|
public CefTaskRunnerManager {
|
|
|
|
public:
|
|
|
|
// |runner| will be non-nullptr for the main process only, and will outlive
|
|
|
|
// this object.
|
2020-06-28 23:05:36 +02:00
|
|
|
ChromeMainDelegateCef(CefMainRunnerHandler* runner,
|
2020-07-06 20:14:57 +02:00
|
|
|
CefSettings* settings,
|
2020-06-28 23:05:36 +02:00
|
|
|
CefRefPtr<CefApp> application);
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
ChromeMainDelegateCef(const ChromeMainDelegateCef&) = delete;
|
|
|
|
ChromeMainDelegateCef& operator=(const ChromeMainDelegateCef&) = delete;
|
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
~ChromeMainDelegateCef() override;
|
|
|
|
|
|
|
|
// ChromeMainDelegate overrides.
|
2023-12-06 21:16:15 +01:00
|
|
|
std::optional<int> BasicStartupComplete() override;
|
2020-07-06 20:14:57 +02:00
|
|
|
void PreSandboxStartup() override;
|
2024-05-02 21:36:20 +02:00
|
|
|
void SandboxInitialized(const std::string& process_type) override;
|
2023-12-06 21:16:15 +01:00
|
|
|
std::optional<int> PreBrowserMain() override;
|
|
|
|
std::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;
|
2021-12-16 23:35:54 +01:00
|
|
|
absl::variant<int, content::MainFunctionParams> RunProcess(
|
2020-06-25 04:34:12 +02:00
|
|
|
const std::string& process_type,
|
2021-12-16 23:35:54 +01:00
|
|
|
content::MainFunctionParams main_function_params) override;
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2020-07-06 20:14:57 +02:00
|
|
|
void ZygoteForked() override;
|
|
|
|
#endif
|
2020-06-28 23:05:36 +02:00
|
|
|
content::ContentClient* CreateContentClient() override;
|
2020-06-25 04:34:12 +02:00
|
|
|
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
2020-09-25 03:40:47 +02:00
|
|
|
content::ContentRendererClient* CreateContentRendererClient() override;
|
2020-06-25 04:34:12 +02:00
|
|
|
|
|
|
|
protected:
|
2020-06-28 23:05:36 +02:00
|
|
|
// CefAppManager overrides.
|
|
|
|
CefRefPtr<CefApp> GetApplication() override { return application_; }
|
|
|
|
content::ContentClient* GetContentClient() override {
|
|
|
|
return &chrome_content_client_cef_;
|
|
|
|
}
|
|
|
|
CefRefPtr<CefRequestContext> GetGlobalRequestContext() override;
|
2020-07-01 02:57:00 +02:00
|
|
|
CefBrowserContext* CreateNewBrowserContext(
|
2021-04-07 00:09:45 +02:00
|
|
|
const CefRequestContextSettings& settings,
|
|
|
|
base::OnceClosure initialized_cb) override;
|
2020-06-28 23:05:36 +02:00
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
// CefTaskRunnerManager overrides.
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
|
|
|
|
override;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetUserVisibleTaskRunner()
|
|
|
|
override;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetUserBlockingTaskRunner()
|
|
|
|
override;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetRenderTaskRunner() override;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetWebWorkerTaskRunner() override;
|
|
|
|
|
2024-05-03 18:50:23 +02:00
|
|
|
// ChromeMainDelegate overrides.
|
|
|
|
ui::ResourceBundle::Delegate* GetResourceBundleDelegate() override {
|
|
|
|
return &resource_bundle_delegate_;
|
|
|
|
}
|
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
private:
|
|
|
|
ChromeContentBrowserClientCef* content_browser_client() const;
|
2020-09-25 03:40:47 +02:00
|
|
|
ChromeContentRendererClientCef* content_renderer_client() const;
|
2020-06-25 04:34:12 +02:00
|
|
|
|
|
|
|
CefMainRunnerHandler* const runner_;
|
2020-07-06 20:14:57 +02:00
|
|
|
CefSettings* const settings_;
|
2020-06-28 23:05:36 +02:00
|
|
|
CefRefPtr<CefApp> application_;
|
|
|
|
|
|
|
|
// We use this instead of ChromeMainDelegate::chrome_content_client_.
|
|
|
|
ChromeContentClientCef chrome_content_client_cef_;
|
2024-05-03 18:50:23 +02:00
|
|
|
|
|
|
|
CefResourceBundleDelegate resource_bundle_delegate_;
|
2020-06-25 04:34:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_CHROME_CHROME_MAIN_DELEGATE_CEF_
|