Logo ROOT  
Reference Guide
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-2019, 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
31
32#if CEF_VERSION_MAJOR < 95
33typedef CefRequestCallback CefResourceLoadCallBack ;
34#else
35typedef CefCallback CefResourceLoadCallBack;
36#endif
37
38
39class THttpServer;
40
41/** \class GuiHandler
42\ingroup cefwebdisplay
43*/
44
45class GuiHandler : public CefClient,
46 public CefLifeSpanHandler,
47 public CefLoadHandler,
48 public CefDisplayHandler,
49 public CefRequestHandler,
51protected:
52
53 bool fUseViews{false}; ///<! if view framework is used, required for true headless mode
54 int fConsole{0}; ///<! console parameter, assigned via WebGui.Console rootrc parameter
55 typedef std::list<CefRefPtr<CefBrowser>> BrowserList; ///<! List of existing browser windows. Only accessed on the CEF UI thread.
57
58 std::vector<THttpServer *> fServers;
59
61
62public:
63 explicit GuiHandler(bool use_views = false);
64
65 // Provide access to the single global instance of this object.
66 // static BaseHandler *GetInstance();
67
68 // CefClient methods:
69 virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; }
70 virtual CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
71 virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; }
72 virtual CefRefPtr<CefRequestHandler> GetRequestHandler() override { return this; }
73
74 // CefLifeSpanHandler methods:
75 virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
76 virtual bool DoClose(CefRefPtr<CefBrowser> browser) override;
77 virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
78
79 // CefLoadHandler methods:
80 virtual void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode,
81 const CefString &errorText, const CefString &failedUrl) override;
82
83 // CefDisplayHandler methods:
84 virtual void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString &title) override;
85
86 virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
87 cef_log_severity_t level,
88 const CefString &message, const CefString &source,
89 int line) override;
90
91 // Request that all existing browser windows close.
92 void CloseAllBrowsers(bool force_close);
93
94 bool IsClosing() const { return is_closing_; }
95
96 // CefRequestHandler methods:
97 virtual CefRefPtr<CefResourceRequestHandler> GetResourceRequestHandler(
98 CefRefPtr<CefBrowser> browser,
99 CefRefPtr<CefFrame> frame,
100 CefRefPtr<CefRequest> request,
101 bool is_navigation,
102 bool is_download,
103 const CefString& request_initiator,
104 bool& disable_default_handling) override { return this; }
105
106 // CefResourceRequestHandler methods:
107 virtual cef_return_value_t OnBeforeResourceLoad(
108 CefRefPtr<CefBrowser> browser,
109 CefRefPtr<CefFrame> frame,
110 CefRefPtr<CefRequest> request,
111 CefRefPtr<CefResourceLoadCallBack> callback) override;
112
113 virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
114 CefRefPtr<CefBrowser> browser,
115 CefRefPtr<CefFrame> frame,
116 CefRefPtr<CefRequest> request) override;
117
118 std::string AddBatchPage(const std::string &cont);
119
120 std::string MakePageUrl(THttpServer *serv, const std::string &addr);
121
122 static bool PlatformInit();
123
124 static std::string GetDataURI(const std::string& data, const std::string& mime_type);
125
126private:
127
128 // Platform-specific implementation.
129 void PlatformTitleChange(CefRefPtr<CefBrowser> browser, const CefString &title);
130
131 CefRefPtr<CefResourceManager> fResourceManager;
133
134 // Include the default reference counting implementation.
137};
138
139
140#endif // ROOT_cef_gui_handler_h
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
const char * mime_type
Definition: civetweb.c:8026
CefRefPtr< CefResourceManager > fResourceManager
Definition: gui_handler.h:131
bool is_closing_
Definition: gui_handler.h:60
int fConsole
! console parameter, assigned via WebGui.Console rootrc parameter
Definition: gui_handler.h:54
virtual CefRefPtr< CefDisplayHandler > GetDisplayHandler() override
Definition: gui_handler.h:71
GuiHandler(bool use_views=false)
Definition: gui_handler.cxx:51
std::vector< THttpServer * > fServers
Definition: gui_handler.h:58
virtual void OnBeforeClose(CefRefPtr< CefBrowser > browser) override
virtual CefRefPtr< CefResourceHandler > GetResourceHandler(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request) override
virtual CefRefPtr< CefLoadHandler > GetLoadHandler() override
Definition: gui_handler.h:70
virtual bool DoClose(CefRefPtr< CefBrowser > browser) override
Definition: gui_handler.cxx:85
virtual CefRefPtr< CefLifeSpanHandler > GetLifeSpanHandler() override
Definition: gui_handler.h:69
BrowserList fBrowserList
Definition: gui_handler.h:56
void CloseAllBrowsers(bool force_close)
virtual CefRefPtr< CefRequestHandler > GetRequestHandler() override
Definition: gui_handler.h:72
IMPLEMENT_REFCOUNTING(GuiHandler)
int fBatchPageCount
Definition: gui_handler.h:132
void PlatformTitleChange(CefRefPtr< CefBrowser > browser, const CefString &title)
virtual 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:97
bool IsClosing() const
Definition: gui_handler.h:94
virtual 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:53
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...
virtual bool OnConsoleMessage(CefRefPtr< CefBrowser > browser, cef_log_severity_t level, const CefString &message, const CefString &source, int line) override
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:55
virtual void OnTitleChange(CefRefPtr< CefBrowser > browser, const CefString &title) override
Definition: gui_handler.cxx:60
static bool PlatformInit()
virtual void OnAfterCreated(CefRefPtr< CefBrowser > browser) override
Definition: gui_handler.cxx:77
virtual cef_return_value_t OnBeforeResourceLoad(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request, CefRefPtr< CefResourceLoadCallBack > callback) 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()
Definition: gui_handler.cxx:44
CefRequestCallback CefResourceLoadCallBack
Definition: gui_handler.h:33
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.