Skip to content

Commit

Permalink
Fix build errors (#403)
Browse files Browse the repository at this point in the history
Change cef.Request.Flags options.
  • Loading branch information
cztomczak committed May 25, 2018
1 parent b1769a5 commit 322389d
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ webcache/
examples/screenshot.png
examples/pyinstaller/build/
examples/pyinstaller/dist/
examples/GPUCache/
examples/blob_storage/
examples/webrtc_event_logs/
unittests/GPUCache/
unittests/blob_storage/
unittests/webrtc_event_logs/
16 changes: 9 additions & 7 deletions api/Request.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,20 @@ be removed and ignored.

Get the flags used in combination with WebRequest.

Available flags (access via `cefpython.Request.Flags["xxx"]`):
Available flags below. Can be accessed via `cefpython.Request.Flags["xxx"]`.
These flags are also defined as constants starting with "UR_FLAG_"
in the cefpython module.requ

* **None** - Default behavior.
* **SkipCache** - If set the cache will be skipped when handling the request.
Setting this value is equivalent to specifying the "Cache-Control: no-cache"
request header. Setting this value in combination with UR_FLAG_ONLY_FROM_CACHE
will cause the request to fail.
* **AllowCachedCredentials** - If set user name, password, and cookies may be
sent with the request, and cookies may be saved from the response.
* **SkipCache** - If set the cache will be skipped when handling the request. Setting this value is equivalent to specifying the "Cache-Control: no-cache" request header. Setting this value in combination with UR_FLAG_ONLY_FROM_CACHE will cause the request to fail.
* **OnlyFromCache** - If set the request will fail if it cannot be served from the cache (or some equivalent local store). Setting this value is equivalent to specifying the "Cache-Control: only-if-cached" request header. Setting this value in combination with UR_FLAG_SKIP_CACHE will cause the request to fail.
* **AllowStoredCredentials** - If set user name, password, and cookies may be sent with the request, and cookies may be saved from the response.
* **ReportUploadProgress** - If set upload progress events will be generated when a request has a body.
* **NoDownloadData** - If set the [WebRequestClient](WebRequestClient.md)::`OnDownloadData` method will not be called.
* **NoRetryOn5xx** - If set 5xx redirect errors will be propagated to the observer instead of automatically re-tried. This currently only applies for requests originated in the browser process.
* **StopOnRedirect** - If set 3XX responses will cause the fetch to halt immediately rather than continue through the redirect.




### SetFlags
Expand Down
15 changes: 15 additions & 0 deletions docs/Migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Table of contents:
* [v66+ Window transparency changes](#v66-window-transparency-changes)
* [v66+ BrowserSettings.javascript_open_windows_disallowed option was removed](#v66-browsersettingsjavascript_open_windows_disallowed-option-was-removed)
* [v66+ Threads removed: TID_DB, TID_PROCESS_LAUNCHER, TID_CACHE](#v66-threads-removed-tid_db-tid_process_launcher-tid_cache)
* [v66+ cef.Request.Flags changed](#v66-cefrequestflags-changed)



Expand Down Expand Up @@ -361,3 +362,17 @@ were removed: TID_DB, TID_PROCESS_LAUNCHER, TID_CACHE.
New threads were added, see cefpython.[PostTask](../api/cefpython.md#posttask)
description for a complete list of threads.


## v66+ cef.Request.Flags changed

Flags removed:
- AllowCachedCredentials

Flags added:
- OnlyFromCache
- AllowStoredCredentials
- StopOnRedirect

See a complete list of flags in the description of
cef.Request.[GetFlags](../api/Request.md#getflags) method.

10 changes: 7 additions & 3 deletions src/cef_v59..v66_changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ internal/cef_types.h
- + Added threads: TID_FILE_BACKGROUND, TID_FILE_USER_VISIBLE


+ cef_urlrequest.h
- + cef_urlrequest_flags_t:
- + Add: UR_FLAG_ONLY_FROM_CACHE, UR_FLAG_ALLOW_STORED_CREDENTIALS,
UR_FLAG_STOP_ON_REDIRECT
- + Remove: UR_FLAG_ALLOW_CACHED_CREDENTIALS


NEW FEATURES
------------

Expand Down Expand Up @@ -133,9 +140,6 @@ cef_server.h
- CefServer: a web server that supports HTTP and WebSocket requests
- CefServerHandler

cef_urlrequest.h
- ResponseWasCached

cef_v8.h
- CefV8ArrayBufferReleaseCallback
- CefV8Value new methods:
Expand Down
16 changes: 9 additions & 7 deletions src/extern/cef/cef_types.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ cdef extern from "include/internal/cef_types.h":
TID_UI,
TID_FILE_BACKGROUND
TID_FILE,
TID_FILE_USER_VISIBLE
TID_FILE_USER_VISIBLE,
TID_FILE_USER_BLOCKING,
TID_IO,
TID_RENDERER
Expand Down Expand Up @@ -160,12 +160,14 @@ cdef extern from "include/internal/cef_types.h":

# WebRequest
ctypedef enum cef_urlrequest_flags_t:
UR_FLAG_NONE = 0,
UR_FLAG_SKIP_CACHE = 1 << 0,
UR_FLAG_ALLOW_CACHED_CREDENTIALS = 1 << 1,
UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3,
UR_FLAG_NO_DOWNLOAD_DATA = 1 << 6,
UR_FLAG_NO_RETRY_ON_5XX = 1 << 7,
UR_FLAG_NONE = 0,
UR_FLAG_SKIP_CACHE = 1 << 0,
UR_FLAG_ONLY_FROM_CACHE = 1 << 1,
UR_FLAG_ALLOW_STORED_CREDENTIALS = 1 << 2,
UR_FLAG_REPORT_UPLOAD_PROGRESS = 1 << 3,
UR_FLAG_NO_DOWNLOAD_DATA = 1 << 4,
UR_FLAG_NO_RETRY_ON_5XX = 1 << 5,
UR_FLAG_STOP_ON_REDIRECT = 1 << 6,

# CefListValue, CefDictionaryValue - types.
ctypedef enum cef_value_type_t:
Expand Down
26 changes: 22 additions & 4 deletions src/request.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,35 @@

include "cefpython.pyx"

# noinspection PyUnresolvedReferences
cimport cef_types

# cef_urlrequest_flags_t
UR_FLAG_NONE = cef_types.UR_FLAG_NONE
UR_FLAG_SKIP_CACHE = cef_types.UR_FLAG_SKIP_CACHE
UR_FLAG_ONLY_FROM_CACHE = cef_types.UR_FLAG_ONLY_FROM_CACHE
UR_FLAG_ALLOW_STORED_CREDENTIALS = cef_types.UR_FLAG_ALLOW_STORED_CREDENTIALS
UR_FLAG_REPORT_UPLOAD_PROGRESS = cef_types.UR_FLAG_REPORT_UPLOAD_PROGRESS
UR_FLAG_NO_DOWNLOAD_DATA = cef_types.UR_FLAG_NO_DOWNLOAD_DATA
UR_FLAG_NO_RETRY_ON_5XX = cef_types.UR_FLAG_NO_RETRY_ON_5XX
UR_FLAG_STOP_ON_REDIRECT = cef_types.UR_FLAG_STOP_ON_REDIRECT


class Request:
# TODO: autocomplete in PyCharm doesn't work for these flags
Flags = {
"None": cef_types.UR_FLAG_NONE,
"SkipCache": cef_types.UR_FLAG_SKIP_CACHE,
"AllowCachedCredentials": cef_types.UR_FLAG_ALLOW_CACHED_CREDENTIALS,
"AllowCookies": 0, # keep for BC
"OnlyFromCache": cef_types.UR_FLAG_ONLY_FROM_CACHE,
"AllowCachedCredentials": 0, # keep dummy for BC
"AllowStoredCredentials": cef_types.UR_FLAG_ALLOW_STORED_CREDENTIALS,
"AllowCookies": 0, # keep dummy for BC
"ReportUploadProgress": cef_types.UR_FLAG_REPORT_UPLOAD_PROGRESS,
"ReportLoadTiming": 0, # keep for BC
"ReportRawHeaders": 0, # keep for BC
"ReportLoadTiming": 0, # keep dummy for BC
"ReportRawHeaders": 0, # keep dummy for BC
"NoDownloadData": cef_types.UR_FLAG_NO_DOWNLOAD_DATA,
"NoRetryOn5xx": cef_types.UR_FLAG_NO_RETRY_ON_5XX,
"StopOnRedirect": cef_types.UR_FLAG_STOP_ON_REDIRECT,
}

def __init__(self):
Expand Down
2 changes: 2 additions & 0 deletions src/subprocess/print_handler_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
#include <gtk/gtk.h>
#include <gtk/gtkunixprint.h>

#include "include/base/cef_bind.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/wrapper/cef_helpers.h"
#include "include/wrapper/cef_closure_task.h"

namespace {

Expand Down
20 changes: 12 additions & 8 deletions src/subprocess/print_handler_gtk.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git print_handler_gtk.cc print_handler_gtk.cc
index 9a822b7a..cfccbaff 100644
index 9a822b7a..18c8c1c4 100644
--- print_handler_gtk.cc
+++ print_handler_gtk.cc
@@ -1,9 +1,12 @@
@@ -1,22 +1,23 @@
+// COPIED from upstream "cef/tests/cefclient/browser/" directory
+// with minor modifications. See the .patch file in current directory.
+
Expand All @@ -16,18 +16,22 @@ index 9a822b7a..cfccbaff 100644

#include <vector>

@@ -14,10 +17,6 @@
#include <gtk/gtk.h>
#include <gtk/gtkunixprint.h>

+#include "include/base/cef_bind.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/wrapper/cef_helpers.h"
-
-#include "tests/cefclient/browser/root_window.h"
-
-namespace client {
-
+#include "include/wrapper/cef_closure_task.h"

namespace {

// CUPS Duplex attribute and values.
@@ -431,10 +430,12 @@ struct ClientPrintHandlerGtk::PrintHandler {
@@ -431,10 +432,12 @@ struct ClientPrintHandlerGtk::PrintHandler {
// Returns the GtkWindow* for the browser. Will return NULL when using the
// Views framework.
GtkWindow* GetWindow() {
Expand All @@ -44,7 +48,7 @@ index 9a822b7a..cfccbaff 100644
return NULL;
}

@@ -626,5 +627,3 @@ ClientPrintHandlerGtk::PrintHandler* ClientPrintHandlerGtk::GetPrintHandler(
@@ -626,5 +629,3 @@ ClientPrintHandlerGtk::PrintHandler* ClientPrintHandlerGtk::GetPrintHandler(
DCHECK(it != print_handler_map_.end());
return it->second;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ g_browserProcessThreads = [
TID_UI,
TID_FILE_BACKGROUND,
TID_FILE,
TID_FILE_USER_VISIBLE
TID_FILE_USER_VISIBLE,
TID_FILE_USER_BLOCKING,
TID_IO,
]
Expand Down

0 comments on commit 322389d

Please sign in to comment.