14#pragma GCC diagnostic ignored "-Wunused-parameter"
15#pragma GCC diagnostic ignored "-Wshadow"
27#include "include/base/cef_build.h"
40 CefDoMessageLoopWork();
55 void Visit(
const CefString &str)
override
87 auto handle = std::make_unique<RCefWebDisplayHandle>(args.
GetFullUrl());
89 handle->fCloseBrowser =
false;
102 handle->WaitForContent(wait_tmout, args.
GetExtraArgs());
108 bool use_views =
true;
111 if ((env_use_views ==
"yes") || (env_use_views ==
"1"))
113 else if ((env_use_views ==
"no") || (env_use_views ==
"0"))
117 CefSettings settings;
120 if (ceflog ==
"fatal")
121 settings.log_severity = LOGSEVERITY_FATAL;
122 else if (ceflog ==
"verbose")
123 settings.log_severity = LOGSEVERITY_VERBOSE;
124 else if (ceflog ==
"info")
125 settings.log_severity = LOGSEVERITY_INFO;
126 else if (ceflog ==
"warning")
127 settings.log_severity = LOGSEVERITY_WARNING;
128 else if (ceflog ==
"error")
129 settings.log_severity = LOGSEVERITY_ERROR;
130 else if (ceflog ==
"disable")
131 settings.log_severity = LOGSEVERITY_DISABLE;
133 settings.log_severity = LOGSEVERITY_FATAL;
135 bool supress_log = (settings.log_severity == LOGSEVERITY_DISABLE) ||
136 (settings.log_severity == LOGSEVERITY_FATAL);
143 CefMainArgs main_args(GetModuleHandle(
nullptr));
149 std::vector<const char *> cef_argv = { root_app->
Argv(0) };
152 cef_argv.emplace_back(
"--disable-logging");
153 cef_argv.emplace_back(
"--enable-logging=none");
154 cef_argv.emplace_back(
"--v=-1");
157 cef_argv.emplace_back(
nullptr);
159 CefMainArgs main_args(cef_argv.size() - 1, (
char **) cef_argv.data());
181 cef_string_ascii_to_utf16(cef_main.
Data(), cef_main.
Length(), &settings.browser_subprocess_path);
186 cef_string_ascii_to_utf16(path.
Data(), path.
Length(), &settings.framework_dir_path);
192 dypath.
Append(path +
"/Libraries/");
198 cef_string_ascii_to_utf16(resource_dir.
Data(), resource_dir.
Length(), &settings.resources_dir_path);
200 cef_string_ascii_to_utf16(locales_dir.
Data(), locales_dir.
Length(), &settings.locales_dir_path);
205 cef_string_ascii_to_utf16(resource_dir.
Data(), resource_dir.
Length(), &settings.resources_dir_path);
207 cef_string_ascii_to_utf16(locales_dir.
Data(), locales_dir.
Length(), &settings.locales_dir_path);
210 settings.no_sandbox =
true;
214 settings.windowless_rendering_enabled =
true;
219 std::string plog =
"cef.log";
220 cef_string_ascii_to_utf16(plog.c_str(), plog.length(), &settings.log_file);
239 CefInitialize(main_args, settings,
fCefApp.get(),
nullptr);
242 handle->WaitForContent(wait_tmout, args.
GetExtraArgs());
283 int expired = tmout_sec * 100;
284 bool did_try =
false, print_finished =
false;
286 if (!extra_args.empty() && (extra_args.find(
"--print-to-pdf=")==0))
287 pdffile = extra_args.substr(15);
289 while ((--expired > 0) &&
GetContent().empty() && !print_finished) {
293 CefDoMessageLoopWork();
297 if (pdffile.empty()) {
300 CefPdfPrintSettings settings;
311 CefDoMessageLoopWork();
333 GetMap().emplace(
"cef", std::make_unique<CefCreator>());
struct RCefCreatorReg newRCefCreatorReg
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
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 mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
R__EXTERN TSystem * gSystem
DISALLOW_COPY_AND_ASSIGN(FrameSourceVisitor)
void Visit(const CefString &str) override
FrameSourceVisitor(RCefWebDisplayHandle *handle)
IMPLEMENT_REFCOUNTING(FrameSourceVisitor)
RCefWebDisplayHandle * fHandle
~FrameSourceVisitor() override=default
static bool PlatformResize(CefRefPtr< CefBrowser > browser, int width, int height)
static void PlatformInit()
void OnPdfPrintFinished(const CefString &, bool ok) override
~HeadlessPrintCallback() override=default
HeadlessPrintCallback(bool *flag)
IMPLEMENT_REFCOUNTING(HeadlessPrintCallback)
DISALLOW_COPY_AND_ASSIGN(HeadlessPrintCallback)
CefRefPtr< SimpleApp > fCefApp
std::unique_ptr< ROOT::RWebDisplayHandle > Display(const ROOT::RWebDisplayArgs &args) override
CefRefPtr< CefBrowser > fBrowser
associated browser
void CloseBrowser()
Closes associated browser window.
static void AddCreator()
Add CEF creator.
bool WaitForContent(int tmout_sec, const std::string &extra_args)
Process system events until browser content is available Used in headless mode for batch production l...
unsigned fValid
used to verify if instance valid or not
~RCefWebDisplayHandle() override
Destructor Closes browser window if any.
bool Resize(int, int) override
Resize browser window.
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
THttpServer * GetHttpServer() const
returns http server instance, used for window display
int GetWidth() const
returns preferable web window width
int GetY() const
set preferable web window y position
std::string GetFullUrl() const
returns window url with append options
bool IsStandalone() const
Return true if browser should runs in standalone mode.
int GetHeight() const
returns preferable web window height
bool IsHeadless() const
returns headless mode
const std::string & GetExtraArgs() const
get extra command line arguments for starting web browser command
int GetX() const
set preferable web window x position
const std::string & GetPageContent() const
returns window url
const std::string & GetContent() const
get content
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
Static holder of registered creators of web displays.
void SetContent(const std::string &cont)
set content
static std::unique_ptr< Creator > & FindCreator(const std::string &name, const std::string &libname="")
Search for specific browser creator If not found, try to add one.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
TCefTimer(Long_t milliSec, Bool_t mode)
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
static const TString & GetLibDir()
Get the library directory in the installation.
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
const char * Data() const
TString & Append(const char *cs)
virtual const char * Getenv(const char *env)
Get environment variable.
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual void Setenv(const char *name, const char *value)
Set environment variable.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Handles synchronous and a-synchronous timer events.
virtual void TurnOn()
Add the timer to the system timer list.
Helper struct to add creator.