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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_COMMON_MAIN_DELEGATE_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_MAIN_DELEGATE_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "include/cef_app.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "libcef/common/content_client.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
|
|
|
}
|
|
|
|
|
|
|
|
class CefContentBrowserClient;
|
|
|
|
class CefContentRendererClient;
|
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.
|
2012-04-03 03:34:16 +02:00
|
|
|
class CefMainDelegate : public content::ContentMainDelegate {
|
|
|
|
public:
|
2020-06-24 22:26:12 +02:00
|
|
|
class Runner {
|
|
|
|
public:
|
|
|
|
virtual void PreCreateMainMessageLoop() = 0;
|
|
|
|
virtual int RunMainProcess(
|
|
|
|
const content::MainFunctionParams& main_function_params) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~Runner() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// |runner| and |settings| will be non-nullptr for the main process only,
|
|
|
|
// and will outlive this object.
|
|
|
|
CefMainDelegate(Runner* runner,
|
|
|
|
CefSettings* settings,
|
|
|
|
CefRefPtr<CefApp> application);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefMainDelegate() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2018-09-06 14:40:36 +02:00
|
|
|
void PreCreateMainMessageLoop() 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
|
|
|
|
|
|
|
CefContentBrowserClient* browser_client() { return browser_client_.get(); }
|
|
|
|
CefContentClient* content_client() { return &content_client_; }
|
|
|
|
|
2020-06-24 22:26:12 +02:00
|
|
|
// Called from MainRunner at various initialization/shutdown stages to create
|
|
|
|
// and clean up global state.
|
|
|
|
static void CefInitialize();
|
|
|
|
static void MainThreadInitialize();
|
|
|
|
static void UIThreadInitialize();
|
|
|
|
static void UIThreadShutdown();
|
|
|
|
static void MainThreadShutdown();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
|
|
|
void InitializeResourceBundle();
|
|
|
|
|
2020-06-24 22:26:12 +02:00
|
|
|
Runner* const runner_;
|
|
|
|
CefSettings* const settings_;
|
2012-04-11 20:00:55 +02:00
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<CefContentBrowserClient> browser_client_;
|
|
|
|
std::unique_ptr<CefContentRendererClient> renderer_client_;
|
2019-10-01 15:55:16 +02:00
|
|
|
std::unique_ptr<ChromeContentUtilityClient> utility_client_;
|
2012-04-03 03:34:16 +02:00
|
|
|
CefContentClient content_client_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefMainDelegate);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_MAIN_DELEGATE_H_
|