Repository navigation
Expand file tree
/
Copy pathclient_handler.h
More file actions
268 lines (239 loc) · 9.67 KB
/
Copy pathclient_handler.h
File metadata and controls
268 lines (239 loc) · 9.67 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
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
// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
// License: New BSD License.
// Website: http://code.google.com/p/cefpython/
#pragma once
#if defined(_WIN32)
#include "../windows/stdint.h"
#endif
#include "cefpython_public_api.h"
class ClientHandler :
public CefClient,
public CefLifeSpanHandler
{
public:
ClientHandler(){}
virtual ~ClientHandler(){}
///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for dialogs. If no handler is provided the default
// implementation will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for browser display state events.
///
/*--cef()--*/
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for download events. If no handler is returned downloads
// will not be allowed.
///
/*--cef()--*/
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for drag events.
///
/*--cef()--*/
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for focus events.
///
/*--cef()--*/
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for geolocation permissions requests. If no handler is
// provided geolocation access will be denied by default.
///
/*--cef()--*/
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for JavaScript dialogs. If no handler is provided the
// default implementation will be used.
///
/*--cef()--*/
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for keyboard events.
///
/*--cef()--*/
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for browser life span events.
///
/*--cef()--*/
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
return this;
}
///
// Return the handler for browser load status events.
///
/*--cef()--*/
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for off-screen rendering events.
///
/*--cef()--*/
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE {
return NULL;
}
///
// Return the handler for browser request events.
///
/*--cef()--*/
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
return NULL;
}
///
// Called when a new message is received from a different process. Return true
// if the message was handled or false otherwise. Do not keep a reference to
// or attempt to access the message outside of this callback.
///
/*--cef()--*/
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message)
OVERRIDE;
// --------------------------------------------------------------------------
// CefLifeSpanHandler
// --------------------------------------------------------------------------
///
// Implement this interface to handle events related to browser life span. The
// methods of this class will be called on the UI thread unless otherwise
// indicated.
///
///
// Called on the IO thread before a new popup window is created. The |browser|
// and |frame| parameters represent the source of the popup request. The
// |target_url| and |target_frame_name| values may be empty if none were
// specified with the request. The |popupFeatures| structure contains
// information about the requested popup window. To allow creation of the
// popup window optionally modify |windowInfo|, |client|, |settings| and
// |no_javascript_access| and return false. To cancel creation of the popup
// window return true. The |client| and |settings| values will default to the
// source browser's values. The |no_javascript_access| value indicates whether
// the new browser window should be scriptable and in the same process as the
// source browser.
/*--cef(optional_param=target_url,optional_param=target_frame_name)--*/
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
bool* no_javascript_access) OVERRIDE;
///
// Called after a new browser is created.
///
/*--cef()--*/
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
///
// Called when a modal window is about to display and the modal loop should
// begin running. Return false to use the default modal loop implementation or
// true to use a custom implementation.
///
/*--cef()--*/
virtual bool RunModal(CefRefPtr<CefBrowser> browser) OVERRIDE;
///
// Called when a browser has recieved a request to close. This may result
// directly from a call to CefBrowserHost::CloseBrowser() or indirectly if the
// browser is a top-level OS window created by CEF and the user attempts to
// close the window. This method will be called after the JavaScript
// 'onunload' event has been fired. It will not be called for browsers after
// the associated OS window has been destroyed (for those browsers it is no
// longer possible to cancel the close).
//
// If CEF created an OS window for the browser returning false will send an OS
// close notification to the browser window's top-level owner (e.g. WM_CLOSE
// on Windows, performClose: on OS-X and "delete_event" on Linux). If no OS
// window exists (window rendering disabled) returning false will cause the
// browser object to be destroyed immediately. Return true if the browser is
// parented to another window and that other window needs to receive close
// notification via some non-standard technique.
//
// If an application provides its own top-level window it should handle OS
// close notifications by calling CefBrowserHost::CloseBrowser(false) instead
// of immediately closing (see the example below). This gives CEF an
// opportunity to process the 'onbeforeunload' event and optionally cancel the
// close before DoClose() is called.
//
// The CefLifeSpanHandler::OnBeforeClose() method will be called immediately
// before the browser object is destroyed. The application should only exit
// after OnBeforeClose() has been called for all existing browsers.
//
// If the browser represents a modal window and a custom modal loop
// implementation was provided in CefLifeSpanHandler::RunModal() this callback
// should be used to restore the opener window to a usable state.
//
// By way of example consider what should happen during window close when the
// browser is parented to an application-provided top-level OS window.
// 1. User clicks the window close button which sends an OS close
// notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and
// "delete_event" on Linux).
// 2. Application's top-level window receives the close notification and:
// A. Calls CefBrowserHost::CloseBrowser(false).
// B. Cancels the window close.
// 3. JavaScript 'onbeforeunload' handler executes and shows the close
// confirmation dialog (which can be overridden via
// CefJSDialogHandler::OnBeforeUnloadDialog()).
// 4. User approves the close.
// 5. JavaScript 'onunload' handler executes.
// 6. Application's DoClose() handler is called. Application will:
// A. Call CefBrowserHost::ParentWindowWillClose() to notify CEF that the
// parent window will be closing.
// B. Set a flag to indicate that the next close attempt will be allowed.
// C. Return false.
// 7. CEF sends an OS close notification.
// 8. Application's top-level window receives the OS close notification and
// allows the window to close based on the flag from #6B.
// 9. Browser OS window is destroyed.
// 10. Application's CefLifeSpanHandler::OnBeforeClose() handler is called and
// the browser object is destroyed.
// 11. Application exits by calling CefQuitMessageLoop() if no other browsers
// exist.
///
/*--cef()--*/
virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any methods on the browser
// object after this callback returns. If this is a modal window and a custom
// modal loop implementation was provided in RunModal() this callback should
// be used to exit the custom modal loop. See DoClose() documentation for
// additional usage information.
///
/*--cef()--*/
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
private:
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(ClientHandler);
// Include the default locking implementation.
// IMPLEMENT_LOCKING(ClientHandler);
};