2012-04-03 03:34:16 +02: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 20:29:44 +02:00
|
|
|
#ifndef CEF_LIBCEF_COMMON_ALLOY_ALLOY_MAIN_DELEGATE_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_ALLOY_ALLOY_MAIN_DELEGATE_H_
|
2012-04-03 03:34:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/cef_app.h"
|
2020-06-28 20:29:44 +02:00
|
|
|
#include "libcef/common/alloy/alloy_content_client.h"
|
2020-06-28 23:05:36 +02:00
|
|
|
#include "libcef/common/app_manager.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
#include "libcef/common/main_runner_handler.h"
|
2020-06-28 23:05:36 +02:00
|
|
|
#include "libcef/common/resource_bundle_delegate.h"
|
2020-06-25 04:34:12 +02:00
|
|
|
#include "libcef/common/task_runner_manager.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "content/public/app/content_main_delegate.h"
|
|
|
|
|
2012-04-11 20:00:55 +02:00
|
|
|
namespace base {
|
2016-10-17 20:14:44 +02:00
|
|
|
class CommandLine;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
class AlloyContentBrowserClient;
|
|
|
|
class AlloyContentRendererClient;
|
2019-10-01 15:55:16 +02:00
|
|
|
class ChromeContentUtilityClient;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-24 22:26:12 +02:00
|
|
|
// Manages state specific to the CEF runtime.
|
2020-06-28 20:29:44 +02:00
|
|
|
class AlloyMainDelegate : public content::ContentMainDelegate,
|
2020-06-28 23:05:36 +02:00
|
|
|
public CefAppManager,
|
2020-06-28 20:29:44 +02:00
|
|
|
public CefTaskRunnerManager {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2020-06-24 22:26:12 +02:00
|
|
|
// |runner| and |settings| will be non-nullptr for the main process only,
|
|
|
|
// and will outlive this object.
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyMainDelegate(CefMainRunnerHandler* runner,
|
|
|
|
CefSettings* settings,
|
|
|
|
CefRefPtr<CefApp> application);
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
AlloyMainDelegate(const AlloyMainDelegate&) = delete;
|
|
|
|
AlloyMainDelegate& operator=(const AlloyMainDelegate&) = delete;
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
~AlloyMainDelegate() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
// content::ContentMainDelegate overrides.
|
2021-06-04 03:34:56 +02:00
|
|
|
void PreBrowserMain() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
bool BasicStartupComplete(int* exit_code) override;
|
|
|
|
void PreSandboxStartup() override;
|
2015-07-16 23:40:01 +02:00
|
|
|
void SandboxInitialized(const std::string& process_type) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
int RunProcess(
|
2012-04-03 03:34:16 +02:00
|
|
|
const std::string& process_type,
|
2014-11-12 20:25:15 +01:00
|
|
|
const content::MainFunctionParams& main_function_params) override;
|
|
|
|
void ProcessExiting(const std::string& process_type) override;
|
2017-12-07 22:44:24 +01:00
|
|
|
#if defined(OS_LINUX)
|
2014-11-12 20:25:15 +01:00
|
|
|
void ZygoteForked() override;
|
2013-11-21 23:43:36 +01:00
|
|
|
#endif
|
2014-11-12 20:25:15 +01:00
|
|
|
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
2017-05-17 11:29:28 +02:00
|
|
|
content::ContentRendererClient* CreateContentRendererClient() override;
|
2014-11-12 20:25:15 +01:00
|
|
|
content::ContentUtilityClient* CreateContentUtilityClient() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
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 &content_client_;
|
|
|
|
}
|
|
|
|
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;
|
2020-06-24 22:26:12 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
|
|
|
void InitializeResourceBundle();
|
|
|
|
|
2020-06-25 04:34:12 +02:00
|
|
|
CefMainRunnerHandler* const runner_;
|
2020-06-24 22:26:12 +02:00
|
|
|
CefSettings* const settings_;
|
2020-06-28 23:05:36 +02:00
|
|
|
CefRefPtr<CefApp> application_;
|
2012-04-11 20:00:55 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::unique_ptr<AlloyContentBrowserClient> browser_client_;
|
|
|
|
std::unique_ptr<AlloyContentRendererClient> renderer_client_;
|
2019-10-01 15:55:16 +02:00
|
|
|
std::unique_ptr<ChromeContentUtilityClient> utility_client_;
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentClient content_client_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2020-06-28 23:05:36 +02:00
|
|
|
CefResourceBundleDelegate resource_bundle_delegate_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#endif // CEF_LIBCEF_COMMON_ALLOY_ALLOY_MAIN_DELEGATE_H_
|