19#pragma GCC diagnostic ignored "-Wunused-parameter"
20#pragma GCC diagnostic ignored "-Wshadow"
29#include "include/base/cef_build.h"
30#include "include/cef_browser.h"
31#include "include/cef_version.h"
32#include "include/views/cef_browser_view.h"
33#include "include/views/cef_window.h"
34#include "include/wrapper/cef_helpers.h"
46class SimpleWindowDelegate :
public CefWindowDelegate {
47 CefRefPtr<CefBrowserView> fBrowserView;
52 explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browser_view,
int width = 800,
int height = 600,
bool batch =
false)
53 : fBrowserView(browser_view), fWidth(
width), fHeight(
height), fBatch(batch)
57 void OnWindowCreated(CefRefPtr<CefWindow> window)
override
59 window->AddChildView(fBrowserView);
66 fBrowserView->RequestFocus();
70 void OnWindowDestroyed(CefRefPtr<CefWindow> window)
override { fBrowserView =
nullptr; }
72 bool CanClose(CefRefPtr<CefWindow> window)
override
75 CefRefPtr<CefBrowser> browser = fBrowserView->GetBrowser();
77 return browser->GetHost()->TryCloseBrowser();
81 CefSize GetPreferredSize(CefRefPtr<CefView> view)
override
83 return CefSize(fWidth, fHeight);
89 IMPLEMENT_REFCOUNTING(SimpleWindowDelegate);
90 DISALLOW_COPY_AND_ASSIGN(SimpleWindowDelegate);
94class SimpleBrowserViewDelegate :
public CefBrowserViewDelegate {
96 SimpleBrowserViewDelegate() {}
98 bool OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,
99 CefRefPtr<CefBrowserView> popup_browser_view,
100 bool is_devtools)
override {
103 CefWindow::CreateTopLevelWindow(
new SimpleWindowDelegate(popup_browser_view));
110 IMPLEMENT_REFCOUNTING(SimpleBrowserViewDelegate);
111 DISALLOW_COPY_AND_ASSIGN(SimpleBrowserViewDelegate);
118 THttpServer *serv,
const std::string &url,
const std::string &cont,
125#if defined(OS_WIN) || defined(OS_LINUX)
156 command_line->AppendSwitchWithValue(
"v",
"-1");
157 command_line->AppendSwitch(
"disable-logging");
158 command_line->AppendSwitchWithValue(
"enable-logging",
"none");
162 command_line->AppendSwitchWithValue(
"user-data-dir",
".");
163 command_line->AppendSwitch(
"allow-file-access-from-files");
164 command_line->AppendSwitch(
"disable-web-security");
165 command_line->AppendSwitch(
"off-screen-rendering-enabled");
170 command_line->AppendSwitch(
"headless");
171 command_line->AppendSwitchWithValue(
"use-angle",
"swiftshader");
172 command_line->AppendSwitch(
"enable-unsafe-swiftshader");
173 command_line->AppendSwitch(
"disable-gpu");
178 command_line->AppendSwitchWithValue(
"use-angle",
"metal");
179 command_line->AppendSwitch(
"ignore-gpu-blocklist");
180 command_line->AppendSwitch(
"enable-webgl");
186 command_line->AppendSwitch(
"headless");
187 command_line->AppendSwitchWithValue(
"use-gl",
"swiftshader");
188 command_line->AppendSwitch(
"disable-gpu");
189 command_line->AppendSwitch(
"ignore-gpu-blocklist");
190 command_line->AppendSwitch(
"enable-unsafe-swiftshader");
193 command_line->AppendSwitchWithValue(
"ozone-platform",
"headless");
204 CEF_REQUIRE_UI_THREAD();
216 CEF_REQUIRE_UI_THREAD();
218 bool is_batch = (addr.empty() && !cont.empty()) || is_headless;
233 CefBrowserSettings browser_settings;
235 browser_settings.windowless_frame_rate = 30;
243 CefRefPtr<CefBrowserView> browser_view =
244 CefBrowserView::CreateBrowserView(
fGuiHandler, url, browser_settings,
nullptr,
nullptr,
new SimpleBrowserViewDelegate());
247 CefWindow::CreateTopLevelWindow(
new SimpleWindowDelegate(browser_view,
rect.width,
rect.height, is_batch));
250 fNextHandle->SetBrowser(browser_view->GetBrowser());
256 CefWindowInfo window_info;
263 window_info.SetAsChild(0,
rect);
266 window_info.SetAsPopup(0,
"cefsimple");
269 window_info.SetAsWindowless(kNullWindowHandle);
272 window_info.SetAsChild(0,
rect);
274 window_info.SetAsWindowless(kNullWindowHandle);
278 auto browser = CefBrowserHost::CreateBrowserSync(window_info,
fGuiHandler, url, browser_settings,
nullptr,
nullptr);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
RCefWebDisplayHandle * fNextHandle
next handle where browser will be created
bool fNextHeadless
if next handle display is headless
std::string fFirstUrl
! first URL to open
void SetNextHandle(RCefWebDisplayHandle *handle, bool headless)
bool fUseViewes
! is views framework used
void OnContextInitialized() override
THttpServer * fFirstServer
! first server
bool fFirstHeadless
! is first window is headless
bool fSupressLog
! supress log output when possible
void OnBeforeChildProcessLaunch(CefRefPtr< CefCommandLine > command_line) override
CefRect fFirstRect
! original width
void OnRegisterCustomSchemes(CefRawPtr< CefSchemeRegistrar > registrar) override
CefRefPtr< GuiHandler > fGuiHandler
! normal handler
std::string fFirstContent
! first page content open
SimpleApp(bool use_viewes, bool supress_log, THttpServer *serv=nullptr, const std::string &url="", const std::string &cont="", int width=0, int height=0, bool headless=false)
void StartWindow(THttpServer *serv, const std::string &url, const std::string &cont, CefRect &rect, bool is_headless=false)
void OnBeforeCommandLineProcessing(const CefString &process_type, CefRefPtr< CefCommandLine > command_line) override
Online http server for arbitrary ROOT application.