Skip to content

Commit 9849e7a

Browse files
committed
Merge remote-tracking branch 'upstream/cefpython147' into cefpython147-qt
# Conflicts: # .gitignore # README.md # api/Browser.md # docs/Build-instructions.md # examples/hello_world.py # examples/pywin32.py # examples/qt.py # examples/screenshot.py # examples/tkinter_.py # examples/tutorial.py # examples/wxpython.py # src/browser.pyx # src/cefpython.pyx # src/client_handler/cookie_access_filter.h # src/client_handler/dialog_handler.cpp # src/client_handler/dialog_handler.h # src/client_handler/request_handler.cpp # src/client_handler/request_handler.h # src/common/cefpython_public_api.h # src/cookie.pyx # src/extern/cef/cef_cookie.pxd # src/extern/cef/cef_types.pxd # src/frame.pyx # src/handlers/cookie_access_filter.pyx # src/handlers/render_handler.pyx # src/handlers/request_handler.pyx # src/handlers/v8context_handler.pyx # src/include/base/cef_bind.h # src/include/base/cef_build.h # src/include/base/cef_callback.h # src/include/base/cef_callback_helpers.h # src/include/base/cef_compiler_specific.h # src/include/base/cef_ref_counted.h # src/include/base/cef_scoped_refptr.h # src/include/base/cef_weak_ptr.h # src/include/base/internal/README-TRANSFER.txt # src/include/base/internal/cef_bind_internal.h # src/include/base/internal/cef_callback_internal.h # src/include/base/internal/cef_net_error_list.h # src/include/cef_api_hash.h # src/include/cef_api_version_test.h # src/include/cef_app.h # src/include/cef_application_mac.h # src/include/cef_base.h # src/include/cef_browser.h # src/include/cef_browser_process_handler.h # src/include/cef_command_handler.h # src/include/cef_command_ids.h # src/include/cef_command_line.h # src/include/cef_config.h # src/include/cef_dialog_handler.h # src/include/cef_display_handler.h # src/include/cef_download_handler.h # src/include/cef_download_item.h # src/include/cef_frame.h # src/include/cef_frame_handler.h # src/include/cef_life_span_handler.h # src/include/cef_media_router.h # src/include/cef_pack_resources.h # src/include/cef_pack_strings.h # src/include/cef_permission_handler.h # src/include/cef_preference.h # src/include/cef_render_handler.h # src/include/cef_request_context.h # src/include/cef_request_handler.h # src/include/cef_resource_bundle.h # src/include/cef_resource_bundle_handler.h # src/include/cef_sandbox_win.h # src/include/cef_test_server.h # src/include/cef_v8.h # src/include/cef_version.h # src/include/internal/cef_app_win.h # src/include/internal/cef_linux.h # src/include/internal/cef_string_wrappers.h # src/include/internal/cef_time.h # src/include/internal/cef_types.h # src/include/internal/cef_types_content_settings.h # src/include/internal/cef_types_linux.h # src/include/internal/cef_types_mac.h # src/include/internal/cef_types_win.h # src/include/internal/cef_types_wrappers.h # src/include/internal/cef_win.h # src/include/test/cef_translator_test.h # src/include/views/cef_browser_view.h # src/include/views/cef_browser_view_delegate.h # src/include/views/cef_display.h # src/include/views/cef_view.h # src/include/views/cef_window.h # src/include/views/cef_window_delegate.h # src/javascript_callback.pyx # src/process_message_utils.pyx # src/response.pyx # src/settings.pyx # src/subprocess/cefpython_app.cpp # src/version/cef_version_win.h # src/web_request.pyx # src/window_info.pyx # tools/automate.py # tools/build.py # tools/build_cpp_projects.py # tools/build_distrib.py # tools/common.py # tools/cython_setup.py # tools/installer/cefpython3.__init__.py # tools/installer/cefpython3.setup.py # tools/make_installer.py # tools/requirements.txt
2 parents a4844bd + 8568a35 commit 9849e7a

5 files changed

Lines changed: 93 additions & 1 deletion

File tree

api/API-index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@
364364
* [SetUrl](Request.md#seturl)
365365
* [GetMethod](Request.md#getmethod)
366366
* [SetMethod](Request.md#setmethod)
367+
* [SetReferrer](Request.md#setreferrer)
368+
* [GetReferrerURL](Request.md#getreferrerurl)
369+
* [GetReferrerPolicy](Request.md#getreferrerpolicy)
367370
* [GetPostData](Request.md#getpostdata)
368371
* [SetPostData](Request.md#setpostdata)
369372
* [GetHeaderMap](Request.md#getheadermap)

api/Request.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Table of contents:
1313
* [SetUrl](#seturl)
1414
* [GetMethod](#getmethod)
1515
* [SetMethod](#setmethod)
16+
* [SetReferrer](#setreferrer)
17+
* [GetReferrerURL](#getreferrerurl)
18+
* [GetReferrerPolicy](#getreferrerpolicy)
1619
* [GetPostData](#getpostdata)
1720
* [SetPostData](#setpostdata)
1821
* [GetHeaderMap](#getheadermap)
@@ -77,6 +80,49 @@ if post data is provided and GET otherwise.
7780
Set the request method type.
7881

7982

83+
### SetReferrer
84+
85+
| Parameter | Type |
86+
| --- | --- |
87+
| referrer_url | string |
88+
| policy | ReferrerPolicy |
89+
| __Return__ | void |
90+
91+
Set the request referrer.
92+
93+
`referrer` must be a fully qualified url.
94+
95+
`ReferrerPolicy` constants in the cefpython module:
96+
* **REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE**
97+
* **REFERRER_POLICY_DEFAULT** - equivalent to REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE
98+
* **REFERRER_POLICY_REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN**
99+
* **REFERRER_POLICY_ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN**
100+
* **REFERRER_POLICY_NEVER_CLEAR_REFERRER**
101+
* **REFERRER_POLICY_ORIGIN**
102+
* **REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN**
103+
* **REFERRER_POLICY_ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE**
104+
* **REFERRER_POLICY_NO_REFERRER**
105+
* **REFERRER_POLICY_NUM_VALUES**
106+
107+
108+
### GetReferrerURL
109+
110+
| | |
111+
| --- | --- |
112+
| __Return__ | string |
113+
114+
Get the referrer url.
115+
116+
117+
### GetReferrerPolicy
118+
119+
| | |
120+
| --- | --- |
121+
| __Return__ | ReferrerPolicy |
122+
123+
Get the referrer policy for this request.
124+
125+
80126
### GetPostData
81127

82128
| | |

src/extern/cef/cef_request.pxd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from cef_ptr cimport CefRefPtr
66
from cef_string cimport CefString
77
# noinspection PyUnresolvedReferences
8-
from cef_types cimport cef_urlrequest_flags_t, cef_postdataelement_type_t
8+
from cef_types cimport cef_urlrequest_flags_t, cef_postdataelement_type_t, cef_referrer_policy_t
99
# noinspection PyUnresolvedReferences
1010
from libcpp.vector cimport vector as cpp_vector
1111
from libcpp cimport bool as cpp_bool
@@ -16,6 +16,7 @@ cdef extern from "include/cef_request.h":
1616
# This types won't be visible in pyx files!
1717
ctypedef cpp_multimap[CefString, CefString] HeaderMap
1818
# ctypedef cef_urlrequest_flags_t CefRequestFlags
19+
ctypedef cef_referrer_policy_t ReferrerPolicy
1920

2021
cdef CefRefPtr[CefRequest] CefRequest_Create "CefRequest::Create"()
2122
cdef cppclass CefRequest:
@@ -24,6 +25,9 @@ cdef extern from "include/cef_request.h":
2425
void SetURL(CefString& url)
2526
CefString GetMethod()
2627
void SetMethod(CefString& method)
28+
void SetReferrer(CefString& referrer_url, ReferrerPolicy policy)
29+
CefString GetReferrerURL()
30+
ReferrerPolicy GetReferrerPolicy()
2731
CefRefPtr[CefPostData] GetPostData()
2832
void SetPostData(CefRefPtr[CefPostData] postData)
2933
void GetHeaderMap(HeaderMap& headerMap)

src/extern/cef/cef_types.pxd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,19 @@ cdef extern from "include/internal/cef_types.h":
334334
PK_DIR_RESOURCES,
335335
ctypedef cef_path_key_t PathKey
336336

337+
ctypedef enum cef_referrer_policy_t:
338+
REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE
339+
REFERRER_POLICY_DEFAULT = REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
340+
REFERRER_POLICY_REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN,
341+
REFERRER_POLICY_ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN,
342+
REFERRER_POLICY_NEVER_CLEAR_REFERRER,
343+
REFERRER_POLICY_ORIGIN,
344+
REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN,
345+
REFERRER_POLICY_ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
346+
REFERRER_POLICY_NO_REFERRER,
347+
REFERRER_POLICY_NUM_VALUES
348+
ctypedef cef_referrer_policy_t ReferrerPolicy
349+
337350
# Drag & drop
338351

339352
ctypedef enum cef_drag_operations_mask_t:

src/request.pyx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
include "cefpython.pyx"
66

7+
# noinspection PyUnresolvedReferences
8+
from cef_types cimport ReferrerPolicy
79
# noinspection PyUnresolvedReferences
810
cimport cef_types
911

@@ -17,6 +19,17 @@ UR_FLAG_NO_DOWNLOAD_DATA = cef_types.UR_FLAG_NO_DOWNLOAD_DATA
1719
UR_FLAG_NO_RETRY_ON_5XX = cef_types.UR_FLAG_NO_RETRY_ON_5XX
1820
UR_FLAG_STOP_ON_REDIRECT = cef_types.UR_FLAG_STOP_ON_REDIRECT
1921

22+
# cef_referrer_policy_t
23+
REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE = cef_types.REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE
24+
REFERRER_POLICY_DEFAULT = cef_types.REFERRER_POLICY_DEFAULT
25+
REFERRER_POLICY_REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN = cef_types.REFERRER_POLICY_REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN
26+
REFERRER_POLICY_ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN = cef_types.REFERRER_POLICY_ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN
27+
REFERRER_POLICY_NEVER_CLEAR_REFERRER = cef_types.REFERRER_POLICY_NEVER_CLEAR_REFERRER
28+
REFERRER_POLICY_ORIGIN = cef_types.REFERRER_POLICY_ORIGIN
29+
REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN = cef_types.REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN
30+
REFERRER_POLICY_ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE = cef_types.REFERRER_POLICY_ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE
31+
REFERRER_POLICY_NO_REFERRER = cef_types.REFERRER_POLICY_NO_REFERRER
32+
REFERRER_POLICY_NUM_VALUES = cef_types.REFERRER_POLICY_NUM_VALUES
2033

2134
class Request:
2235
# TODO: autocomplete in PyCharm doesn't work for these flags
@@ -80,6 +93,19 @@ cdef class PyRequest:
8093
PyToCefString(method, cefMethod)
8194
self.GetCefRequest().get().SetMethod(cefMethod)
8295

96+
cpdef py_void SetReferrer(self, py_string referrer_url, cef_types.cef_referrer_policy_t policy):
97+
cdef CefString cefReferrerUrl
98+
PyToCefString(referrer_url, cefReferrerUrl)
99+
self.GetCefRequest().get().SetReferrer(cefReferrerUrl, policy)
100+
101+
cpdef str GetReferrerURL(self):
102+
return CefToPyString(self.GetCefRequest().get().GetReferrerURL())
103+
104+
cpdef cef_types.cef_referrer_policy_t GetReferrerPolicy(self):
105+
cdef cef_types.cef_referrer_policy_t rp
106+
rp = <cef_types.cef_referrer_policy_t>self.GetCefRequest().get().GetReferrerPolicy()
107+
return rp
108+
83109
cpdef object GetPostData(self):
84110
if self.GetMethod() != "POST":
85111
return {}

0 commit comments

Comments
 (0)