forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui_handler.h
More file actions
132 lines (98 loc) · 4.7 KB
/
Copy pathgui_handler.h
File metadata and controls
132 lines (98 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Author: Sergey Linev <S.Linev@gsi.de>
// Date: 2017-06-29
// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
/*************************************************************************
* Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_cef_gui_handler_h
#define ROOT_cef_gui_handler_h
#include "include/cef_client.h"
#include "include/base/cef_ref_counted.h"
#include "include/cef_version.h"
#include "include/wrapper/cef_resource_manager.h"
#include <list>
#include <vector>
namespace ROOT {
class RLogChannel;
}
ROOT::RLogChannel &CefWebDisplayLog();
class THttpServer;
/** \class GuiHandler
\ingroup cefwebdisplay
*/
class GuiHandler : public CefClient,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefDisplayHandler,
public CefRequestHandler,
public CefResourceRequestHandler {
protected:
bool fUseViews{false}; ///<! if view framework is used, required for true headless mode
int fConsole{0}; ///<! console parameter, assigned via WebGui.Console rootrc parameter
typedef std::list<CefRefPtr<CefBrowser>> BrowserList; ///<! List of existing browser windows. Only accessed on the CEF UI thread.
BrowserList fBrowserList;
std::vector<THttpServer *> fServers;
bool is_closing_{false};
public:
explicit GuiHandler(bool use_views = false);
// Provide access to the single global instance of this object.
// static BaseHandler *GetInstance();
// CefClient methods:
CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; }
CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; }
CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; }
CefRefPtr<CefRequestHandler> GetRequestHandler() override { return this; }
// CefLifeSpanHandler methods:
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
bool DoClose(CefRefPtr<CefBrowser> browser) override;
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
// CefLoadHandler methods:
void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const CefString &errorText, const CefString &failedUrl) override;
// CefDisplayHandler methods:
void OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString &title) override;
bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
cef_log_severity_t level,
const CefString &message, const CefString &source,
int line) override;
// Request that all existing browser windows close.
void CloseAllBrowsers(bool force_close);
bool IsClosing() const { return is_closing_; }
// CefRequestHandler methods:
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 { return this; }
// CefResourceRequestHandler methods:
cef_return_value_t OnBeforeResourceLoad(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback) override;
CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) override;
std::string AddBatchPage(const std::string &cont);
std::string MakePageUrl(THttpServer *serv, const std::string &addr);
static void PlatformInit();
static std::string GetDataURI(const std::string& data, const std::string& mime_type);
static bool PlatformResize(CefRefPtr<CefBrowser> browser, int width, int height);
private:
// Platform-specific implementation.
void PlatformTitleChange(CefRefPtr<CefBrowser> browser, const CefString &title);
CefRefPtr<CefResourceManager> fResourceManager;
int fBatchPageCount{0};
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(GuiHandler);
DISALLOW_COPY_AND_ASSIGN(GuiHandler);
};
#endif // ROOT_cef_gui_handler_h