From 1da0110d01fd40cad093159033ec4b48f5e7fd70 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Fri, 9 Dec 2016 11:44:39 +0100 Subject: [PATCH 1/2] Update to Chrome 54.0.2840.99 and CEF 3.2840.1518.gffd843c (#272). Update to Cython 0.25.2 (#110). Changes in API: - Add ApplicationSettings.net_security_expiration_enabled Key changes in upstream CEF between commits 7fe3d03...ffd843c (CEF Python 54.0 ... 54.1): - Update to Chromium version 54.0.2840.99 - Fix PDF rendering with OSR - Add CefRequestHandler::OnSelectClientCertificate (allows for client certificate selection programmatically) - Fix load error when using Request->SetUrl when url contains double byte characters - Fix crash related to channel ID support, disable channel ID support - Net security (CT, HSTS) expiration based on build age is now disabled by default. Configurable with CefSettings.enable_net_security_expiration. - New web plugin API: CefRegisterCdmCallback, CefRegisterWidevineCdm --- api/ApplicationSettings.md | 14 +++ api/RequestHandler.md | 9 +- api/WebPluginInfo.md | 11 +++ docs/Build-instructions.md | 10 +- examples/gtk2.py | 12 +-- examples/gtk3.py | 6 +- examples/hello_world.py | 4 +- examples/tkinter_.py | 11 ++- patches/issue231.patch | 8 +- patches/issue251.patch | 4 +- src/extern/cef/cef_types.pxd | 3 +- src/include/cef_menu_model_delegate.h | 6 +- src/include/cef_render_handler.h | 3 +- src/include/cef_request_handler.h | 43 ++++++++- src/include/cef_v8.h | 108 ++++++++++++++++++---- src/include/cef_web_plugin.h | 66 +++++++++++++ src/include/internal/cef_types.h | 49 ++++++++++ src/include/internal/cef_types_wrappers.h | 4 + src/linux/compile.py | 32 ++++++- src/linux/setup/cefpython.h | 2 +- src/settings.pyx | 7 +- src/subprocess/cefpython_app.cpp | 2 +- src/subprocess/v8utils.cpp | 2 +- src/version/cef_version_linux.h | 16 ++-- tools/requirements.txt | 2 +- 25 files changed, 361 insertions(+), 73 deletions(-) diff --git a/api/ApplicationSettings.md b/api/ApplicationSettings.md index cfa467c2..1e2555d8 100644 --- a/api/ApplicationSettings.md +++ b/api/ApplicationSettings.md @@ -283,6 +283,20 @@ 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. Also configurable using the +"enable-net-security-expiration" command-line switch. Can be overridden for +individual CefRequestContext instances via the +CefRequestContextSettings.enable_net_security_expiration value. + + ### pack_loading_disabled (bool) diff --git a/api/RequestHandler.md b/api/RequestHandler.md index 9ca788f2..80ffd23c 100644 --- a/api/RequestHandler.md +++ b/api/RequestHandler.md @@ -5,12 +5,15 @@ 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). -Not yet ported to CEF Python: +Not yet exposed in CEF Python: * OnOpenURLFromTab +* OnSelectClientCertificate diff --git a/api/WebPluginInfo.md b/api/WebPluginInfo.md index 62ee2baa..b0038980 100644 --- a/api/WebPluginInfo.md +++ b/api/WebPluginInfo.md @@ -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) diff --git a/docs/Build-instructions.md b/docs/Build-instructions.md index a806472d..671d1e5c 100644 --- a/docs/Build-instructions.md +++ b/docs/Build-instructions.md @@ -32,7 +32,7 @@ Table of contents: ## Build CEF Python on Linux -Complete steps for building CEF Python 54 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) @@ -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 'v54-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 54.0 +python compile.py xx.x ``` ## Requirements @@ -167,7 +167,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 54.0 +python compile.py xx.x ``` __MISSING PACKAGES (Linux)__: After the chromium sources are downloaded, diff --git a/examples/gtk2.py b/examples/gtk2.py index 2cbfbabf..8d716cde 100644 --- a/examples/gtk2.py +++ b/examples/gtk2.py @@ -35,9 +35,9 @@ def main(): def check_versions(): - print("CEF Python {ver}".format(ver=cef.__version__)) - print("Python {ver}".format(ver=sys.version[:6])) - print("GTK {ver}".format(ver='.'.join(map(str, list(gtk.gtk_version))))) + 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))))) assert cef.__version__ >= "54.0", "CEF Python v54+ required to run this" pygtk.require('2.0') @@ -45,14 +45,14 @@ def check_versions(): def configure_message_loop(): global g_message_loop if "--message-loop-timer" in sys.argv: - print("Message loop mode: TIMER") + print("[gkt2.py] Message loop mode: TIMER") g_message_loop = MESSAGE_LOOP_TIMER sys.argv.remove("--message-loop-timer") else: - print("Message loop mode: BEST") + print("[gkt2.py] Message loop mode: BEST") g_message_loop = MESSAGE_LOOP_BEST if len(sys.argv) > 1: - print("ERROR: unknown argument passed") + print("[gkt2.py] ERROR: unknown argument passed") sys.exit(1) diff --git a/examples/gtk3.py b/examples/gtk3.py index 701a058b..27d6c863 100644 --- a/examples/gtk3.py +++ b/examples/gtk3.py @@ -9,9 +9,9 @@ def main(): - print("CEF Python {ver}".format(ver=cef.__version__)) - print("Python {ver}".format(ver=sys.version[:6])) - print("GTK {major}.{minor}".format( + print("[gkt3.py] CEF Python {ver}".format(ver=cef.__version__)) + print("[gkt3.py] Python {ver}".format(ver=sys.version[:6])) + print("[gkt3.py] GTK {major}.{minor}".format( major=Gtk.get_major_version(), minor=Gtk.get_minor_version())) assert cef.__version__ >= "53.1", "CEF Python v53.1+ required to run this" diff --git a/examples/hello_world.py b/examples/hello_world.py index 5ec5fa61..88d7b489 100644 --- a/examples/hello_world.py +++ b/examples/hello_world.py @@ -6,8 +6,8 @@ def main(): - print("CEF Python {ver}".format(ver=cef.__version__)) - print("Python {ver}".format(ver=sys.version[:6])) + print("[hello_world.py] CEF Python {ver}".format(ver=cef.__version__)) + print("[hello_world.py] Python {ver}".format(ver=sys.version[:6])) assert cef.__version__ >= "53.1", "CEF Python v53.1+ required to run this" sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error cef.Initialize() diff --git a/examples/tkinter_.py b/examples/tkinter_.py index c0ee3128..22a8759f 100644 --- a/examples/tkinter_.py +++ b/examples/tkinter_.py @@ -12,15 +12,18 @@ import Tkinter as tk import sys import os -import logging +import logging as _logging # Globals -logger = logging.getLogger() +logger = _logging.getLogger("tkinter_.py") def main(): - logger.setLevel(logging.INFO) - logger.addHandler(logging.StreamHandler()) + logger.setLevel(_logging.INFO) + stream_handler = _logging.StreamHandler() + formatter = _logging.Formatter("[%(filename)s] %(message)s") + stream_handler.setFormatter(formatter) + logger.addHandler(stream_handler) logger.info("CEF Python {ver}".format(ver=cef.__version__)) logger.info("Python {ver}".format(ver=sys.version[:6])) logger.info("Tk {ver}".format(ver=tk.TkVersion)) diff --git a/patches/issue231.patch b/patches/issue231.patch index b9375afd..58d2b1c3 100644 --- a/patches/issue231.patch +++ b/patches/issue231.patch @@ -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 208333c..fcadb7e 100644 +index 496c9b0..f2dc4d8 100644 --- libcef_dll/libcef_dll.cc +++ libcef_dll/libcef_dll.cc -@@ -747,6 +747,23 @@ CEF_EXPORT int cef_get_path(cef_path_key_t key, cef_string_t* path) { +@@ -752,6 +752,23 @@ CEF_EXPORT int cef_get_path(cef_path_key_t key, cef_string_t* path) { return _retval; } @@ -111,10 +111,10 @@ index 208333c..fcadb7e 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 248a285..3f0c226 100644 +index 3a5d30f..7431698 100644 --- libcef_dll/wrapper/libcef_dll_wrapper.cc +++ libcef_dll/wrapper/libcef_dll_wrapper.cc -@@ -691,6 +691,23 @@ CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) { +@@ -696,6 +696,23 @@ CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) { return _retval?true:false; } diff --git a/patches/issue251.patch b/patches/issue251.patch index 460aea42..6e22dfe4 100644 --- a/patches/issue251.patch +++ b/patches/issue251.patch @@ -71,7 +71,7 @@ index 8f8094b..8b4602b 100644 #endif // CEF_INCLUDE_CEF_DRAG_DATA_H_ diff --git libcef/browser/osr/web_contents_view_osr.cc libcef/browser/osr/web_contents_view_osr.cc -index 52f1a87..e967865 100644 +index f6715a2..0f7c20a 100644 --- libcef/browser/osr/web_contents_view_osr.cc +++ libcef/browser/osr/web_contents_view_osr.cc @@ -6,6 +6,7 @@ @@ -82,7 +82,7 @@ index 52f1a87..e967865 100644 #include "libcef/browser/osr/render_widget_host_view_osr.h" #include "libcef/common/drag_data_impl.h" -@@ -227,7 +228,9 @@ void CefWebContentsViewOSR::StartDragging( +@@ -230,7 +231,9 @@ void CefWebContentsViewOSR::StartDragging( if (browser.get()) handler = browser->GetClient()->GetRenderHandler(); if (handler.get()) { diff --git a/src/extern/cef/cef_types.pxd b/src/extern/cef/cef_types.pxd index f21c42a5..9769e0b6 100644 --- a/src/extern/cef/cef_types.pxd +++ b/src/extern/cef/cef_types.pxd @@ -29,15 +29,16 @@ cdef extern from "include/internal/cef_types.h": cef_string_t accept_language_list int single_process cef_string_t browser_subprocess_path - int multi_threaded_message_loop int command_line_args_disabled cef_string_t cache_path + int enable_net_security_expiration int persist_session_cookies cef_string_t user_agent cef_string_t product_version cef_string_t locale cef_string_t log_file int log_severity + int multi_threaded_message_loop cef_string_t javascript_flags cef_string_t resources_dir_path cef_string_t locales_dir_path diff --git a/src/include/cef_menu_model_delegate.h b/src/include/cef_menu_model_delegate.h index b4e23418..84ebae18 100644 --- a/src/include/cef_menu_model_delegate.h +++ b/src/include/cef_menu_model_delegate.h @@ -63,20 +63,20 @@ class CefMenuModelDelegate : public virtual CefBase { // The menu is about to show. /// /*--cef()--*/ - virtual void MenuWillShow(CefRefPtr menu_model) {}; + virtual void MenuWillShow(CefRefPtr menu_model) {} /// // The menu has closed. /// /*--cef()--*/ - virtual void MenuClosed(CefRefPtr menu_model) {}; + virtual void MenuClosed(CefRefPtr menu_model) {} /// // Optionally modify a menu item label. Return true if |label| was modified. /// /*--cef()--*/ virtual bool FormatLabel(CefRefPtr menu_model, - CefString& label) { return false; }; + CefString& label) { return false; } }; #endif // CEF_INCLUDE_VIEWS_CEF_MENU_MODEL_DELEGATE_H_ diff --git a/src/include/cef_render_handler.h b/src/include/cef_render_handler.h index 636d72ea..1b84f2f9 100644 --- a/src/include/cef_render_handler.h +++ b/src/include/cef_render_handler.h @@ -38,10 +38,11 @@ #define CEF_INCLUDE_CEF_RENDER_HANDLER_H_ #pragma once +#include + #include "include/cef_base.h" #include "include/cef_browser.h" #include "include/cef_drag_data.h" -#include /// // Implement this interface to handle events when window rendering is disabled. diff --git a/src/include/cef_request_handler.h b/src/include/cef_request_handler.h index a4f09708..69334397 100644 --- a/src/include/cef_request_handler.h +++ b/src/include/cef_request_handler.h @@ -38,6 +38,8 @@ #define CEF_INCLUDE_CEF_REQUEST_HANDLER_H_ #pragma once +#include + #include "include/cef_auth_callback.h" #include "include/cef_base.h" #include "include/cef_browser.h" @@ -47,7 +49,7 @@ #include "include/cef_response_filter.h" #include "include/cef_request.h" #include "include/cef_ssl_info.h" - +#include "include/cef_x509_certificate.h" /// // Callback interface used for asynchronous continuation of url requests. @@ -70,6 +72,21 @@ class CefRequestCallback : public virtual CefBase { }; +/// +// Callback interface used to select a client certificate for authentication. +/// +/*--cef(source=library)--*/ +class CefSelectClientCertificateCallback : public virtual CefBase { + public: + /// + // Chooses the specified certificate for client certificate authentication. + // NULL value means that no client certificate should be used. + /// + /*--cef(optional_param=cert)--*/ + virtual void Select(CefRefPtr cert) =0; +}; + + /// // Implement this interface to handle events related to browser requests. The // methods of this class will be called on the thread indicated. @@ -81,6 +98,7 @@ class CefRequestHandler : public virtual CefBase { typedef cef_termination_status_t TerminationStatus; typedef cef_urlrequest_status_t URLRequestStatus; typedef cef_window_open_disposition_t WindowOpenDisposition; + typedef std::vector > X509CertificateList; /// // Called on the UI thread before browser navigation. Return true to cancel @@ -282,6 +300,29 @@ class CefRequestHandler : public virtual CefBase { return false; } + /// + // Called on the UI thread when a client certificate is being requested for + // authentication. Return false to use the default behavior and automatically + // select the first certificate available. Return true and call + // CefSelectClientCertificateCallback::Select either in this method or at a + // later time to select a certificate. Do not call Select or call it with NULL + // to continue without using any certificate. |isProxy| indicates whether the + // host is an HTTPS proxy or the origin server. |host| and |port| contains the + // hostname and port of the SSL server. |certificates| is the list of + // certificates to choose from; this list has already been pruned by Chromium + // so that it only contains certificates from issuers that the server trusts. + /// + /*--cef()--*/ + virtual bool OnSelectClientCertificate( + CefRefPtr browser, + bool isProxy, + const CefString& host, + int port, + const X509CertificateList& certificates, + CefRefPtr callback) { + return false; + } + /// // Called on the browser process UI thread when a plugin has crashed. // |plugin_path| is the path of the plugin that crashed. diff --git a/src/include/cef_v8.h b/src/include/cef_v8.h index 070d4391..f33090a4 100644 --- a/src/include/cef_v8.h +++ b/src/include/cef_v8.h @@ -206,13 +206,17 @@ class CefV8Context : public virtual CefBase { virtual bool IsSame(CefRefPtr that) =0; /// - // Evaluates the specified JavaScript code using this context's global object. - // On success |retval| will be set to the return value, if any, and the - // function will return true. On failure |exception| will be set to the + // Execute a string of JavaScript code in this V8 context. The |script_url| + // parameter is the URL where the script in question can be found, if any. + // The |start_line| parameter is the base line number to use for error + // reporting. On success |retval| will be set to the return value, if any, and + // the function will return true. On failure |exception| will be set to the // exception, if any, and the function will return false. /// - /*--cef()--*/ + /*--cef(optional_param=script_url)--*/ virtual bool Eval(const CefString& code, + const CefString& script_url, + int start_line, CefRefPtr& retval, CefRefPtr& exception) =0; }; @@ -277,6 +281,74 @@ class CefV8Accessor : public virtual CefBase { CefString& exception) =0; }; +/// +// Interface that should be implemented to handle V8 interceptor calls. The +// methods of this class will be called on the thread associated with the V8 +// interceptor. Interceptor's named property handlers (with first argument of +// type CefString) are called when object is indexed by string. Indexed property +// handlers (with first argument of type int) are called when object is indexed +// by integer. +/// +/*--cef(source=client)--*/ +class CefV8Interceptor : public virtual CefBase { +public: + /// + // Handle retrieval of the interceptor value identified by |name|. |object| is + // the receiver ('this' object) of the interceptor. If retrieval succeeds, set + // |retval| to the return value. If the requested value does not exist, don't + // set either |retval| or |exception|. If retrieval fails, set |exception| to + // the exception that will be thrown. If the property has an associated + // accessor, it will be called only if you don't set |retval|. + // Return true if interceptor retrieval was handled, false otherwise. + /// + /*--cef(capi_name=get_byname)--*/ + virtual bool Get(const CefString& name, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) =0; + + /// + // Handle retrieval of the interceptor value identified by |index|. |object| + // is the receiver ('this' object) of the interceptor. If retrieval succeeds, + // set |retval| to the return value. If the requested value does not exist, + // don't set either |retval| or |exception|. If retrieval fails, set + // |exception| to the exception that will be thrown. + // Return true if interceptor retrieval was handled, false otherwise. + /// + /*--cef(capi_name=get_byindex,index_param=index)--*/ + virtual bool Get(int index, + const CefRefPtr object, + CefRefPtr& retval, + CefString& exception) =0; + + /// + // Handle assignment of the interceptor value identified by |name|. |object| + // is the receiver ('this' object) of the interceptor. |value| is the new + // value being assigned to the interceptor. If assignment fails, set + // |exception| to the exception that will be thrown. This setter will always + // be called, even when the property has an associated accessor. + // Return true if interceptor assignment was handled, false otherwise. + /// + /*--cef(capi_name=set_byname)--*/ + virtual bool Set(const CefString& name, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) =0; + + /// + // Handle assignment of the interceptor value identified by |index|. |object| + // is the receiver ('this' object) of the interceptor. |value| is the new + // value being assigned to the interceptor. If assignment fails, set + // |exception| to the exception that will be thrown. + // Return true if interceptor assignment was handled, false otherwise. + /// + /*--cef(capi_name=set_byindex,index_param=index)--*/ + virtual bool Set(int index, + const CefRefPtr object, + const CefRefPtr value, + CefString& exception) =0; +}; + /// // Class representing a V8 exception. The methods of this class may be called on // any render process thread. @@ -404,14 +476,16 @@ class CefV8Value : public virtual CefBase { static CefRefPtr CreateString(const CefString& value); /// - // Create a new CefV8Value object of type object with optional accessor. This - // method should only be called from within the scope of a + // Create a new CefV8Value object of type object with optional accessor and/or + // interceptor. This method should only be called from within the scope of a // CefRenderProcessHandler, CefV8Handler or CefV8Accessor callback, or in // combination with calling Enter() and Exit() on a stored CefV8Context // reference. /// - /*--cef(optional_param=accessor)--*/ - static CefRefPtr CreateObject(CefRefPtr accessor); + /*--cef(optional_param=accessor, optional_param=interceptor)--*/ + static CefRefPtr CreateObject( + CefRefPtr accessor, + CefRefPtr interceptor); /// // Create a new CefV8Value object of type array with the specified |length|. @@ -515,43 +589,37 @@ class CefV8Value : public virtual CefBase { virtual bool IsSame(CefRefPtr that) =0; /// - // Return a bool value. The underlying data will be converted to if - // necessary. + // Return a bool value. /// /*--cef()--*/ virtual bool GetBoolValue() =0; /// - // Return an int value. The underlying data will be converted to if - // necessary. + // Return an int value. /// /*--cef()--*/ virtual int32 GetIntValue() =0; /// - // Return an unisgned int value. The underlying data will be converted to if - // necessary. + // Return an unsigned int value. /// /*--cef()--*/ virtual uint32 GetUIntValue() =0; /// - // Return a double value. The underlying data will be converted to if - // necessary. + // Return a double value. /// /*--cef()--*/ virtual double GetDoubleValue() =0; /// - // Return a Date value. The underlying data will be converted to if - // necessary. + // Return a Date value. /// /*--cef()--*/ virtual CefTime GetDateValue() =0; /// - // Return a string value. The underlying data will be converted to if - // necessary. + // Return a string value. /// /*--cef()--*/ virtual CefString GetStringValue() =0; diff --git a/src/include/cef_web_plugin.h b/src/include/cef_web_plugin.h index b7e199b9..731be7b9 100644 --- a/src/include/cef_web_plugin.h +++ b/src/include/cef_web_plugin.h @@ -144,5 +144,71 @@ class CefWebPluginUnstableCallback : public virtual CefBase { void CefIsWebPluginUnstable(const CefString& path, CefRefPtr callback); +/// +// Implement this interface to receive notification when CDM registration is +// complete. The methods of this class will be called on the browser process +// UI thread. +/// +/*--cef(source=client)--*/ +class CefRegisterCdmCallback : public virtual CefBase { + public: + /// + // Method that will be called when CDM registration is complete. |result| + // will be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed + // successfully. Otherwise, |result| and |error_message| will contain + // additional information about why registration failed. + /// + /*--cef(optional_param=error_message)--*/ + virtual void OnCdmRegistrationComplete(cef_cdm_registration_error_t result, + const CefString& error_message) =0; +}; + +/// +// Register the Widevine CDM plugin. +// +// The client application is responsible for downloading an appropriate +// platform-specific CDM binary distribution from Google, extracting the +// contents, and building the required directory structure on the local machine. +// The CefBrowserHost::StartDownload method and CefZipArchive class can be used +// to implement this functionality in CEF. Contact Google via +// https://www.widevine.com/contact.html for details on CDM download. +// +// |path| is a directory that must contain the following files: +// 1. manifest.json file from the CDM binary distribution (see below). +// 2. widevinecdm file from the CDM binary distribution (e.g. +// widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X, +// libwidevinecdm.so on Linux). +// 3. widevidecdmadapter file from the CEF binary distribution (e.g. +// widevinecdmadapter.dll on Windows, widevinecdmadapter.plugin on OS X, +// libwidevinecdmadapter.so on Linux). +// +// If any of these files are missing or if the manifest file has incorrect +// contents the registration will fail and |callback| will receive a |result| +// value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS. +// +// The manifest.json file must contain the following keys: +// A. "os": Supported OS (e.g. "mac", "win" or "linux"). +// B. "arch": Supported architecture (e.g. "ia32" or "x64"). +// C. "x-cdm-module-versions": Module API version (e.g. "4"). +// D. "x-cdm-interface-versions": Interface API version (e.g. "8"). +// E. "x-cdm-host-versions": Host API version (e.g. "8"). +// F. "version": CDM version (e.g. "1.4.8.903"). +// G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp9.0,avc1"). +// +// A through E are used to verify compatibility with the current Chromium +// version. If the CDM is not compatible the registration will fail and +// |callback| will receive a |result| value of +// CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE. +// +// |callback| will be executed asynchronously once registration is complete. +// +// On Linux this function must be called before CefInitialize() and the +// registration cannot be changed during runtime. If registration is not +// supported at the time that CefRegisterWidevineCdm() is called then |callback| +// will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED. +/// +/*--cef(optional_param=callback)--*/ +void CefRegisterWidevineCdm(const CefString& path, + CefRefPtr callback); #endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_ diff --git a/src/include/internal/cef_types.h b/src/include/internal/cef_types.h index 77d8605f..9f21e3f5 100644 --- a/src/include/internal/cef_types.h +++ b/src/include/internal/cef_types.h @@ -376,6 +376,19 @@ typedef struct _cef_settings_t { /// int ignore_certificate_errors; + /// + // 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. Also configurable using the + // "enable-net-security-expiration" command-line switch. Can be overridden for + // individual CefRequestContext instances via the + // CefRequestContextSettings.enable_net_security_expiration value. + /// + int enable_net_security_expiration; + /// // Opaque background color used for accelerated content. By default the // background color will be white. Only the RGB compontents of the specified @@ -443,6 +456,17 @@ typedef struct _cef_request_context_settings_t { /// int ignore_certificate_errors; + /// + // 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. + /// + int enable_net_security_expiration; + /// // Comma delimited ordered list of language codes without any whitespace that // will be used in the "Accept-Language" HTTP header. Can be set globally @@ -2657,6 +2681,31 @@ typedef enum { SSL_CONTENT_RAN_INSECURE_CONTENT = 1 << 1, } cef_ssl_content_status_t; +/// +// Error codes for CDM registration. See cef_web_plugin.h for details. +/// +typedef enum { + /// + // No error. Registration completed successfully. + /// + CEF_CDM_REGISTRATION_ERROR_NONE, + + /// + // Required files or manifest contents are missing. + /// + CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS, + + /// + // The CDM is incompatible with the current Chromium version. + /// + CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE, + + /// + // CDM registration is not supported at this time. + /// + CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED, +} cef_cdm_registration_error_t; + #ifdef __cplusplus } #endif diff --git a/src/include/internal/cef_types_wrappers.h b/src/include/internal/cef_types_wrappers.h index 44b49e94..90278cde 100644 --- a/src/include/internal/cef_types_wrappers.h +++ b/src/include/internal/cef_types_wrappers.h @@ -607,6 +607,8 @@ struct CefSettingsTraits { target->uncaught_exception_stack_size = src->uncaught_exception_stack_size; target->context_safety_implementation = src->context_safety_implementation; target->ignore_certificate_errors = src->ignore_certificate_errors; + target->enable_net_security_expiration = + src->enable_net_security_expiration; target->background_color = src->background_color; cef_string_set(src->accept_language_list.str, @@ -639,6 +641,8 @@ struct CefRequestContextSettingsTraits { target->persist_session_cookies = src->persist_session_cookies; target->persist_user_preferences = src->persist_user_preferences; target->ignore_certificate_errors = src->ignore_certificate_errors; + target->enable_net_security_expiration = + src->enable_net_security_expiration; cef_string_set(src->accept_language_list.str, src->accept_language_list.length, &target->accept_language_list, copy); } diff --git a/src/linux/compile.py b/src/linux/compile.py index 6eb2da74..db946753 100644 --- a/src/linux/compile.py +++ b/src/linux/compile.py @@ -33,6 +33,30 @@ except NameError: pass + +def check_cython_version(): + output = subprocess.check_output(["cython", "--version"], + stderr=subprocess.STDOUT) + output = output.strip() + if not isinstance(output, str): + output = output.decode("utf-8") + match = re.search(r"[\d+.]+", output) + assert match, "Checking Cython version failed" + version = match.group(0) + with open("../../tools/requirements.txt", "r") as fileobj: + contents = fileobj.read() + match = re.search(r"cython\s*==\s*([\d.]+)", contents, + flags=re.IGNORECASE) + assert match, "cython package not found in requirements.txt" + require_version = match.group(1) + if version != require_version: + print("ERROR: Wrong Cython version: {}. Required: {}" + .format(version, require_version)) + sys.exit(1) + print("Cython version: {}".format(version)) + +check_cython_version() + # This will not show "Segmentation fault" error message: # | subprocess.call(["python", "./wxpython.py"]) # You need to call it with shell=True for this kind of @@ -280,7 +304,7 @@ run_examples = (" && {python} hello_world.py" " && {python} gtk2.py" " && {python} gtk2.py --message-loop-timer" - " && {python} gtk3.py" + # " && {python} gtk3.py" " && {python} tkinter_.py") commands = ("cd ./installer/" " && {python} make-setup.py --version {ver}" @@ -288,9 +312,9 @@ " && {sudo} {python} setup.py install" " && cd ../" " && {sudo} rm -rf ./cefpython3-{ver}-*-setup/" - " && cd ../../../examples/" - + run_examples + - " && cd ../unittests/" + " && cd ../../../unittests/" " && {python} _test_runner.py" + " && cd ../examples/" + + run_examples + " && cd ../src/linux/") os.system(commands.format(python=sys.executable, ver=VERSION, sudo=sudo)) diff --git a/src/linux/setup/cefpython.h b/src/linux/setup/cefpython.h index d50a6025..bfc9b92b 100644 --- a/src/linux/setup/cefpython.h +++ b/src/linux/setup/cefpython.h @@ -1,4 +1,4 @@ -/* Generated by Cython 0.24.1 */ +/* Generated by Cython 0.25.2 */ #ifndef __PYX_HAVE__cefpython_py27 #define __PYX_HAVE__cefpython_py27 diff --git a/src/settings.pyx b/src/settings.pyx index d6872d76..6e35e845 100644 --- a/src/settings.pyx +++ b/src/settings.pyx @@ -43,8 +43,6 @@ cdef void SetApplicationSettings( cefString = new CefString(&cefAppSettings.accept_language_list) PyToCefStringPointer(appSettings[key], cefString) del cefString - elif key == "multi_threaded_message_loop": - cefAppSettings.multi_threaded_message_loop = int(appSettings[key]) elif key == "cache_path": cefString = new CefString(&cefAppSettings.cache_path) PyToCefStringPointer(appSettings[key], cefString) @@ -69,6 +67,11 @@ cdef void SetApplicationSettings( del cefString elif key == "log_severity": cefAppSettings.log_severity = int(appSettings[key]) + elif key == "multi_threaded_message_loop": + cefAppSettings.multi_threaded_message_loop = int(appSettings[key]) + elif key == "net_security_expiration_enabled": + cefAppSettings.enable_net_security_expiration =\ + int(appSettings[key]) elif key == "release_dcheck_enabled": # Keep for BC, just log info - no error Debug("DEPRECATED: 'release_dcheck_enabled' setting") diff --git a/src/subprocess/cefpython_app.cpp b/src/subprocess/cefpython_app.cpp index fc2efb80..936d2fb3 100644 --- a/src/subprocess/cefpython_app.cpp +++ b/src/subprocess/cefpython_app.cpp @@ -579,7 +579,7 @@ void CefPythonApp::DoJavascriptBindingsForFrame(CefRefPtr browser, for (std::vector::iterator it = objectsVector.begin(); \ it != objectsVector.end(); ++it) { CefString objectName = *it; - CefRefPtr v8Object = CefV8Value::CreateObject(NULL); + CefRefPtr v8Object = CefV8Value::CreateObject(NULL, NULL); v8Window->SetValue(objectName, v8Object, V8_PROPERTY_ATTRIBUTE_NONE); // METHODS. if (!(objects->GetType(objectName) == VTYPE_DICTIONARY)) { diff --git a/src/subprocess/v8utils.cpp b/src/subprocess/v8utils.cpp index ef224886..126657e6 100644 --- a/src/subprocess/v8utils.cpp +++ b/src/subprocess/v8utils.cpp @@ -316,7 +316,7 @@ CefRefPtr CefDictionaryValueToV8Value( "dictValue->GetKeys() failed"); return CefV8Value::CreateNull(); } - CefRefPtr ret = CefV8Value::CreateObject(NULL); + CefRefPtr ret = CefV8Value::CreateObject(NULL, NULL); CefRefPtr binaryValue; PythonCallback pyCallback; CefRefPtr v8FunctionHandler; diff --git a/src/version/cef_version_linux.h b/src/version/cef_version_linux.h index 897fb9a9..ca239f0d 100644 --- a/src/version/cef_version_linux.h +++ b/src/version/cef_version_linux.h @@ -35,16 +35,16 @@ #ifndef CEF_INCLUDE_CEF_VERSION_H_ #define CEF_INCLUDE_CEF_VERSION_H_ -#define CEF_VERSION "3.2840.1494.g7fe3d03" +#define CEF_VERSION "3.2840.1518.gffd843c" #define CEF_VERSION_MAJOR 3 -#define CEF_COMMIT_NUMBER 1494 -#define CEF_COMMIT_HASH "7fe3d037c47c9da9b478fb09073e06d3c30c52e5" +#define CEF_COMMIT_NUMBER 1518 +#define CEF_COMMIT_HASH "ffd843c47c513be4b5e1a7780034b401305cfb28" #define COPYRIGHT_YEAR 2016 #define CHROME_VERSION_MAJOR 54 #define CHROME_VERSION_MINOR 0 #define CHROME_VERSION_BUILD 2840 -#define CHROME_VERSION_PATCH 59 +#define CHROME_VERSION_PATCH 99 #define DO_MAKE_STRING(p) #p #define MAKE_STRING(p) DO_MAKE_STRING(p) @@ -63,13 +63,13 @@ extern "C" { // universal hash value will change if any platform is affected whereas the // platform hash values will change only if that particular platform is // affected. -#define CEF_API_HASH_UNIVERSAL "37fcbfef190e2904e94cef41b2710abc1ed8d6c1" +#define CEF_API_HASH_UNIVERSAL "361f1fd075435038b5b47812a574ca960f6af294" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "b37e78fb101049abfc54c27e57917194e0679cf2" +#define CEF_API_HASH_PLATFORM "fe05aeb5fff130ce334d7ecb22acfd84ee8a7334" #elif defined(OS_MACOSX) -#define CEF_API_HASH_PLATFORM "366ed6f02ce8cf0e34e1e9fea8acf195c13ba6a2" +#define CEF_API_HASH_PLATFORM "58b40170fdf2e68f0a5035622577684462af6011" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "275725e2e7ed42949113899f9e124d8862d2dd17" +#define CEF_API_HASH_PLATFORM "245d21ed57f262d1ef2c6b6396b54e5929e7880d" #endif // Returns CEF version information for the libcef library. The |entry| diff --git a/tools/requirements.txt b/tools/requirements.txt index b3593e58..c5ba053d 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,2 +1,2 @@ -cython == 0.24.1 +cython == 0.25.2 docopt >= 0.6.2 From 2f336cf3c4c9d5a32a1ccdcc56d60ebdbf82d5c0 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Fri, 9 Dec 2016 11:51:38 +0100 Subject: [PATCH 2/2] Python 3.6 support (#121). --- src/linux/installer/__init__.py.template | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/linux/installer/__init__.py.template b/src/linux/installer/__init__.py.template index d78179d9..baebba0f 100644 --- a/src/linux/installer/__init__.py.template +++ b/src/linux/installer/__init__.py.template @@ -28,11 +28,13 @@ libcef_so = os.path.join(package_dir, "libcef.so") ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL) import sys -if 0x02070000 <= sys.hexversion < 0x02080000: +if (2, 7) <= sys.version_info < (2, 8): from . import cefpython_py27 as cefpython -elif 0x03040000 <= sys.hexversion < 0x03050000: +elif (3, 4) <= sys.version_info < (3, 5): from . import cefpython_py34 as cefpython -elif 0x03050000 <= sys.hexversion < 0x03060000: +elif (3, 5) <= sys.version_info < (3, 6): from . import cefpython_py35 as cefpython +elif (3, 6) <= sys.version_info < (3, 7): + from . import cefpython_py36 as cefpython else: raise Exception("Unsupported python version: " + sys.version)