Skip to content

Commit

Permalink
Update to Chrome 55.0.2883.59 and CEF 3.2883.1539.gd7f087e (#271).
Browse files Browse the repository at this point in the history
Update to Cython 0.25.2.

Fix Certificate Transparency support causing some SSL sites fail
to load after some time (#279).

Fix ApplicationSettings.cache_path not working (#283).

Fix: Not a clean shutdown in examples, when closing app while browser
is still loading a website (#282).

Fix loading local filesystem urls that contained any of ? & =
characters (#273).

Fix Request.SetPostData and GetPostData segmentation faults (#228).

Add ApplicationSettings.net_security_expiration_enabled.

Update ExecuteJavascript docs with scriptUrl="" and startLine=1
default params. Also worth noting that ExecuteJavascript crashed
in earlier CEF versions when startLine wasn't provided or was <= 0
(Issue #268).

Add a test that measures execution time for calling Python function
from javascript and then js callback.

Add Contributing guidelines / Issue template.

Update automate.py, include ceftests executable.
  • Loading branch information
cztomczak committed Dec 15, 2016
1 parent 59a9aa1 commit bfc0a25
Show file tree
Hide file tree
Showing 56 changed files with 1,034 additions and 255 deletions.
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Please read this:
1. Do not create Issues to report problems and/or ask questions. Use the Forum for that.
2. Before creating an Issue it must first be discussed and confirmed on the Forum.
3. Always use the Forum: https://goo.gl/xz4cEF
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Please read this:
1. Do not create Issues to report problems and/or ask questions. Use the Forum for that.
2. Before creating an Issue it must first be discussed and confirmed on the Forum.
3. Always use the Forum: https://goo.gl/xz4cEF
19 changes: 19 additions & 0 deletions api/ApplicationSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Table of contents:
* [log_file](#log_file)
* [log_severity](#log_severity)
* [multi_threaded_message_loop](#multi_threaded_message_loop)
* [net_security_expiration_enabled](#net_security_expiration_enabled)
* [pack_loading_disabled](#pack_loading_disabled)
* [persist_session_cookies](#persist_session_cookies)
* [persist_user_preferences](#persist_user_preferences)
Expand Down Expand Up @@ -283,6 +284,19 @@ only supported on Windows.
This option is not and cannot be supported on OS-X for architectural reasons.


### net_security_expiration_enabled

(bool)
Set to true (1) to enable date-based expiration of built in network
security information (i.e. certificate transparency logs, HSTS preloading
and pinning information). Enabling this option improves network security
but may cause HTTPS load failures when using CEF binaries built more than
10 weeks in the past. See https://www.certificate-transparency.org/ and
https://www.chromium.org/hsts for details. Can be set globally using the
CefSettings.enable_net_security_expiration value.



### pack_loading_disabled

(bool)
Expand Down Expand Up @@ -393,6 +407,11 @@ To successfully implement separate cookie manager per browser session
with the use of the RequestHandler.`GetCookieManager` callback, you have to
set `unique_request_context_per_browser` to True.

In upstream CEF each request context may have separate settings like
cache_path, persist_session_cookies, persist_user_preferences,
ignore_certificate_errors, enable_net_security_expiration,
accept_language_list. Such functionality wasn't yet exposed in CEF Python.


### user_agent

Expand Down
18 changes: 13 additions & 5 deletions api/Browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

# Browser (object)

Remember to free all browser references for the browser to shut down cleanly.
Otherwise data such as cookies or other storage might not be flushed to disk
when closing app, and other issues might occur as well. To free a reference
just assign a None value to a "browser" variable.


Table of contents:
* [Notes](#notes)
Expand Down Expand Up @@ -82,10 +87,13 @@ Table of contents:

## Notes

**Closing browser cleanly**
Methods available in upstream CEF which were not yet exposed in CEF Python
(see src/include/cef_browser.h):

Remember to delete all browser references for the browser to shut down cleanly. See the wxpython.py example > MainFrame.OnClose() for how to
do it.
* ImeSetComposition
* ImeCommitText
* ImeFinishComposingText
* ImeCancelComposition


## Methods
Expand Down Expand Up @@ -267,8 +275,8 @@ Passing a python function here is not allowed, it is only possible through [Java
| Parameter | Type |
| --- | --- |
| jsCode | string |
| scriptURL=None | string |
| startLine=None | int |
| scriptUrl="" | string |
| startLine=1 | int |
| __Return__ | void |

Execute a string of JavaScript code in this frame. The `sciptURL` parameter is the URL where the script in question can be found, if any. The renderer may request this URL to show the developer the source of the error. The `startLine` parameter is the base line number to use for error reporting.
Expand Down
4 changes: 2 additions & 2 deletions api/Frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ Call a javascript function asynchronously. This can also call object's methods,
| Parameter | Type |
| --- | --- |
| jsCode | string |
| scriptUrl=None | string |
| startLine=None | int |
| scriptUrl="" | string |
| startLine=1 | int |
| __Return__ | void |

Execute a string of JavaScript code in this frame. The sciptUrl parameter is the url where the script in question can be found, if any. The renderer may request this URL to show the developer the source of the error. The startLine parameter is the base line number to use for error reporting. This function executes asynchronously so there is no way to get the returned value. Calling javascript <> native code synchronously is not possible.
Expand Down
41 changes: 26 additions & 15 deletions api/RenderHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@
# RenderHandler (interface)

Implement this interface to handle events when window rendering is disabled
(off-screen rendering). The methods of this class will be called on the UI thread.

In order to create windowless browsers the
ApplicationSettings.[windowless_rendering_enabled](ApplicationSettings.md#windowless_rendering_enabled)
value must be set to true.

Callbacks not implemented yet:
* GetScreenInfo()

Off-screen rendering examples:
* [Kivy](https://github.com/cztomczak/cefpython/wiki/Kivy)
* [Panda3D](https://github.com/cztomczak/cefpython/wiki/Panda3D)
* [cefpython_offscreen_no_UI_framework.py](https://gist.github.com/stefanbacon/7b1571d57aee54aa9f8e9021b4848d06) -
most basic usage of OSR to take screenshot of a page

(off-screen rendering). The methods of this class will be called on
the UI thread. In order to create windowless browsers the
[windowless_rendering_enabled](ApplicationSettings.md#windowless_rendering_enabled)
setting must be set to true.

Table of contents:
* [Examples](#examples)
* [Notes](#notes)
* [Callbacks](#callbacks)
* [GetRootScreenRect](#getrootscreenrect)
* [GetViewRect](#getviewrect)
Expand All @@ -35,6 +26,26 @@ Table of contents:
* [UpdateDragCursor](#updatedragcursor)


## Examples

Off-screen rendering examples:
* [Kivy](https://github.com/cztomczak/cefpython/wiki/Kivy)
* [Panda3D](https://github.com/cztomczak/cefpython/wiki/Panda3D)
\- tested with v31
* [pygame + PyOpenGL](https://gist.github.com/AnishN/aa3bb27fc9d69319955ed9a8973cd40f)
\- tested with v31, more info on this example on the Forum in
[this post](https://groups.google.com/d/topic/cefpython/mwSa7He90xA/discussion)
* [cefpython_offscreen_no_UI_framework.py](https://gist.github.com/stefanbacon/7b1571d57aee54aa9f8e9021b4848d06)
\- most basic usage of OSR to take a screenshot of a page

## Notes

Callbacks available in upstream CEF, but not yet exposed in CEF Python
(see src/include/cef_render_handler.h):
* GetScreenInfo
* OnImeCompositionRangeChanged


## Callbacks


Expand Down
10 changes: 6 additions & 4 deletions api/RequestHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@

Implement this interface to handle events related to browser requests.

For an example of how to implement handler see [cefpython](cefpython.md).CreateBrowser(). For a list of all handler interfaces see [API > Client handlers](API#Client_handlers).
For an example of how to implement handler see
[cefpython](cefpython.md).CreateBrowserSync(). For a list of all handler
interfaces see [API > Client handlers](API#Client_handlers).

The `RequestHandler` tests can be found in the wxpython.py script.
The `RequestHandler` tests can be found in the old wxpython.py script (v31).

The following callbacks are available in upstream CEF, but were not yet
exposed:
Not yet exposed in CEF Python:
* OnOpenURLFromTab
* OnSelectClientCertificate



Table of contents:
* [Callbacks](#callbacks)
* [OnBeforeBrowse](#onbeforebrowse)
Expand Down
11 changes: 11 additions & 0 deletions api/WebPluginInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@

See [RequestHandler](RequestHandler.md).OnBeforePluginLoad().

Web Plugin API available in upstream CEF, but not yet exposed in CEF Python
(see src/include/cef_web_plugin.h):

* CefRegisterCdmCallback
* CefRegisterWidevineCdm
* CefIsWebPluginUnstable
* CefRegisterWebPluginCrash
* CefUnregisterInternalWebPlugin
* CefRefreshWebPlugins
* CefVisitWebPluginInfo


Table of contents:
* [Methods](#methods)
Expand Down
18 changes: 7 additions & 11 deletions docs/Build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Table of contents:

## Build CEF Python on Linux

Complete steps for building CEF Python 55 using prebuilt
Complete steps for building CEF Python v50+ using prebuilt
binaries from GitHub releases:

1) Tested and works fine on Ubuntu 14.04 64-bit (cmake 2.8.12 and g++ 4.8.4)
Expand All @@ -48,15 +48,15 @@ binaries from GitHub releases:

5) Download 64-bit Linux binaries and libraries from
[GH releases](https://github.com/cztomczak/cefpython/releases)
tagged 'v55-upstream'.
tagged e.g. 'v50-upstream' when building v50.

6) Extract it in the cefpython/build/ directory and rename the extracted
directory to "cef_linux64".

8) Build cefpython and run examples:
8) Build cefpython and run examples (xx.x is version e.g. 50.0):
```
cd cefpython/src/linux/
python compile.py 55.0
python compile.py xx.x
```

## Requirements
Expand All @@ -67,12 +67,8 @@ requirements common for all platforms.

__Windows__

* For Python 2.7 - VS2008 compiler is required:
http://www.microsoft.com/en-us/download/details.aspx?id=44266
* For Python 3.4 - VS2010 compiler is required:
https://docs.python.org/3.4/using/windows.html#compiling-python-on-windows
* For Python 3.5 - VS2015 compiler is required:
https://docs.python.org/3.5/using/windows.html#compiling-python-on-windows
* Install an appropriate MS compiler for a specific Python version:
https://wiki.python.org/moin/WindowsCompilers
* To build CEF from sources:
* Use Win7 x64 or later. 32-bit OS'es are not supported. For more details
see [here](https://www.chromium.org/developers/how-tos/build-instructions-windows).
Expand Down Expand Up @@ -167,7 +163,7 @@ mkdir build/ && cd build
python ../tools/automate.py --build-cef --ninja-jobs 6
mv cef*_*_linux64/ cef_linux64/
cd ../../../src/linux/
python compile.py 55.0
python compile.py xx.x
```

__MISSING PACKAGES (Linux)__: After the chromium sources are downloaded,
Expand Down
10 changes: 4 additions & 6 deletions examples/gtk2.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Example of embedding CEF Python browser using PyGTK library (GTK 2).
# Tested with GTK 2.24 and CEF Python v54+.

# Known issue on Linux: Keyboard focus problem (Issue #284)

from cefpython3 import cefpython as cef
import pygtk
import gtk
import gobject
import sys
import time

# In CEF you can run message loop in two ways (see API docs for more details):
# 1. By calling cef.MessageLoop() instead of an application-provided
Expand Down Expand Up @@ -37,7 +38,8 @@ def main():
def check_versions():
print("[gkt2.py] CEF Python {ver}".format(ver=cef.__version__))
print("[gkt2.py] Python {ver}".format(ver=sys.version[:6]))
print("[gkt2.py] GTK {ver}".format(ver='.'.join(map(str, list(gtk.gtk_version)))))
print("[gkt2.py] GTK {ver}".format(ver='.'.join(
map(str, list(gtk.gtk_version)))))
assert cef.__version__ >= "54.0", "CEF Python v54+ required to run this"
pygtk.require('2.0')

Expand Down Expand Up @@ -135,10 +137,6 @@ def on_exit(self, *_):
self.browser.CloseBrowser(True)
self.browser = None
if g_message_loop == MESSAGE_LOOP_BEST:
# Run some message loop work for the browser to close cleanly
for i in range(0, 10):
cef.MessageLoopWork()
time.sleep(0.01)
cef.QuitMessageLoop()
else:
gtk.main_quit()
Expand Down
5 changes: 3 additions & 2 deletions examples/tkinter_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# This example has two widgets: a navigation bar and a browser.
# Tested with Tk 8.6 and CEF Python v53+.

# Issue #255: when typing url, mouse must be over url entry widget
# otherwise keyboard focus is lost.
# Known issue on Linux: When typing url, mouse must be over url
# entry widget otherwise keyboard focus is lost (Issue #255
# and Issue #284)

from cefpython3 import cefpython as cef
try:
Expand Down
14 changes: 7 additions & 7 deletions patches/issue231.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git include/capi/cef_path_util_capi.h include/capi/cef_path_util_capi.h
index 23befac..de31b3d 100644
index 23befacc..de31b3d6 100644
--- include/capi/cef_path_util_capi.h
+++ include/capi/cef_path_util_capi.h
@@ -51,6 +51,16 @@ extern "C" {
Expand All @@ -20,7 +20,7 @@ index 23befac..de31b3d 100644
}
#endif
diff --git include/cef_path_util.h include/cef_path_util.h
index 552f4ba..95af66e 100644
index 552f4ba5..95af66ef 100644
--- include/cef_path_util.h
+++ include/cef_path_util.h
@@ -49,4 +49,15 @@ typedef cef_path_key_t PathKey;
Expand All @@ -40,7 +40,7 @@ index 552f4ba..95af66e 100644
+
#endif // CEF_INCLUDE_CEF_PATH_UTIL_H_
diff --git libcef/browser/path_util_impl.cc libcef/browser/path_util_impl.cc
index 6a75930..ad620d7 100644
index 6a759309..ad620d7f 100644
--- libcef/browser/path_util_impl.cc
+++ libcef/browser/path_util_impl.cc
@@ -51,3 +51,38 @@ bool CefGetPath(PathKey key, CefString& path) {
Expand Down Expand Up @@ -83,10 +83,10 @@ index 6a75930..ad620d7 100644
+ return PathService::Override(pref_key, file_path);
+}
diff --git libcef_dll/libcef_dll.cc libcef_dll/libcef_dll.cc
index 496c9b0..f2dc4d8 100644
index 2e353f5b..f18e89b5 100644
--- libcef_dll/libcef_dll.cc
+++ libcef_dll/libcef_dll.cc
@@ -752,6 +752,23 @@ CEF_EXPORT int cef_get_path(cef_path_key_t key, cef_string_t* path) {
@@ -899,6 +899,23 @@ CEF_EXPORT int cef_get_path(cef_path_key_t key, cef_string_t* path) {
return _retval;
}

Expand All @@ -111,10 +111,10 @@ index 496c9b0..f2dc4d8 100644
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

diff --git libcef_dll/wrapper/libcef_dll_wrapper.cc libcef_dll/wrapper/libcef_dll_wrapper.cc
index 3a5d30f..7431698 100644
index 5e6ba876..be6e5af6 100644
--- libcef_dll/wrapper/libcef_dll_wrapper.cc
+++ libcef_dll/wrapper/libcef_dll_wrapper.cc
@@ -696,6 +696,23 @@ CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) {
@@ -820,6 +820,23 @@ CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) {
return _retval?true:false;
}

Expand Down
6 changes: 5 additions & 1 deletion src/browser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MOUSEBUTTON_RIGHT = cef_types.MBT_RIGHT
# get segmentation faults, as they will be garbage collected.

cdef dict g_pyBrowsers = {}
cdef list g_closed_browsers = [] # [int identifier, ..]

cdef PyBrowser GetPyBrowserById(int browserId):
if browserId in g_pyBrowsers:
Expand Down Expand Up @@ -269,7 +270,10 @@ cdef class PyBrowser:
Debug("CloseBrowser: releasing shared request context")
g_sharedRequestContext.Assign(NULL)
Debug("CefBrowser::CloseBrowser(%s)" % forceClose)
cdef int browserId = self.GetCefBrowser().get().GetIdentifier()
self.GetCefBrowserHost().get().CloseBrowser(bool(forceClose))
global g_closed_browsers
g_closed_browsers.append(browserId)

cpdef py_void CloseDevTools(self):
self.GetCefBrowserHost().get().CloseDevTools()
Expand All @@ -278,7 +282,7 @@ cdef class PyBrowser:
self.GetMainFrame().ExecuteFunction(*args)

cpdef py_void ExecuteJavascript(self, py_string jsCode,
py_string scriptUrl="", int startLine=0):
py_string scriptUrl="", int startLine=1):
self.GetMainFrame().ExecuteJavascript(jsCode, scriptUrl, startLine)

cpdef py_void Find(self, int searchId, py_string searchText,
Expand Down
Loading

0 comments on commit bfc0a25

Please sign in to comment.