-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathCefViewBrowserClientDelegate.h
289 lines (245 loc) · 11.8 KB
/
CefViewBrowserClientDelegate.h
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
//
// CefViewBrowserHandlerDelegate.h
// CefView
//
// Created by Sheen Tian on 2020/6/11.
//
#ifndef CefViewBrowserHandlerDelegate_h
#define CefViewBrowserHandlerDelegate_h
#pragma once
#include <memory>
#include <string>
#include <include/cef_client.h>
#include <include/cef_version.h>
/// <summary>
///
/// </summary>
class CefViewBrowserClientDelegateInterface
{
public:
typedef std::shared_ptr<CefViewBrowserClientDelegateInterface> RefPtr;
typedef std::weak_ptr<CefViewBrowserClientDelegateInterface> WeakPtr;
virtual ~CefViewBrowserClientDelegateInterface() {}
virtual void processUrlRequest(const std::string& url) = 0;
#if CEF_VERSION_MAJOR >= 122
virtual void processQueryRequest(CefRefPtr<CefBrowser>& browser,
const std::string& frameId,
const std::string& query,
const int64_t query_id) = 0;
virtual void focusedEditableNodeChanged(CefRefPtr<CefBrowser>& browser,
const std::string& frameId,
bool focusOnEditableNode) = 0;
virtual void invokeMethodNotify(CefRefPtr<CefBrowser>& browser,
const std::string& frameId,
const std::string& method,
const CefRefPtr<CefListValue>& arguments) = 0;
virtual void reportJSResult(CefRefPtr<CefBrowser>& browser,
const std::string& frameId,
const std::string& context,
const CefRefPtr<CefValue>& result) = 0;
#else
virtual void processQueryRequest(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const std::string& query,
const int64_t query_id) = 0;
virtual void focusedEditableNodeChanged(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
bool focusOnEditableNode) = 0;
virtual void invokeMethodNotify(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const std::string& method,
const CefRefPtr<CefListValue>& arguments) = 0;
virtual void reportJSResult(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const std::string& context,
const CefRefPtr<CefValue>& result) = 0;
#endif
// context menu handler
#pragma region ContextMenuHandler
virtual void onBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model) = 0;
virtual bool onRunContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model,
CefRefPtr<CefRunContextMenuCallback> callback) = 0;
virtual bool onContextMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
CefContextMenuHandler::EventFlags event_flags) = 0;
virtual void onContextMenuDismissed(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame) = 0;
#pragma endregion
// dialog handler
#pragma region DialogHandler
virtual bool onFileDialog(CefRefPtr<CefBrowser> browser,
CefBrowserHost::FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
CefRefPtr<CefFileDialogCallback> callback)
{
return false;
};
#pragma endregion
// display handler
#pragma region DisplayHandler
#if CEF_VERSION_MAJOR >= 122
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, const std::string& frameId, const std::string& url) = 0;
#else
virtual void addressChanged(CefRefPtr<CefBrowser>& browser, int64_t frameId, const std::string& url) = 0;
#endif
virtual void titleChanged(CefRefPtr<CefBrowser>& browser, const std::string& title) = 0;
virtual void faviconURLChanged(CefRefPtr<CefBrowser> browser, const std::vector<CefString>& icon_urls) = 0;
virtual bool tooltipMessage(CefRefPtr<CefBrowser>& browser, const std::string& text) = 0;
virtual void fullscreenModeChanged(CefRefPtr<CefBrowser>& browser, bool fullscreen) = 0;
virtual void statusMessage(CefRefPtr<CefBrowser>& browser, const std::string& value) = 0;
virtual void loadingProgressChanged(CefRefPtr<CefBrowser>& browser, double progress) = 0;
virtual void consoleMessage(CefRefPtr<CefBrowser>& browser, const std::string& message, int level) = 0;
virtual bool cursorChanged(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor,
cef_cursor_type_t type,
const CefCursorInfo& custom_cursor_info) = 0;
#pragma endregion
// download hander
#pragma region DownloadHandler
virtual void onBeforeDownload(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
const CefString& suggested_name,
CefRefPtr<CefBeforeDownloadCallback> callback) = 0;
virtual void onDownloadUpdated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDownloadItem> download_item,
CefRefPtr<CefDownloadItemCallback> callback) = 0;
#pragma endregion
#pragma region GetDragHandler
// drag hander
virtual bool onDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
CefDragHandler::DragOperationsMask mask)
{
return true;
}
virtual void draggableRegionChanged(CefRefPtr<CefBrowser>& browser,
const std::vector<CefDraggableRegion>& regions) = 0;
#pragma endregion
// life span handler
#pragma region LifeSpanHandler
#if CEF_VERSION_MAJOR >= 122
virtual bool onBeforePopup(CefRefPtr<CefBrowser>& browser,
const std::string& frameId,
const std::string& targetUrl,
const std::string& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition,
CefWindowInfo& windowInfo,
CefBrowserSettings& settings,
bool& DisableJavascriptAccess) = 0;
#else
virtual bool onBeforePopup(CefRefPtr<CefBrowser>& browser,
int64_t frameId,
const std::string& targetUrl,
const std::string& targetFrameName,
CefLifeSpanHandler::WindowOpenDisposition targetDisposition,
CefWindowInfo& windowInfo,
CefBrowserSettings& settings,
bool& DisableJavascriptAccess) = 0;
#endif
virtual void onAfterCreate(CefRefPtr<CefBrowser>& browser) = 0;
virtual bool doClose(CefRefPtr<CefBrowser> browser) = 0;
virtual bool requestClose(CefRefPtr<CefBrowser> browser) = 0;
virtual void onBeforeClose(CefRefPtr<CefBrowser> browser) = 0;
#pragma endregion
// focus handler
#pragma region FocusHandler
virtual void takeFocus(CefRefPtr<CefBrowser>& browser, bool next) = 0;
virtual bool setFocus(CefRefPtr<CefBrowser>& browser) = 0;
virtual void gotFocus(CefRefPtr<CefBrowser>& browser) = 0;
#pragma endregion
// load handler
#pragma region LoadHandler
virtual void loadingStateChanged(CefRefPtr<CefBrowser>& browser,
bool isLoading,
bool canGoBack,
bool canGoForward) = 0;
virtual void loadStart(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame, int transition_type) = 0;
virtual void loadEnd(CefRefPtr<CefBrowser>& browser, CefRefPtr<CefFrame>& frame, int httpStatusCode) = 0;
virtual void loadError(CefRefPtr<CefBrowser>& browser,
CefRefPtr<CefFrame>& frame,
int errorCode,
const std::string& errorMsg,
const std::string& failedUrl,
bool& handled) = 0;
#pragma endregion
// keyboard handler
#pragma region KeyboardHandler
virtual bool onPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
bool* is_keyboard_shortcut) = 0;
virtual bool onKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent& event, CefEventHandle os_event) = 0;
#pragma endregion
// Off screen rendering
#pragma region RenderHandler
virtual bool getRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect)
{
return false;
}
virtual void getViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) {}
virtual bool getScreenPoint(CefRefPtr<CefBrowser> browser, int viewX, int viewY, int& screenX, int& screenY)
{
return false;
}
virtual bool getScreenInfo(CefRefPtr<CefBrowser> browser, CefScreenInfo& screen_info)
{
return false;
}
virtual void onPopupShow(CefRefPtr<CefBrowser> browser, bool show) {}
virtual void onPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) {}
virtual void onPaint(CefRefPtr<CefBrowser> browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
const void* buffer,
int width,
int height)
{
}
#if CEF_VERSION_MAJOR >= 122
virtual void onAcceleratedPaint(CefRefPtr<CefBrowser> browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
const CefAcceleratedPaintInfo& info)
{
}
#else
virtual void onAcceleratedPaint(CefRefPtr<CefBrowser> browser,
CefRenderHandler::PaintElementType type,
const CefRenderHandler::RectList& dirtyRects,
void* shared_handle)
{
}
#endif
virtual bool startDragging(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> drag_data,
CefRenderHandler::DragOperationsMask allowed_ops,
int x,
int y)
{
return false;
}
virtual void updateDragCursor(CefRefPtr<CefBrowser> browser, CefRenderHandler::DragOperation operation) {}
virtual void onScrollOffsetChanged(CefRefPtr<CefBrowser> browser, double x, double y) {}
virtual void onImeCompositionRangeChanged(CefRefPtr<CefBrowser> browser,
const CefRange& selected_range,
const CefRenderHandler::RectList& character_bounds)
{
}
virtual void onTextSelectionChanged(CefRefPtr<CefBrowser> browser,
const CefString& selected_text,
const CefRange& selected_range)
{
}
virtual void onVirtualKeyboardRequested(CefRefPtr<CefBrowser> browser, CefRenderHandler::TextInputMode input_mode) {}
#pragma endregion
};
#endif