Skip to content

Commit 5f7a3f1

Browse files
committed
RequestHandler.OnBeforeBrowse hsa a new param 'user_gesture' (#403)
1 parent 44a74ad commit 5f7a3f1

File tree

6 files changed

+36
-21
lines changed

6 files changed

+36
-21
lines changed

api/RequestHandler.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,21 @@ Table of contents:
4444
| browser | [Browser](Browser.md) |
4545
| frame | [Frame](Frame.md) |
4646
| request | [Request](Request.md) |
47+
| user_gesture | bool |
4748
| is_redirect | bool |
4849
| __Return__ | bool |
4950

50-
Called on the UI thread before browser navigation. Return true to cancel
51-
the navigation or false to allow the navigation to proceed. The |request|
52-
object cannot be modified in this callback.
53-
[DisplayHandler](DisplayHandler.md).`OnLoadingStateChange` will be
54-
called twice in all cases.
55-
If the navigation is allowed [LoadHandler](LoadHandler.md).`OnLoadStart` and
56-
`OnLoadEnd` will be called. If the navigation is canceled
57-
[LoadHandler](LoadHandler.md).`OnLoadError` will be called with
58-
an |error_code| value of ERR_ABORTED.
51+
Description from upstream CEF:
52+
> Called on the UI thread before browser navigation. Return true to cancel
53+
> the navigation or false to allow the navigation to proceed. The |request|
54+
> object cannot be modified in this callback.
55+
> CefLoadHandler::OnLoadingStateChange will be called twice in all cases.
56+
> If the navigation is allowed CefLoadHandler::OnLoadStart and
57+
> CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled
58+
> CefLoadHandler::OnLoadError will be called with an |errorCode| value of
59+
> ERR_ABORTED. The |user_gesture| value will be true if the browser
60+
> navigated via explicit user gesture (e.g. clicking a link) or false if it
61+
> navigated automatically (e.g. via the DomContentLoaded event).
5962
6063

6164
### OnBeforeResourceLoad

docs/Migration-guide.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ Table of contents:
3333
* [v54+ GTK 3 example doesn't work anymore on Linux](#v54-gtk-3-example-doesnt-work-anymore-on-linux)
3434
* [v54+ libcef.so library is stripped from symbols on Linux](#v54-libcefso-library-is-stripped-from-symbols-on-linux)
3535
* [v55+ HTTPS cache problems on pages with certificate errors](#v55-https-cache-problems-on-pages-with-certificate-errors)
36-
* [v55.3+ Handlers' callbacks and other interfaces](#v553-handlers-callbacks-and-other-interfaces)
36+
* [v55.3+ Handlers' callbacks and other interfaces are now called using keyword args](#v553-handlers-callbacks-and-other-interfaces-are-now-called-using-keyword-args)
3737
* [v56+ MacOS 10.9+ required to run](#v56-macos-109-required-to-run)
3838
* [v57.1+ High DPI support on Windows](#v571-high-dpi-support-on-windows)
3939
* [v66+ Linux patch that fixed HTTPS cache problems on pages with certificate errors was disabled](#v66-linux-patch-that-fixed-https-cache-problems-on-pages-with-certificate-errors-was-disabled)
40-
* [v66+ DisplayHandler.OnConsoleMessage has new param 'level'](#v66-displayhandleronconsolemessage-has-new-param-level)
40+
* [v66+ DisplayHandler.OnConsoleMessage has a new param 'level'](#v66-displayhandleronconsolemessage-has-a-new-param-level)
4141
* [v66+ LifespanHandler.OnBeforePopup is now called on UI thread](#v66-lifespanhandleronbeforepopup-is-now-called-on-ui-thread)
42+
* [V66+ RequestHandler.OnBeforeBrowse has a new param 'user_gesture'](#v66-requesthandleronbeforebrowse-has-a-new-param-user_gesture)
4243

4344

4445

@@ -212,6 +213,8 @@ API ref: Request.[GetHeaderMap](../api/Request.md#getheadermap)
212213

213214
## v54+ GTK 3 example doesn't work anymore on Linux
214215

216+
Update: GTK 3 example is back working in v57+.
217+
215218
Currently GTK 3 example is broken on Linux. You can either
216219
downgrade to an old cefpython v53 (available on GitHub release
217220
page) or use GTK 2 example. For more details on the problem see
@@ -236,7 +239,7 @@ cefpython starts using CEF prebuilt binaries from Spotify.
236239
See Issue [#125](../../../issues/125) for more details.
237240

238241

239-
## v55.3+ Handlers' callbacks and other interfaces
242+
## v55.3+ Handlers' callbacks and other interfaces are now called using keyword args
240243

241244
Since v55.3 all handlers' callbacks and other interfaces such as
242245
CookieVisitor, StringVisitor and WebRequestClient, are now called
@@ -308,7 +311,7 @@ If you need this feature then you can build from sources and apply
308311
the patch yourself. See Issue [#125](../../../issues/125) for more details.
309312

310313

311-
## v66+ DisplayHandler.OnConsoleMessage has new param 'level'
314+
## v66+ DisplayHandler.OnConsoleMessage has a new param 'level'
312315

313316
The DisplayHandler.[OnConsoleMessage](../api/DisplayHandler.md#onconsolemessage)
314317
callback has a new param `level`.
@@ -320,3 +323,9 @@ The LifespanHandler.[OnBeforePopup](../api/LifespanHandler.md#onbeforepopup)
320323
callback is now called on UI thread. Previously it was called on
321324
IO thread.
322325

326+
327+
## V66+ RequestHandler.OnBeforeBrowse has a new param 'user_gesture'
328+
329+
The RequestHandler.[OnBeforeBrowse](../api/RequestHandler.md#onbeforebrowse)
330+
callback has a new param `user_gesture`.
331+

src/cef_v59..v66_changes.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ BREAKAGE (needs updating Migration Guide doc)
2323
+ cef_render_process_handler.h
2424
- + Remove OnBeforeNavigation in subprocess/cefpython_app.h and .cpp files
2525

26-
cef_request_handler.h
27-
- OnBeforeBrowse: new param 'user_gesture'
28-
- update Migration Guide
26+
+ cef_request_handler.h
27+
- + OnBeforeBrowse: new param 'user_gesture'
28+
- + update Migration Guide
2929

3030
internal/cef_linux.h
3131
internal/cef_types_linux.h

src/client_handler/request_handler.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
bool RequestHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
1010
CefRefPtr<CefFrame> frame,
1111
CefRefPtr<CefRequest> request,
12+
bool user_gesture,
1213
bool is_redirect)
1314
{
1415
REQUIRE_UI_THREAD();
15-
return RequestHandler_OnBeforeBrowse(browser, frame, request, is_redirect);
16+
return RequestHandler_OnBeforeBrowse(browser, frame, request,
17+
user_gesture, is_redirect);
1618
}
1719

1820

src/client_handler/request_handler.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class RequestHandler : public CefRequestHandler
1717
bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
1818
CefRefPtr<CefFrame> frame,
1919
CefRefPtr<CefRequest> request,
20+
bool user_gesture,
2021
bool is_redirect) override;
2122

2223
ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,

src/handlers/request_handler.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,26 @@ cdef public cpp_bool RequestHandler_OnBeforeBrowse(
5959
CefRefPtr[CefBrowser] cefBrowser,
6060
CefRefPtr[CefFrame] cefFrame,
6161
CefRefPtr[CefRequest] cefRequest,
62-
cpp_bool cefIsRedirect
62+
cpp_bool user_gesture,
63+
cpp_bool is_redirect
6364
) except * with gil:
6465
cdef PyBrowser pyBrowser
6566
cdef PyFrame pyFrame
6667
cdef PyRequest pyRequest
67-
cdef py_bool pyIsRedirect
6868
cdef object clientCallback
6969
cdef py_bool returnValue
7070
try:
7171
pyBrowser = GetPyBrowser(cefBrowser, "OnBeforeBrowse")
7272
pyFrame = GetPyFrame(cefFrame)
7373
pyRequest = CreatePyRequest(cefRequest)
74-
pyIsRedirect = bool(cefIsRedirect)
7574
clientCallback = pyBrowser.GetClientCallback("OnBeforeBrowse")
7675
if clientCallback:
7776
returnValue = clientCallback(
7877
browser=pyBrowser,
7978
frame=pyFrame,
8079
request=pyRequest,
81-
is_redirect=pyIsRedirect)
80+
user_gesture=user_gesture,
81+
is_redirect=is_redirect)
8282
return bool(returnValue)
8383
else:
8484
return False

0 commit comments

Comments
 (0)