2015-01-23 00:11:30 +01:00
|
|
|
// Copyright (c) 2015 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.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_MAIN_CONTEXT_IMPL_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_MAIN_CONTEXT_IMPL_H_
|
|
|
|
#pragma once
|
2015-01-23 00:11:30 +01:00
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2015-01-29 22:44:17 +01:00
|
|
|
#include "include/base/cef_thread_checker.h"
|
2015-01-29 21:53:53 +01:00
|
|
|
#include "include/cef_app.h"
|
2015-01-23 00:11:30 +01:00
|
|
|
#include "include/cef_command_line.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/main_context.h"
|
|
|
|
#include "tests/cefclient/browser/root_window_manager.h"
|
2015-01-29 21:53:53 +01:00
|
|
|
|
2015-01-23 00:11:30 +01:00
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Used to store global context in the browser process.
|
|
|
|
class MainContextImpl : public MainContext {
|
|
|
|
public:
|
2015-01-31 05:41:36 +01:00
|
|
|
MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
2015-01-29 21:53:53 +01:00
|
|
|
bool terminate_when_all_windows_closed);
|
2015-01-23 00:11:30 +01:00
|
|
|
|
|
|
|
// MainContext members.
|
2023-11-29 02:33:44 +01:00
|
|
|
CefRefPtr<CefCommandLine> GetCommandLine() override;
|
2021-06-17 21:43:06 +02:00
|
|
|
std::string GetConsoleLogPath() override;
|
|
|
|
std::string GetDownloadPath(const std::string& file_name) override;
|
|
|
|
std::string GetAppWorkingDirectory() override;
|
2023-11-29 02:33:44 +01:00
|
|
|
std::string GetMainURL(CefRefPtr<CefCommandLine> command_line) override;
|
2021-06-17 21:43:06 +02:00
|
|
|
cef_color_t GetBackgroundColor() override;
|
|
|
|
bool UseChromeRuntime() override;
|
2023-11-14 18:16:43 +01:00
|
|
|
bool UseChromeRuntimeNative() override;
|
2021-06-17 21:43:06 +02:00
|
|
|
bool UseViews() override;
|
|
|
|
bool UseWindowlessRendering() override;
|
|
|
|
bool TouchEventsEnabled() override;
|
2022-04-11 22:54:33 +02:00
|
|
|
bool UseDefaultPopup() override;
|
2021-06-17 21:43:06 +02:00
|
|
|
void PopulateSettings(CefSettings* settings) override;
|
|
|
|
void PopulateBrowserSettings(CefBrowserSettings* settings) override;
|
|
|
|
void PopulateOsrSettings(OsrRendererSettings* settings) override;
|
|
|
|
RootWindowManager* GetRootWindowManager() override;
|
2015-01-23 00:11:30 +01:00
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
// Initialize CEF and associated main context state. This method must be
|
|
|
|
// called on the same thread that created this object.
|
|
|
|
bool Initialize(const CefMainArgs& args,
|
|
|
|
const CefSettings& settings,
|
|
|
|
CefRefPtr<CefApp> application,
|
|
|
|
void* windows_sandbox_info);
|
|
|
|
|
|
|
|
// Shut down CEF and associated context state. This method must be called on
|
|
|
|
// the same thread that created this object.
|
|
|
|
void Shutdown();
|
|
|
|
|
2015-01-23 00:11:30 +01:00
|
|
|
private:
|
2021-06-17 22:08:01 +02:00
|
|
|
// Allow deletion via std::unique_ptr only.
|
|
|
|
friend std::default_delete<MainContextImpl>;
|
2015-01-23 00:11:30 +01:00
|
|
|
|
2024-01-20 03:22:56 +01:00
|
|
|
~MainContextImpl() override;
|
2015-01-29 21:53:53 +01:00
|
|
|
|
|
|
|
// Returns true if the context is in a valid state (initialized and not yet
|
|
|
|
// shut down).
|
2017-05-17 11:29:28 +02:00
|
|
|
bool InValidState() const { return initialized_ && !shutdown_; }
|
2015-01-29 21:53:53 +01:00
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
CefRefPtr<CefCommandLine> command_line_;
|
2015-01-29 21:53:53 +01:00
|
|
|
const bool terminate_when_all_windows_closed_;
|
|
|
|
|
|
|
|
// Track context state. Accessing these variables from multiple threads is
|
|
|
|
// safe because only a single thread will exist at the time that they're set
|
|
|
|
// (during context initialization and shutdown).
|
2022-03-21 22:22:07 +01:00
|
|
|
bool initialized_ = false;
|
|
|
|
bool shutdown_ = false;
|
2015-01-23 00:11:30 +01:00
|
|
|
|
2022-03-21 22:22:07 +01:00
|
|
|
cef_color_t background_color_ = 0;
|
|
|
|
cef_color_t browser_background_color_ = 0;
|
2016-01-19 21:09:01 +01:00
|
|
|
bool use_windowless_rendering_;
|
2022-03-21 22:22:07 +01:00
|
|
|
int windowless_frame_rate_ = 0;
|
2021-02-18 02:58:25 +01:00
|
|
|
bool use_chrome_runtime_;
|
2023-11-14 18:16:43 +01:00
|
|
|
bool use_chrome_runtime_native_ = false;
|
2016-01-19 21:09:01 +01:00
|
|
|
bool use_views_;
|
2015-01-23 00:11:30 +01:00
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
std::unique_ptr<RootWindowManager> root_window_manager_;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2018-09-26 13:25:58 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
bool shared_texture_enabled_;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool external_begin_frame_enabled_;
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
// Used to verify that methods are called on the correct thread.
|
|
|
|
base::ThreadChecker thread_checker_;
|
|
|
|
|
2015-01-23 00:11:30 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(MainContextImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_MAIN_CONTEXT_IMPL_H_
|