19#pragma GCC diagnostic ignored "-Wunused-parameter"
20#pragma GCC diagnostic ignored "-Wshadow"
29#include "include/cef_browser.h"
30#include "include/cef_version.h"
31#include "include/views/cef_browser_view.h"
32#include "include/views/cef_window.h"
33#include "include/wrapper/cef_helpers.h"
45class SimpleWindowDelegate :
public CefWindowDelegate {
46 CefRefPtr<CefBrowserView> fBrowserView;
50 explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browser_view,
int width = 800,
int height = 600)
51 : fBrowserView(browser_view), fWidth(
width), fHeight(height)
55 void OnWindowCreated(CefRefPtr<CefWindow> window)
override
58 window->AddChildView(fBrowserView);
62 fBrowserView->RequestFocus();
65 void OnWindowDestroyed(CefRefPtr<CefWindow> window)
override { fBrowserView =
nullptr; }
67 bool CanClose(CefRefPtr<CefWindow> window)
override
70 CefRefPtr<CefBrowser> browser = fBrowserView->GetBrowser();
72 return browser->GetHost()->TryCloseBrowser();
76 CefSize GetPreferredSize(CefRefPtr<CefView> view)
override
78 return CefSize(fWidth, fHeight);
84 IMPLEMENT_REFCOUNTING(SimpleWindowDelegate);
85 DISALLOW_COPY_AND_ASSIGN(SimpleWindowDelegate);
89class SimpleBrowserViewDelegate :
public CefBrowserViewDelegate {
91 SimpleBrowserViewDelegate() {}
93 bool OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,
94 CefRefPtr<CefBrowserView> popup_browser_view,
95 bool is_devtools)
override {
98 CefWindow::CreateTopLevelWindow(
new SimpleWindowDelegate(popup_browser_view));
105 IMPLEMENT_REFCOUNTING(SimpleBrowserViewDelegate);
106 DISALLOW_COPY_AND_ASSIGN(SimpleBrowserViewDelegate);
113 THttpServer *serv,
const std::string &url,
const std::string &cont,
114 int width,
int height,
bool headless)
119#if defined(OS_WIN) || defined(OS_LINUX)
170 CEF_REQUIRE_UI_THREAD();
182 CEF_REQUIRE_UI_THREAD();
191 if(addr.empty() && !cont.empty()) {
201 CefBrowserSettings browser_settings;
209 CefRefPtr<CefBrowserView> browser_view =
210 CefBrowserView::CreateBrowserView(
fGuiHandler, url, browser_settings,
nullptr,
nullptr,
new SimpleBrowserViewDelegate());
213 CefWindow::CreateTopLevelWindow(
new SimpleWindowDelegate(browser_view, rect.width, rect.height));
222 CefWindowInfo window_info;
228 RECT wnd_rect = {rect.x, rect.y, rect.x + rect.width, rect.y + rect.height};
229 if (!rect.IsEmpty()) window_info.SetAsChild(0, wnd_rect);
232 window_info.SetAsPopup(0,
"cefsimple");
235 #elif defined(OS_LINUX)
236 if (!rect.IsEmpty()) window_info.SetAsChild(0, rect);
241 window_info.SetAsChild(0, rect.x, rect.y, rect.width, rect.height );
247 auto browser = CefBrowserHost::CreateBrowserSync(window_info,
fGuiHandler, url, browser_settings,
nullptr,
nullptr);
#define R__LOG_ERROR(...)
include TDocParser_001 C image html pict1_TDocParser_001 png width
void SetBrowser(CefRefPtr< CefBrowser > br)
RCefWebDisplayHandle * fNextHandle
next handle where browser will be created
SimpleApp(bool use_viewes, THttpServer *serv=nullptr, const std::string &url="", const std::string &cont="", int width=0, int height=0, bool headless=false)
std::string fFirstUrl
! first URL to open
bool fUseViewes
! is views framework used
virtual void OnContextInitialized() override
THttpServer * fFirstServer
! first server
void StartWindow(THttpServer *serv, const std::string &url, const std::string &cont, CefRect &rect)
virtual void OnBeforeChildProcessLaunch(CefRefPtr< CefCommandLine > command_line) override
CefRect fFirstRect
! original width
void SetNextHandle(RCefWebDisplayHandle *handle)
virtual void OnRegisterCustomSchemes(CefRawPtr< CefSchemeRegistrar > registrar) override
CefRefPtr< GuiHandler > fGuiHandler
! normal handler
std::string fFirstContent
! first page content open
virtual void OnBeforeCommandLineProcessing(const CefString &process_type, CefRefPtr< CefCommandLine > command_line) override
ROOT::Experimental::RLogChannel & CefWebDisplayLog()