2012-04-03 01:34:16 +00:00
|
|
|
// Copyright (c) 2011 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.
|
|
|
|
|
2020-06-28 14:29:44 -04:00
|
|
|
#ifndef CEF_LIBCEF_COMMON_ALLOY_ALLOY_MAIN_DELEGATE_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_ALLOY_ALLOY_MAIN_DELEGATE_H_
|
2012-04-03 01:34:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/cef_app.h"
|
2020-06-28 14:29:44 -04:00
|
|
|
#include "libcef/common/alloy/alloy_content_client.h"
|
2020-06-28 17:05:36 -04:00
|
|
|
#include "libcef/common/app_manager.h"
|
2020-06-24 22:34:12 -04:00
|
|
|
#include "libcef/common/main_runner_handler.h"
|
2020-06-28 17:05:36 -04:00
|
|
|
#include "libcef/common/resource_bundle_delegate.h"
|
2020-06-24 22:34:12 -04:00
|
|
|
#include "libcef/common/task_runner_manager.h"
|
2012-04-03 01:34:16 +00:00
|
|
|
|
|
|
|
#include "content/public/app/content_main_delegate.h"
|
|
|
|
|
2012-04-11 18:00:55 +00:00
|
|
|
namespace base {
|
2016-10-17 14:14:44 -04:00
|
|
|
class CommandLine;
|
2012-04-03 01:34:16 +00:00
|
|
|
}
|
|
|
|
|
2020-06-28 14:29:44 -04:00
|
|
|
class AlloyContentBrowserClient;
|
|
|
|
class AlloyContentRendererClient;
|
2019-10-01 13:55:16 +00:00
|
|
|
class ChromeContentUtilityClient;
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2020-06-24 16:26:12 -04:00
|
|
|
// Manages state specific to the CEF runtime.
|
2020-06-28 14:29:44 -04:00
|
|
|
class AlloyMainDelegate : public content::ContentMainDelegate,
|
2020-06-28 17:05:36 -04:00
|
|
|
public CefAppManager,
|
2020-06-28 14:29:44 -04:00
|
|
|
public CefTaskRunnerManager {
|
2012-04-03 01:34:16 +00:00
|
|
|
public:
|
2020-06-24 16:26:12 -04:00
|
|
|
// |runner| and |settings| will be non-nullptr for the main process only,
|
|
|
|
// and will outlive this object.
|
2020-06-28 14:29:44 -04:00
|
|
|
AlloyMainDelegate(CefMainRunnerHandler* runner,
|
|
|
|
CefSettings* settings,
|
|
|
|
CefRefPtr<CefApp> application);
|
2021-12-06 15:40:25 -05:00
|
|
|
|
|
|
|
AlloyMainDelegate(const AlloyMainDelegate&) = delete;
|
|
|
|
AlloyMainDelegate& operator=(const AlloyMainDelegate&) = delete;
|
|
|
|
|
2020-06-28 14:29:44 -04:00
|
|
|
~AlloyMainDelegate() override;
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2020-06-24 22:34:12 -04:00
|
|
|
// content::ContentMainDelegate overrides.
|
2022-07-25 13:49:32 -04:00
|
|
|
absl::optional<int> PreBrowserMain() override;
|
|
|
|
absl::optional<int> BasicStartupComplete() override;
|
2014-11-12 19:25:15 +00:00
|
|
|
void PreSandboxStartup() override;
|
2021-12-16 17:35:54 -05:00
|
|
|
absl::variant<int, content::MainFunctionParams> RunProcess(
|
2012-04-03 01:34:16 +00:00
|
|
|
const std::string& process_type,
|
2021-12-16 17:35:54 -05:00
|
|
|
content::MainFunctionParams main_function_params) override;
|
2014-11-12 19:25:15 +00:00
|
|
|
void ProcessExiting(const std::string& process_type) override;
|
2022-01-24 12:58:02 -05:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2014-11-12 19:25:15 +00:00
|
|
|
void ZygoteForked() override;
|
2013-11-21 22:43:36 +00:00
|
|
|
#endif
|
2014-11-12 19:25:15 +00:00
|
|
|
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
2017-05-17 11:29:28 +02:00
|
|
|
content::ContentRendererClient* CreateContentRendererClient() override;
|
2014-11-12 19:25:15 +00:00
|
|
|
content::ContentUtilityClient* CreateContentUtilityClient() override;
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2020-06-24 22:34:12 -04:00
|
|
|
protected:
|
2020-06-28 17:05:36 -04:00
|
|
|
// CefAppManager overrides.
|
|
|
|
CefRefPtr<CefApp> GetApplication() override { return application_; }
|
|
|
|
content::ContentClient* GetContentClient() override {
|
|
|
|
return &content_client_;
|
|
|
|
}
|
|
|
|
CefRefPtr<CefRequestContext> GetGlobalRequestContext() override;
|
2020-06-30 20:57:00 -04:00
|
|
|
CefBrowserContext* CreateNewBrowserContext(
|
2021-04-06 18:09:45 -04:00
|
|
|
const CefRequestContextSettings& settings,
|
|
|
|
base::OnceClosure initialized_cb) override;
|
2020-06-28 17:05:36 -04:00
|
|
|
|
2020-06-24 22:34:12 -04: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;
|
2020-06-24 16:26:12 -04:00
|
|
|
|
2012-04-03 01:34:16 +00:00
|
|
|
private:
|
|
|
|
void InitializeResourceBundle();
|
|
|
|
|
2020-06-24 22:34:12 -04:00
|
|
|
CefMainRunnerHandler* const runner_;
|
2020-06-24 16:26:12 -04:00
|
|
|
CefSettings* const settings_;
|
2020-06-28 17:05:36 -04:00
|
|
|
CefRefPtr<CefApp> application_;
|
2012-04-11 18:00:55 +00:00
|
|
|
|
2020-06-28 14:29:44 -04:00
|
|
|
std::unique_ptr<AlloyContentBrowserClient> browser_client_;
|
|
|
|
std::unique_ptr<AlloyContentRendererClient> renderer_client_;
|
2019-10-01 13:55:16 +00:00
|
|
|
std::unique_ptr<ChromeContentUtilityClient> utility_client_;
|
2020-06-28 14:29:44 -04:00
|
|
|
AlloyContentClient content_client_;
|
2012-04-03 01:34:16 +00:00
|
|
|
|
2020-06-28 17:05:36 -04:00
|
|
|
CefResourceBundleDelegate resource_bundle_delegate_;
|
2012-04-03 01:34:16 +00:00
|
|
|
};
|
|
|
|
|
2020-06-28 14:29:44 -04:00
|
|
|
#endif // CEF_LIBCEF_COMMON_ALLOY_ALLOY_MAIN_DELEGATE_H_
|