Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gui_handler.h
Go to the documentation of this file.
1// Author: Sergey Linev <S.Linev@gsi.de>
2// Date: 2017-06-29
3// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
4
5/*************************************************************************
6 * Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_cef_gui_handler_h
14#define ROOT_cef_gui_handler_h
15
16#include "include/cef_client.h"
17#include "include/base/cef_ref_counted.h"
18#include "include/cef_version.h"
19#include "include/wrapper/cef_resource_manager.h"
20#include <list>
21#include <vector>
22
23namespace ROOT {
24namespace Experimental {
25class RLogChannel;
26}
27}
28
30
31class THttpServer;
32
33/** \class GuiHandler
34\ingroup cefwebdisplay
35*/
36
37class GuiHandler : public CefClient,
38 public CefLifeSpanHandler,
39 public CefLoadHandler,
40 public CefDisplayHandler,
41 public CefRequestHandler,
43protected:
44
45 bool fUseViews{false}; ///<! if view framework is used, required for true headless mode
46 int fConsole{0}; ///<! console parameter, assigned via WebGui.Console rootrc parameter
47 typedef std::list<CefRefPtr<CefBrowser>> BrowserList; ///<! List of existing browser windows. Only accessed on the CEF UI thread.
49
50 std::vector<THttpServer *> fServers;
51
52 bool is_closing_{false};
53
54public:
55 explicit GuiHandler(bool use_views = false);
56
57 // Provide access to the single global instance of this object.
58 // static BaseHandler *GetInstance();
59
60 // CefClient methods:
61 CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; }
62 CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
63 CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; }
64 CefRefPtr<CefRequestHandler> GetRequestHandler() override { return this; }
65
66 // CefLifeSpanHandler methods:
67 void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
68 bool DoClose(CefRefPtr<CefBrowser> browser) override;
69 void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
70
71 // CefLoadHandler methods:
72 void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode,
73 const CefString &errorText, const CefString &failedUrl) override;
74
75 // CefDisplayHandler methods:
76 void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString &title) override;
77
78 bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
79 cef_log_severity_t level,
80 const CefString &message, const CefString &source,
81 int line) override;
82
83 // Request that all existing browser windows close.
84 void CloseAllBrowsers(bool force_close);
85
86 bool IsClosing() const { return is_closing_; }
87
88 // CefRequestHandler methods:
89 CefRefPtr<CefResourceRequestHandler> GetResourceRequestHandler(
90 CefRefPtr<CefBrowser> browser,
91 CefRefPtr<CefFrame> frame,
92 CefRefPtr<CefRequest> request,
93 bool is_navigation,
94 bool is_download,
95 const CefString& request_initiator,
96 bool& disable_default_handling) override { return this; }
97
98 // CefResourceRequestHandler methods:
99 cef_return_value_t OnBeforeResourceLoad(
100 CefRefPtr<CefBrowser> browser,
101 CefRefPtr<CefFrame> frame,
102 CefRefPtr<CefRequest> request,
103 CefRefPtr<CefCallback> callback) override;
104
105 CefRefPtr<CefResourceHandler> GetResourceHandler(
106 CefRefPtr<CefBrowser> browser,
107 CefRefPtr<CefFrame> frame,
108 CefRefPtr<CefRequest> request) override;
109
110 std::string AddBatchPage(const std::string &cont);
111
112 std::string MakePageUrl(THttpServer *serv, const std::string &addr);
113
114 static bool PlatformInit();
115
116 static std::string GetDataURI(const std::string& data, const std::string& mime_type);
117
118 static bool PlatformResize(CefRefPtr<CefBrowser> browser, int width, int height);
119
120private:
121
122 // Platform-specific implementation.
123 void PlatformTitleChange(CefRefPtr<CefBrowser> browser, const CefString &title);
124
125 CefRefPtr<CefResourceManager> fResourceManager;
127
128 // Include the default reference counting implementation.
131};
132
133
134#endif // ROOT_cef_gui_handler_h
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
const char * mime_type
Definition civetweb.c:8027
CefRefPtr< CefResourceManager > fResourceManager
bool is_closing_
Definition gui_handler.h:52
int fConsole
! console parameter, assigned via WebGui.Console rootrc parameter
Definition gui_handler.h:46
std::vector< THttpServer * > fServers
Definition gui_handler.h:50
void OnBeforeClose(CefRefPtr< CefBrowser > browser) override
CefRefPtr< CefResourceHandler > GetResourceHandler(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request) override
bool DoClose(CefRefPtr< CefBrowser > browser) override
CefRefPtr< CefLifeSpanHandler > GetLifeSpanHandler() override
Definition gui_handler.h:61
BrowserList fBrowserList
Definition gui_handler.h:48
static bool PlatformResize(CefRefPtr< CefBrowser > browser, int width, int height)
void CloseAllBrowsers(bool force_close)
CefRefPtr< CefRequestHandler > GetRequestHandler() override
Definition gui_handler.h:64
IMPLEMENT_REFCOUNTING(GuiHandler)
int fBatchPageCount
CefRefPtr< CefResourceRequestHandler > GetResourceRequestHandler(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request, bool is_navigation, bool is_download, const CefString &request_initiator, bool &disable_default_handling) override
Definition gui_handler.h:89
void PlatformTitleChange(CefRefPtr< CefBrowser > browser, const CefString &title)
CefRefPtr< CefDisplayHandler > GetDisplayHandler() override
Definition gui_handler.h:63
cef_return_value_t OnBeforeResourceLoad(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request, CefRefPtr< CefCallback > callback) override
bool IsClosing() const
Definition gui_handler.h:86
void OnLoadError(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, ErrorCode errorCode, const CefString &errorText, const CefString &failedUrl) override
static std::string GetDataURI(const std::string &data, const std::string &mime_type)
bool fUseViews
! if view framework is used, required for true headless mode
Definition gui_handler.h:45
std::string AddBatchPage(const std::string &cont)
Generate URL for batch page Uses file:/// prefix to let access JSROOT scripts placed on file system R...
std::string MakePageUrl(THttpServer *serv, const std::string &addr)
Generate URL for RWebWindow page Register server instance and assign it with the index Produced URL o...
bool OnConsoleMessage(CefRefPtr< CefBrowser > browser, cef_log_severity_t level, const CefString &message, const CefString &source, int line) override
CefRefPtr< CefLoadHandler > GetLoadHandler() override
Definition gui_handler.h:62
DISALLOW_COPY_AND_ASSIGN(GuiHandler)
std::list< CefRefPtr< CefBrowser > > BrowserList
! List of existing browser windows. Only accessed on the CEF UI thread.
Definition gui_handler.h:47
void OnTitleChange(CefRefPtr< CefBrowser > browser, const CefString &title) override
static bool PlatformInit()
void OnAfterCreated(CefRefPtr< CefBrowser > browser) override
A log configuration for a channel, e.g.
Definition RLogger.hxx:101
Online http server for arbitrary ROOT application.
Definition THttpServer.h:31
TLine * line
ROOT::Experimental::RLogChannel & CefWebDisplayLog()
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...