diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..f4f8ab2a --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -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 diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..f4f8ab2a --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -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 diff --git a/api/ApplicationSettings.md b/api/ApplicationSettings.md index cfa467c2..65e95d35 100644 --- a/api/ApplicationSettings.md +++ b/api/ApplicationSettings.md @@ -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) @@ -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) @@ -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 diff --git a/api/Browser.md b/api/Browser.md index 369a7eb7..2f02c60f 100644 --- a/api/Browser.md +++ b/api/Browser.md @@ -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) @@ -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 @@ -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. diff --git a/api/Frame.md b/api/Frame.md index a66fbf65..f214bdcd 100644 --- a/api/Frame.md +++ b/api/Frame.md @@ -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. diff --git a/api/RenderHandler.md b/api/RenderHandler.md index f06d47e9..d680af4b 100644 --- a/api/RenderHandler.md +++ b/api/RenderHandler.md @@ -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) @@ -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 diff --git a/api/RequestHandler.md b/api/RequestHandler.md index 2ed5c67c..80ffd23c 100644 --- a/api/RequestHandler.md +++ b/api/RequestHandler.md @@ -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) 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 f629d519..1693e39f 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 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) @@ -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 @@ -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). @@ -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, diff --git a/examples/gtk2.py b/examples/gtk2.py index 8d716cde..a784021c 100644 --- a/examples/gtk2.py +++ b/examples/gtk2.py @@ -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 @@ -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') @@ -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() diff --git a/examples/tkinter_.py b/examples/tkinter_.py index 22a8759f..8f86e6f0 100644 --- a/examples/tkinter_.py +++ b/examples/tkinter_.py @@ -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: diff --git a/patches/issue231.patch b/patches/issue231.patch index 58d2b1c3..ac6f062e 100644 --- a/patches/issue231.patch +++ b/patches/issue231.patch @@ -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" { @@ -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; @@ -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) { @@ -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; } @@ -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; } diff --git a/src/browser.pyx b/src/browser.pyx index 46e48528..dba50285 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -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: @@ -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() @@ -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, diff --git a/src/cefpython.pyx b/src/cefpython.pyx index 22e59f16..8c7e1f3e 100644 --- a/src/cefpython.pyx +++ b/src/cefpython.pyx @@ -386,7 +386,6 @@ cdef extern from *: # noinspection PyUnresolvedReferences from cef_types cimport ( CefSettings, CefBrowserSettings, CefRect, CefPoint, - CefRequestContextSettings, CefKeyEvent, CefMouseEvent, CefScreenInfo, PathKey, PK_DIR_EXE, PK_DIR_MODULE, ) @@ -777,19 +776,18 @@ def CreateBrowserSync(windowInfo=None, # Request context - part 1/2. createSharedRequestContext = bool(not g_sharedRequestContext.get()) - cdef CefRequestContextSettings requestContextSettings cdef CefRefPtr[CefRequestContext] cefRequestContext cdef CefRefPtr[RequestContextHandler] requestContextHandler =\ new RequestContextHandler( cefBrowser) if g_applicationSettings["unique_request_context_per_browser"]: - cefRequestContext = CefRequestContext_CreateContext( - requestContextSettings, + cefRequestContext = CefRequestContext.CreateContext( + CefRequestContext.GetGlobalContext(), requestContextHandler) else: if createSharedRequestContext: - cefRequestContext = CefRequestContext_CreateContext( - requestContextSettings, + cefRequestContext = CefRequestContext.CreateContext( + CefRequestContext.GetGlobalContext(), \ requestContextHandler) g_sharedRequestContext.Assign(cefRequestContext.get()) @@ -860,47 +858,85 @@ def Shutdown(): Debug("Shutdown: releasing shared request context") g_sharedRequestContext.Assign(NULL) - if len(g_pyBrowsers) and _MessageLoopWork_wasused: - # There might be a case when python error occured after creating - # browser, but before any message loop was run. In such case - # the renderer process won't be terminated unless we run some - # message loop work here first, try to close browser and free - # reference, and then run some message loop work again. - for i in range(10): + # Run some message loop work, force closing browsers and then run + # some message loop work again for the browsers to close cleanly. + # + # CASE 1: + # There might be a case when python error occured after creating + # browser, but before any message loop was run. In such case + # the renderer process won't be terminated unless we run some + # message loop work here first, close browser and free + # reference, and then run some message loop work again. + # + # CASE 2: + # Application closes browser and then calls CEF shutdown. We need + # to run some message loop work so that browser can close cleanly. + # Looks like running message loop work is also required when + # application runs MessageLoop() (Issue #282 and the hello_world.py + # example). + # + # CASE 3: + # Run some message loop work to fix possible errors on shutdown. + # See this post: + # >> https://magpcss.org/ceforum/viewtopic.php?p=30858#p30858 + # May be fixed by host owned message loop, see Issue 1805: + # >> https://bitbucket.org/chromiumembedded/cef/issues/1805/ + + # This 0.2 sec message loop work should close browsers and clean + # CEF references. Even when CloseBrowser(True) wasn't called + # in client app, then this code below should close it cleanly. + # Looks like CEF detects that parent window was destroyed + # and closes browser automatically if you give it some time. + # If the time was not enough, then there is an emergency plan, + # the code block further down that checks len(g_pyBrowsers). + for _ in range(20): + for __ in range(10): with nogil: CefDoMessageLoopWork() - time.sleep(0.01) + time.sleep(0.01) + + # Emergency plan in case the code above didn't close browsers, + # and neither browsers were closed in client app. This code + # will force closing browsers by calling CloseBrowser(True) + # and then free global g_pyBrowsers list that keeps CEF + # references alive. + if len(g_pyBrowsers): browsers_list = [] for browserId in g_pyBrowsers: # Cannot close browser here otherwise error: # > dictionary changed size during iteration browsers_list.append(browserId) + browser_close_forced = False for browserId in browsers_list: browser = GetPyBrowserById(browserId) - if browser: - browser.TryCloseBrowser() + if browser and browserId not in g_closed_browsers: + Debug("WARNING: Browser was not closed with CloseBrowser call." + " Will close it safely now, but this will delay CEF" + " shutdown by 0.2 sec.") + browser.CloseBrowser(True) + browser_close_forced = True + browser = None # free reference RemovePyBrowser(browserId) - for i in range(10): - with nogil: - CefDoMessageLoopWork() - time.sleep(0.01) + if browser_close_forced: + for _ in range(20): + for __ in range(10): + with nogil: + CefDoMessageLoopWork() + time.sleep(0.01) + # Message loop work was run, so handlers callbacks might got called + # and browsers might still be in g_pyBrowsers. + for browserId in browsers_list: + if browserId in g_pyBrowsers: + RemovePyBrowser(browserId) + # If the the two code blocks above, that tried to close browsers + # and free CEF references, failed, then display an error about it! if len(g_pyBrowsers): - Error("Shutdown called, but there are still browser references alive") + Error("Shutdown called, but there are still browser references alive!") Debug("Shutdown()") with nogil: - # Temporary fix for possible errors on shutdown. See this post: - # https://magpcss.org/ceforum/viewtopic.php?p=30858#p30858 - # May be fixed by host owned message loop, see Issue 1805: - # https://bitbucket.org/chromiumembedded/cef/issues/1805/ - if _MessageLoopWork_wasused: - for i in range(10): - CefDoMessageLoopWork() CefShutdown() - if _MessageLoopWork_wasused: - for i in range(10): - CefDoMessageLoopWork() # Release external message pump, as in cefclient after Shutdown if g_external_message_pump.get(): diff --git a/src/extern/cef/cef_request_context.pxd b/src/extern/cef/cef_request_context.pxd index 7ce07efe..08a79612 100644 --- a/src/extern/cef/cef_request_context.pxd +++ b/src/extern/cef/cef_request_context.pxd @@ -5,12 +5,12 @@ from cef_ptr cimport CefRefPtr # noinspection PyUnresolvedReferences from cef_request_context_handler cimport CefRequestContextHandler -from cef_types cimport CefRequestContextSettings cdef extern from "include/cef_request_context.h": cdef cppclass CefRequestContext: - pass - cdef CefRefPtr[CefRequestContext] CefRequestContext_CreateContext\ - "CefRequestContext::CreateContext"( - const CefRequestContextSettings& settings, - CefRefPtr[CefRequestContextHandler] handler) + @staticmethod + CefRefPtr[CefRequestContext] GetGlobalContext() + @staticmethod + CefRefPtr[CefRequestContext] CreateContext( + CefRefPtr[CefRequestContext] other, + CefRefPtr[CefRequestContextHandler] handler) 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/frame.pyx b/src/frame.pyx index b39454e0..a8502427 100644 --- a/src/frame.pyx +++ b/src/frame.pyx @@ -110,7 +110,7 @@ cdef class PyFrame: self.ExecuteJavascript(code) cpdef py_void ExecuteJavascript(self, py_string jsCode, - py_string scriptUrl="", int startLine=0): + py_string scriptUrl="", int startLine=1): self.GetCefFrame().get().ExecuteJavaScript(PyToCefStringValue(jsCode), PyToCefStringValue(scriptUrl), startLine) diff --git a/src/include/base/cef_macros.h b/src/include/base/cef_macros.h index 59c02029..df3f9b7c 100644 --- a/src/include/base/cef_macros.h +++ b/src/include/base/cef_macros.h @@ -36,13 +36,6 @@ // When building CEF include the Chromium header directly. #include "base/macros.h" -// Chromium uses movable types. -#define MOVE_SCOPED_PTR(var) std::move(var) - -// Chromium uses std types. -#define SCOPED_PTR(type) std::unique_ptr -#define DEFAULT_DELETER(type) std::default_delete - #else // !USING_CHROMIUM_INCLUDES // The following is substantially similar to the Chromium implementation. // If the Chromium implementation diverges the below implementation should be @@ -51,13 +44,6 @@ #include // For size_t. #include "include/base/cef_build.h" // For COMPILER_MSVC -// CEF does not use movable types. -#define MOVE_SCOPED_PTR(var) var.Pass() - -// CEF uses base types. -#define SCOPED_PTR(type) scoped_ptr -#define DEFAULT_DELETER(type) struct base::DefaultDeleter - #if !defined(arraysize) // The arraysize(arr) macro returns the # of elements in an array arr. diff --git a/src/include/cef_browser.h b/src/include/cef_browser.h index eda660f1..2d4d8abb 100644 --- a/src/include/cef_browser.h +++ b/src/include/cef_browser.h @@ -669,24 +669,66 @@ class CefBrowserHost : public virtual CefBase { virtual void SetWindowlessFrameRate(int frame_rate) =0; /// - // Get the NSTextInputContext implementation for enabling IME on Mac when - // window rendering is disabled. + // Begins a new composition or updates the existing composition. Blink has a + // special node (a composition node) that allows the input method to change + // text without affecting other DOM nodes. |text| is the optional text that + // will be inserted into the composition node. |underlines| is an optional set + // of ranges that will be underlined in the resulting text. + // |replacement_range| is an optional range of the existing text that will be + // replaced. |selection_range| is an optional range of the resulting text that + // will be selected after insertion or replacement. The |replacement_range| + // value is only used on OS X. + // + // This method may be called multiple times as the composition changes. When + // the client is done making changes the composition should either be canceled + // or completed. To cancel the composition call ImeCancelComposition. To + // complete the composition call either ImeCommitText or + // ImeFinishComposingText. Completion is usually signaled when: + // A. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR + // flag (on Windows), or; + // B. The client receives a "commit" signal of GtkIMContext (on Linux), or; + // C. insertText of NSTextInput is called (on Mac). + // + // This method is only used when window rendering is disabled. /// - /*--cef(default_retval=NULL)--*/ - virtual CefTextInputContext GetNSTextInputContext() =0; + /*--cef(optional_param=text, optional_param=underlines)--*/ + virtual void ImeSetComposition( + const CefString& text, + const std::vector& underlines, + const CefRange& replacement_range, + const CefRange& selection_range) =0; /// - // Handles a keyDown event prior to passing it through the NSTextInputClient - // machinery. + // Completes the existing composition by optionally inserting the specified + // |text| into the composition node. |replacement_range| is an optional range + // of the existing text that will be replaced. |relative_cursor_pos| is where + // the cursor will be positioned relative to the current cursor position. See + // comments on ImeSetComposition for usage. The |replacement_range| and + // |relative_cursor_pos| values are only used on OS X. + // This method is only used when window rendering is disabled. + /// + /*--cef(optional_param=text)--*/ + virtual void ImeCommitText(const CefString& text, + const CefRange& replacement_range, + int relative_cursor_pos) =0; + + /// + // Completes the existing composition by applying the current composition node + // contents. If |keep_selection| is false the current selection, if any, will + // be discarded. See comments on ImeSetComposition for usage. + // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) =0; + virtual void ImeFinishComposingText(bool keep_selection) =0; /// - // Performs any additional actions after NSTextInputClient handles the event. + // Cancels the existing composition and discards the composition node + // contents without applying them. See comments on ImeSetComposition for + // usage. + // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) =0; + virtual void ImeCancelComposition() =0; /// // Call this method when the user drags the mouse into the web view (before diff --git a/src/include/cef_file_util.h b/src/include/cef_file_util.h new file mode 100644 index 00000000..d18f886c --- /dev/null +++ b/src/include/cef_file_util.h @@ -0,0 +1,118 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_FILE_UTIL_H_ +#define CEF_INCLUDE_CEF_FILE_UTIL_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Creates a directory and all parent directories if they don't already exist. +// Returns true on successful creation or if the directory already exists. The +// directory is only readable by the current user. Calling this function on the +// browser process UI or IO threads is not allowed. +/// +/*--cef()--*/ +bool CefCreateDirectory(const CefString& full_path); + +/// +// Get the temporary directory provided by the system. +// +// WARNING: In general, you should use the temp directory variants below instead +// of this function. Those variants will ensure that the proper permissions are +// set so that other users on the system can't edit them while they're open +// (which could lead to security issues). +/// +/*--cef()--*/ +bool CefGetTempDirectory(CefString& temp_dir); + +/// +// Creates a new directory. On Windows if |prefix| is provided the new directory +// name is in the format of "prefixyyyy". Returns true on success and sets +// |new_temp_path| to the full path of the directory that was created. The +// directory is only readable by the current user. Calling this function on the +// browser process UI or IO threads is not allowed. +/// +/*--cef(optional_param=prefix)--*/ +bool CefCreateNewTempDirectory(const CefString& prefix, + CefString& new_temp_path); + +/// +// Creates a directory within another directory. Extra characters will be +// appended to |prefix| to ensure that the new directory does not have the same +// name as an existing directory. Returns true on success and sets |new_dir| to +// the full path of the directory that was created. The directory is only +// readable by the current user. Calling this function on the browser process +// UI or IO threads is not allowed. +/// +/*--cef(optional_param=prefix)--*/ +bool CefCreateTempDirectoryInDirectory(const CefString& base_dir, + const CefString& prefix, + CefString& new_dir); + +/// +// Returns true if the given path exists and is a directory. Calling this +// function on the browser process UI or IO threads is not allowed. +/// +/*--cef()--*/ +bool CefDirectoryExists(const CefString& path); + +/// +// Deletes the given path whether it's a file or a directory. If |path| is a +// directory all contents will be deleted. If |recursive| is true any sub- +// directories and their contents will also be deleted (equivalent to executing +// "rm -rf", so use with caution). On POSIX environments if |path| is a symbolic +// link then only the symlink will be deleted. Returns true on successful +// deletion or if |path| does not exist. Calling this function on the browser +// process UI or IO threads is not allowed. +/// +/*--cef()--*/ +bool CefDeleteFile(const CefString& path, bool recursive); + +/// +// Writes the contents of |src_dir| into a zip archive at |dest_file|. If +// |include_hidden_files| is true files starting with "." will be included. +// Returns true on success. Calling this function on the browser process UI or +// IO threads is not allowed. +/// +/*--cef()--*/ +bool CefZipDirectory(const CefString& src_dir, + const CefString& dest_file, + bool include_hidden_files); + +#endif // CEF_INCLUDE_CEF_FILE_UTIL_H_ 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 1b84f2f9..0f857b07 100644 --- a/src/include/cef_render_handler.h +++ b/src/include/cef_render_handler.h @@ -176,6 +176,16 @@ class CefRenderHandler : public virtual CefBase { virtual void OnScrollOffsetChanged(CefRefPtr browser, double x, double y) {} + + /// + // Called when the IME composition range has changed. |selected_range| is the + // range of characters that have been selected. |character_bounds| is the + // bounds of each character in view coordinates. + /// + /*--cef()--*/ + virtual void OnImeCompositionRangeChanged(CefRefPtr browser, + const CefRange& selected_range, + const RectList& character_bounds) {} }; #endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_ diff --git a/src/include/cef_thread.h b/src/include/cef_thread.h new file mode 100644 index 00000000..a0e78c49 --- /dev/null +++ b/src/include/cef_thread.h @@ -0,0 +1,117 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_THREAD_H_ +#define CEF_INCLUDE_CEF_THREAD_H_ +#pragma once + +#include "include/cef_task.h" +#include "include/internal/cef_thread_internal.h" + +/// +// A simple thread abstraction that establishes a message loop on a new thread. +// The consumer uses CefTaskRunner to execute code on the thread's message loop. +// The thread is terminated when the CefThread object is destroyed or Stop() is +// called. All pending tasks queued on the thread's message loop will run to +// completion before the thread is terminated. CreateThread() can be called on +// any valid CEF thread in either the browser or render process. This class +// should only be used for tasks that require a dedicated thread. In most cases +// you can post tasks to an existing CEF thread instead of creating a new one; +// see cef_task.h for details. +/// +/*--cef(source=library)--*/ +class CefThread : public CefBase { + public: + /// + // Create and start a new thread. This method does not block waiting for the + // thread to run initialization. |display_name| is the name that will be used + // to identify the thread. |priority| is the thread execution priority. + // |message_loop_type| indicates the set of asynchronous events that the + // thread can process. If |stoppable| is true the thread will stopped and + // joined on destruction or when Stop() is called; otherwise, the the thread + // cannot be stopped and will be leaked on shutdown. On Windows the + // |com_init_mode| value specifies how COM will be initialized for the thread. + // If |com_init_mode| is set to COM_INIT_MODE_STA then |message_loop_type| + // must be set to ML_TYPE_UI. + /// + /*--cef(optional_param=display_name)--*/ + static CefRefPtr CreateThread( + const CefString& display_name, + cef_thread_priority_t priority, + cef_message_loop_type_t message_loop_type, + bool stoppable, + cef_com_init_mode_t com_init_mode); + + /// + // Create and start a new thread with default/recommended values. + // |display_name| is the name that will be used to identify the thread. + /// + static CefRefPtr CreateThread(const CefString& display_name) { + return CreateThread(display_name, TP_NORMAL, ML_TYPE_DEFAULT, true, + COM_INIT_MODE_NONE); + } + + /// + // Returns the CefTaskRunner that will execute code on this thread's message + // loop. This method is safe to call from any thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetTaskRunner() =0; + + /// + // Returns the platform thread ID. It will return the same value after Stop() + // is called. This method is safe to call from any thread. + /// + /*--cef(default_retval=kInvalidPlatformThreadId)--*/ + virtual cef_platform_thread_id_t GetPlatformThreadId() =0; + + /// + // Stop and join the thread. This method must be called from the same thread + // that called CreateThread(). Do not call this method if CreateThread() was + // called with a |stoppable| value of false. + /// + /*--cef()--*/ + virtual void Stop() =0; + + /// + // Returns true if the thread is currently running. This method must be called + // from the same thread that called CreateThread(). + /// + /*--cef()--*/ + virtual bool IsRunning() =0; +}; + +#endif // CEF_INCLUDE_CEF_THREAD_H_ diff --git a/src/include/cef_v8.h b/src/include/cef_v8.h index a11073e7..f33090a4 100644 --- a/src/include/cef_v8.h +++ b/src/include/cef_v8.h @@ -589,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_values.h b/src/include/cef_values.h index 6ab6adff..86fa40ef 100644 --- a/src/include/cef_values.h +++ b/src/include/cef_values.h @@ -606,14 +606,14 @@ class CefListValue : public virtual CefBase { /// // Removes the value at the specified index. /// - /*--cef(index_param=index)--*/ - virtual bool Remove(int index) =0; + /*--cef()--*/ + virtual bool Remove(size_t index) =0; /// // Returns the value type at the specified index. /// - /*--cef(default_retval=VTYPE_INVALID,index_param=index)--*/ - virtual CefValueType GetType(int index) =0; + /*--cef(default_retval=VTYPE_INVALID)--*/ + virtual CefValueType GetType(size_t index) =0; /// // Returns the value at the specified index. For simple types the returned @@ -622,55 +622,55 @@ class CefListValue : public virtual CefBase { // returned value will reference existing data and modifications to the value // will modify this object. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetValue(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetValue(size_t index) =0; /// // Returns the value at the specified index as type bool. /// - /*--cef(index_param=index)--*/ - virtual bool GetBool(int index) =0; + /*--cef()--*/ + virtual bool GetBool(size_t index) =0; /// // Returns the value at the specified index as type int. /// - /*--cef(index_param=index)--*/ - virtual int GetInt(int index) =0; + /*--cef()--*/ + virtual int GetInt(size_t index) =0; /// // Returns the value at the specified index as type double. /// - /*--cef(index_param=index)--*/ - virtual double GetDouble(int index) =0; + /*--cef()--*/ + virtual double GetDouble(size_t index) =0; /// // Returns the value at the specified index as type string. /// - /*--cef(index_param=index)--*/ - virtual CefString GetString(int index) =0; + /*--cef()--*/ + virtual CefString GetString(size_t index) =0; /// // Returns the value at the specified index as type binary. The returned // value will reference existing data. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetBinary(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetBinary(size_t index) =0; /// // Returns the value at the specified index as type dictionary. The returned // value will reference existing data and modifications to the value will // modify this object. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetDictionary(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetDictionary(size_t index) =0; /// // Returns the value at the specified index as type list. The returned // value will reference existing data and modifications to the value will // modify this object. /// - /*--cef(index_param=index)--*/ - virtual CefRefPtr GetList(int index) =0; + /*--cef()--*/ + virtual CefRefPtr GetList(size_t index) =0; /// // Sets the value at the specified index. Returns true if the value was set @@ -680,43 +680,43 @@ class CefListValue : public virtual CefBase { // underlying data will be referenced and modifications to |value| will modify // this object. /// - /*--cef(index_param=index)--*/ - virtual bool SetValue(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetValue(size_t index, CefRefPtr value) =0; /// // Sets the value at the specified index as type null. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetNull(int index) =0; + /*--cef()--*/ + virtual bool SetNull(size_t index) =0; /// // Sets the value at the specified index as type bool. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetBool(int index, bool value) =0; + /*--cef()--*/ + virtual bool SetBool(size_t index, bool value) =0; /// // Sets the value at the specified index as type int. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetInt(int index, int value) =0; + /*--cef()--*/ + virtual bool SetInt(size_t index, int value) =0; /// // Sets the value at the specified index as type double. Returns true if the // value was set successfully. /// - /*--cef(index_param=index)--*/ - virtual bool SetDouble(int index, double value) =0; + /*--cef()--*/ + virtual bool SetDouble(size_t index, double value) =0; /// // Sets the value at the specified index as type string. Returns true if the // value was set successfully. /// - /*--cef(optional_param=value,index_param=index)--*/ - virtual bool SetString(int index, const CefString& value) =0; + /*--cef(optional_param=value)--*/ + virtual bool SetString(size_t index, const CefString& value) =0; /// // Sets the value at the specified index as type binary. Returns true if the @@ -725,8 +725,8 @@ class CefListValue : public virtual CefBase { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - /*--cef(index_param=index)--*/ - virtual bool SetBinary(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetBinary(size_t index, CefRefPtr value) =0; /// // Sets the value at the specified index as type dict. Returns true if the @@ -735,8 +735,8 @@ class CefListValue : public virtual CefBase { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - /*--cef(index_param=index)--*/ - virtual bool SetDictionary(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetDictionary(size_t index, CefRefPtr value) =0; /// // Sets the value at the specified index as type list. Returns true if the @@ -745,8 +745,8 @@ class CefListValue : public virtual CefBase { // Otherwise, ownership will be transferred to this object and the |value| // reference will be invalidated. /// - /*--cef(index_param=index)--*/ - virtual bool SetList(int index, CefRefPtr value) =0; + /*--cef()--*/ + virtual bool SetList(size_t index, CefRefPtr value) =0; }; #endif // CEF_INCLUDE_CEF_VALUES_H_ diff --git a/src/include/cef_waitable_event.h b/src/include/cef_waitable_event.h new file mode 100644 index 00000000..4a4e9950 --- /dev/null +++ b/src/include/cef_waitable_event.h @@ -0,0 +1,109 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_WAITABLE_EVENT_H_ +#define CEF_INCLUDE_CEF_WAITABLE_EVENT_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// WaitableEvent is a thread synchronization tool that allows one thread to wait +// for another thread to finish some work. This is equivalent to using a +// Lock+ConditionVariable to protect a simple boolean value. However, using +// WaitableEvent in conjunction with a Lock to wait for a more complex state +// change (e.g., for an item to be added to a queue) is not recommended. In that +// case consider using a ConditionVariable instead of a WaitableEvent. It is +// safe to create and/or signal a WaitableEvent from any thread. Blocking on a +// WaitableEvent by calling the *Wait() methods is not allowed on the browser +// process UI or IO threads. +/// +/*--cef(source=library)--*/ +class CefWaitableEvent : public CefBase { + public: + /// + // Create a new waitable event. If |automatic_reset| is true then the event + // state is automatically reset to un-signaled after a single waiting thread + // has been released; otherwise, the state remains signaled until Reset() is + // called manually. If |initially_signaled| is true then the event will start + // in the signaled state. + /// + /*--cef()--*/ + static CefRefPtr CreateWaitableEvent( + bool automatic_reset, + bool initially_signaled); + + /// + // Put the event in the un-signaled state. + /// + /*--cef()--*/ + virtual void Reset() =0; + + /// + // Put the event in the signaled state. This causes any thread blocked on Wait + // to be woken up. + /// + /*--cef()--*/ + virtual void Signal() =0; + + /// + // Returns true if the event is in the signaled state, else false. If the + // event was created with |automatic_reset| set to true then calling this + // method will also cause a reset. + /// + /*--cef()--*/ + virtual bool IsSignaled() =0; + + /// + // Wait indefinitely for the event to be signaled. This method will not return + // until after the call to Signal() has completed. This method cannot be + // called on the browser process UI or IO threads. + /// + /*--cef()--*/ + virtual void Wait() =0; + + /// + // Wait up to |max_ms| milliseconds for the event to be signaled. Returns true + // if the event was signaled. A return value of false does not necessarily + // mean that |max_ms| was exceeded. This method will not return until after + // the call to Signal() has completed. This method cannot be called on the + // browser process UI or IO threads. + /// + /*--cef()--*/ + virtual bool TimedWait(int64 max_ms) =0; +}; + +#endif // CEF_INCLUDE_CEF_WAITABLE_EVENT_H_ diff --git a/src/include/internal/cef_linux.h b/src/include/internal/cef_linux.h index 6238397a..d9813a5b 100644 --- a/src/include/internal/cef_linux.h +++ b/src/include/internal/cef_linux.h @@ -39,7 +39,6 @@ #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; diff --git a/src/include/internal/cef_mac.h b/src/include/internal/cef_mac.h index 8defbfb0..420f16ad 100644 --- a/src/include/internal/cef_mac.h +++ b/src/include/internal/cef_mac.h @@ -39,7 +39,6 @@ #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; diff --git a/src/include/internal/cef_string_list.h b/src/include/internal/cef_string_list.h index 52a0abf2..79c0509f 100644 --- a/src/include/internal/cef_string_list.h +++ b/src/include/internal/cef_string_list.h @@ -51,14 +51,14 @@ CEF_EXPORT cef_string_list_t cef_string_list_alloc(); /// // Return the number of elements in the string list. /// -CEF_EXPORT int cef_string_list_size(cef_string_list_t list); +CEF_EXPORT size_t cef_string_list_size(cef_string_list_t list); /// // Retrieve the value at the specified zero-based string list index. Returns // true (1) if the value was successfully retrieved. /// CEF_EXPORT int cef_string_list_value(cef_string_list_t list, - int index, cef_string_t* value); + size_t index, cef_string_t* value); /// // Append a new value at the end of the string list. diff --git a/src/include/internal/cef_string_map.h b/src/include/internal/cef_string_map.h index 93eea2a5..a22f33a7 100644 --- a/src/include/internal/cef_string_map.h +++ b/src/include/internal/cef_string_map.h @@ -51,7 +51,7 @@ CEF_EXPORT cef_string_map_t cef_string_map_alloc(); /// // Return the number of elements in the string map. /// -CEF_EXPORT int cef_string_map_size(cef_string_map_t map); +CEF_EXPORT size_t cef_string_map_size(cef_string_map_t map); /// // Return the value assigned to the specified key. @@ -63,13 +63,13 @@ CEF_EXPORT int cef_string_map_find(cef_string_map_t map, /// // Return the key at the specified zero-based string map index. /// -CEF_EXPORT int cef_string_map_key(cef_string_map_t map, int index, +CEF_EXPORT int cef_string_map_key(cef_string_map_t map, size_t index, cef_string_t* key); /// // Return the value at the specified zero-based string map index. /// -CEF_EXPORT int cef_string_map_value(cef_string_map_t map, int index, +CEF_EXPORT int cef_string_map_value(cef_string_map_t map, size_t index, cef_string_t* value); /// diff --git a/src/include/internal/cef_string_multimap.h b/src/include/internal/cef_string_multimap.h index cd390424..ee9325b3 100644 --- a/src/include/internal/cef_string_multimap.h +++ b/src/include/internal/cef_string_multimap.h @@ -52,12 +52,12 @@ CEF_EXPORT cef_string_multimap_t cef_string_multimap_alloc(); /// // Return the number of elements in the string multimap. /// -CEF_EXPORT int cef_string_multimap_size(cef_string_multimap_t map); +CEF_EXPORT size_t cef_string_multimap_size(cef_string_multimap_t map); /// // Return the number of values with the specified key. /// -CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, +CEF_EXPORT size_t cef_string_multimap_find_count(cef_string_multimap_t map, const cef_string_t* key); /// @@ -65,19 +65,19 @@ CEF_EXPORT int cef_string_multimap_find_count(cef_string_multimap_t map, /// CEF_EXPORT int cef_string_multimap_enumerate(cef_string_multimap_t map, const cef_string_t* key, - int value_index, + size_t value_index, cef_string_t* value); /// // Return the key at the specified zero-based string multimap index. /// -CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, int index, +CEF_EXPORT int cef_string_multimap_key(cef_string_multimap_t map, size_t index, cef_string_t* key); /// // Return the value at the specified zero-based string multimap index. /// -CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, int index, +CEF_EXPORT int cef_string_multimap_value(cef_string_multimap_t map, size_t index, cef_string_t* value); /// diff --git a/src/include/internal/cef_thread_internal.h b/src/include/internal/cef_thread_internal.h index eee2b2ae..006ff15d 100644 --- a/src/include/internal/cef_thread_internal.h +++ b/src/include/internal/cef_thread_internal.h @@ -46,8 +46,10 @@ extern "C" { #if defined(OS_WIN) typedef DWORD cef_platform_thread_id_t; +#define kInvalidPlatformThreadId 0U #elif defined(OS_POSIX) typedef pid_t cef_platform_thread_id_t; +#define kInvalidPlatformThreadId 0 #endif /// @@ -57,8 +59,10 @@ CEF_EXPORT cef_platform_thread_id_t cef_get_current_platform_thread_id(); #if defined(OS_WIN) typedef DWORD cef_platform_thread_handle_t; +#define kInvalidPlatformThreadHandle 0U #elif defined(OS_POSIX) typedef pthread_t cef_platform_thread_handle_t; +#define kInvalidPlatformThreadHandle 0 #endif /// diff --git a/src/include/internal/cef_time.h b/src/include/internal/cef_time.h index 64e601fe..f7e397f0 100644 --- a/src/include/internal/cef_time.h +++ b/src/include/internal/cef_time.h @@ -42,7 +42,8 @@ extern "C" { // Time information. Values should always be in UTC. /// typedef struct _cef_time_t { - int year; // Four digit year "2007" + int year; // Four or five digit year "2007" (1601 to 30827 on + // Windows, 1970 to 2038 on 32-bit POSIX) int month; // 1-based month (values 1 = January, etc.) int day_of_week; // 0-based day of week (0 = Sunday, etc.) int day_of_month; // 1-based day of month (1-31) diff --git a/src/include/internal/cef_types.h b/src/include/internal/cef_types.h index 933ea6e5..6201a47b 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 @@ -1396,6 +1420,73 @@ typedef enum { TID_RENDERER, } cef_thread_id_t; +/// +// Thread priority values listed in increasing order of importance. +/// +typedef enum { + /// + // Suitable for threads that shouldn't disrupt high priority work. + /// + TP_BACKGROUND, + + /// + // Default priority level. + /// + TP_NORMAL, + + /// + // Suitable for threads which generate data for the display (at ~60Hz). + /// + TP_DISPLAY, + + /// + // Suitable for low-latency, glitch-resistant audio. + /// + TP_REALTIME_AUDIO, +} cef_thread_priority_t; + +/// +// Message loop types. Indicates the set of asynchronous events that a message +// loop can process. +/// +typedef enum { + /// + // Supports tasks and timers. + /// + ML_TYPE_DEFAULT, + + /// + // Supports tasks, timers and native UI events (e.g. Windows messages). + /// + ML_TYPE_UI, + + /// + // Supports tasks, timers and asynchronous IO events. + /// + ML_TYPE_IO, +} cef_message_loop_type_t; + +/// +// Windows COM initialization mode. Specifies how COM will be initialized for a +// new thread. +/// +typedef enum { + /// + // No COM initialization. + /// + COM_INIT_MODE_NONE, + + /// + // Initialize COM using single-threaded apartments. + /// + COM_INIT_MODE_STA, + + /// + // Initialize COM using multi-threaded apartments. + /// + COM_INIT_MODE_MTA, +} cef_com_init_mode_t; + /// // Supported value types. /// @@ -2682,6 +2773,33 @@ typedef enum { CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED, } cef_cdm_registration_error_t; +/// +// Structure representing IME composition underline information. This is a thin +// wrapper around Blink's WebCompositionUnderline class and should be kept in +// sync with that. +/// +typedef struct _cef_composition_underline_t { + /// + // Underline character range. + /// + cef_range_t range; + + /// + // Text color. + /// + cef_color_t color; + + /// + // Background color. + /// + cef_color_t background_color; + + /// + // Set to true (1) for thick underline. + /// + int thick; +} cef_composition_underline_t; + #ifdef __cplusplus } #endif diff --git a/src/include/internal/cef_types_linux.h b/src/include/internal/cef_types_linux.h index 3fb896dd..865a9613 100644 --- a/src/include/internal/cef_types_linux.h +++ b/src/include/internal/cef_types_linux.h @@ -60,7 +60,6 @@ extern "C" { // thread-safe and must only be accessed on the browser process UI thread. /// CEF_EXPORT XDisplay* cef_get_xdisplay(); -#define cef_text_input_context_t void* /// // Structure representing CefExecuteProcess arguments. diff --git a/src/include/internal/cef_types_mac.h b/src/include/internal/cef_types_mac.h index 9603fc60..8947e258 100644 --- a/src/include/internal/cef_types_mac.h +++ b/src/include/internal/cef_types_mac.h @@ -43,22 +43,18 @@ @class NSCursor; @class NSEvent; @class NSView; -@class NSTextInputContext; #else class NSCursor; class NSEvent; struct NSView; -class NSTextInputContext; #endif #define cef_cursor_handle_t NSCursor* #define cef_event_handle_t NSEvent* #define cef_window_handle_t NSView* -#define cef_text_input_context_t NSTextInputContext* #else #define cef_cursor_handle_t void* #define cef_event_handle_t void* #define cef_window_handle_t void* -#define cef_text_input_context_t void* #endif #define kNullCursorHandle NULL diff --git a/src/include/internal/cef_types_win.h b/src/include/internal/cef_types_win.h index 27bf6053..0c23a7e7 100644 --- a/src/include/internal/cef_types_win.h +++ b/src/include/internal/cef_types_win.h @@ -42,7 +42,6 @@ #define cef_cursor_handle_t HCURSOR #define cef_event_handle_t MSG* #define cef_window_handle_t HWND -#define cef_text_input_context_t void* #define kNullCursorHandle NULL #define kNullEventHandle NULL diff --git a/src/include/internal/cef_types_wrappers.h b/src/include/internal/cef_types_wrappers.h index 44b49e94..bbe348df 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); } @@ -975,4 +979,31 @@ struct CefBoxLayoutSettingsTraits { /// typedef CefStructBase CefBoxLayoutSettings; +struct CefCompositionUnderlineTraits { + typedef cef_composition_underline_t struct_type; + + static inline void init(struct_type* s) { + s->range = {0, 0}; + s->color = 0; + s->background_color = 0; + s->thick = 0; + } + + static inline void clear(struct_type* s) { + } + + static inline void set(const struct_type* src, struct_type* target, + bool copy) { + target->range = src->range; + target->color = src->color; + target->background_color = src->background_color; + target->thick = src->thick; + } +}; + +/// +// Class representing IME composition underline. +/// +typedef CefStructBase CefCompositionUnderline; + #endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_ diff --git a/src/include/internal/cef_win.h b/src/include/internal/cef_win.h index 7361a3ce..9c20c481 100644 --- a/src/include/internal/cef_win.h +++ b/src/include/internal/cef_win.h @@ -41,7 +41,6 @@ #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; diff --git a/src/include/test/cef_translator_test.h b/src/include/test/cef_translator_test.h index 5357cc91..c9398dad 100644 --- a/src/include/test/cef_translator_test.h +++ b/src/include/test/cef_translator_test.h @@ -35,16 +35,19 @@ // // THIS FILE IS FOR TESTING PURPOSES ONLY. // -// The APIs defined in this file are for testing purposes only. They will not be -// exposed via the binary distribution. All classes in this file must include -// the 'no_debugct_check' attribute to avoid problems when building the binary -// distribution. +// The APIs defined in this file are for testing purposes only. They should only +// be included from unit test targets. // #ifndef CEF_INCLUDE_TEST_CEF_TEST_H_ #define CEF_INCLUDE_TEST_CEF_TEST_H_ #pragma once +#if !defined(BUILDING_CEF_SHARED) && !defined(WRAPPING_CEF_SHARED) && \ + !defined(UNIT_TEST) +#error This file can be included for unit tests only +#endif + #include #include diff --git a/src/include/wrapper/cef_resource_manager.h b/src/include/wrapper/cef_resource_manager.h index a69b0322..9ab8afad 100644 --- a/src/include/wrapper/cef_resource_manager.h +++ b/src/include/wrapper/cef_resource_manager.h @@ -159,18 +159,18 @@ class CefResourceManager : // The below methods are called on the browser process IO thread. - explicit Request(SCOPED_PTR(RequestState) state); + explicit Request(scoped_ptr state); - SCOPED_PTR(RequestState) SendRequest(); + scoped_ptr SendRequest(); bool HasState(); - static void ContinueOnIOThread(SCOPED_PTR(RequestState) state, + static void ContinueOnIOThread(scoped_ptr state, CefRefPtr handler); - static void StopOnIOThread(SCOPED_PTR(RequestState) state); + static void StopOnIOThread(scoped_ptr state); // Will be non-NULL while the request is pending. Only accessed on the // browser process IO thread. - SCOPED_PTR(RequestState) state_; + scoped_ptr state_; // Params that stay with this request object. Safe to access on any thread. RequestParams params_; @@ -343,10 +343,10 @@ class CefResourceManager : // Methods that manage request state between requests. Called on the browser // process IO thread. - bool SendRequest(SCOPED_PTR(RequestState) state); - void ContinueRequest(SCOPED_PTR(RequestState) state, + bool SendRequest(scoped_ptr state); + void ContinueRequest(scoped_ptr state, CefRefPtr handler); - void StopRequest(SCOPED_PTR(RequestState) state); + void StopRequest(scoped_ptr state); bool IncrementProvider(RequestState* state); void DetachRequestFromProvider(RequestState* state); void GetNextValidProvider(ProviderEntryList::iterator& iterator); @@ -365,7 +365,7 @@ class CefResourceManager : MimeTypeResolver mime_type_resolver_; // Must be the last member. Created and accessed on the IO thread. - SCOPED_PTR(base::WeakPtrFactory) weak_ptr_factory_; + scoped_ptr > weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(CefResourceManager); }; diff --git a/src/include/wrapper/cef_scoped_temp_dir.h b/src/include/wrapper/cef_scoped_temp_dir.h new file mode 100644 index 00000000..f40fa7d6 --- /dev/null +++ b/src/include/wrapper/cef_scoped_temp_dir.h @@ -0,0 +1,118 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef CEF_INCLUDE_SCOPED_TEMP_DIR_H_ +#define CEF_INCLUDE_SCOPED_TEMP_DIR_H_ +#pragma once + +#include "include/base/cef_build.h" +#include "include/base/cef_macros.h" +#include "include/cef_base.h" + +/// +// An object representing a temporary / scratch directory that should be cleaned +// up (recursively) when this object goes out of scope. Note that since +// deletion occurs during the destructor, no further error handling is possible +// if the directory fails to be deleted. As a result, deletion is not +// guaranteed by this class. +// +// Multiple calls to the methods which establish a temporary directory +// (CreateUniqueTempDir, CreateUniqueTempDirUnderPath, and Set) must have +// intervening calls to Delete or Take, or the calls will fail. +/// +class CefScopedTempDir { + public: + /// + // No directory is owned/created initially. + /// + CefScopedTempDir(); + + /// + // Recursively delete path. + /// + ~CefScopedTempDir(); + + /// + // Creates a unique directory in TempPath, and takes ownership of it. + // See file_util::CreateNewTemporaryDirectory. + /// + bool CreateUniqueTempDir() WARN_UNUSED_RESULT; + + /// + // Creates a unique directory under a given path, and takes ownership of it. + /// + bool CreateUniqueTempDirUnderPath(const CefString& path) WARN_UNUSED_RESULT; + + /// + // Takes ownership of directory at |path|, creating it if necessary. + // Don't call multiple times unless Take() has been called first. + /// + bool Set(const CefString& path) WARN_UNUSED_RESULT; + + /// + // Deletes the temporary directory wrapped by this object. + /// + bool Delete() WARN_UNUSED_RESULT; + + /// + // Caller takes ownership of the temporary directory so it won't be destroyed + // when this object goes out of scope. + /// + CefString Take(); + + /// + // Returns the path to the created directory. Call one of the + // CreateUniqueTempDir* methods before getting the path. + /// + const CefString& GetPath() const; + + /// + // Returns true if path_ is empty. + /// + bool IsEmpty() const; + + /// + // Returns true if path_ is non-empty and exists. + /// + bool IsValid() const; + + private: + CefString path_; + + DISALLOW_COPY_AND_ASSIGN(CefScopedTempDir); +}; + +#endif // CEF_INCLUDE_SCOPED_TEMP_DIR_H_ diff --git a/src/include/wrapper/cef_stream_resource_handler.h b/src/include/wrapper/cef_stream_resource_handler.h index 1963bc17..af7fe4af 100644 --- a/src/include/wrapper/cef_stream_resource_handler.h +++ b/src/include/wrapper/cef_stream_resource_handler.h @@ -91,7 +91,7 @@ class CefStreamResourceHandler : public CefResourceHandler { bool read_on_file_thread_; class Buffer; - SCOPED_PTR(Buffer) buffer_; + scoped_ptr buffer_; #if DCHECK_IS_ON() // Used in debug builds to verify that |buffer_| isn't being accessed on // multiple threads at the same time. diff --git a/src/linux/setup/cefpython.h b/src/linux/setup/cefpython.h index ec4f857f..bfc9b92b 100644 --- a/src/linux/setup/cefpython.h +++ b/src/linux/setup/cefpython.h @@ -1,4 +1,4 @@ -/* Generated by Cython 0.25.1 */ +/* Generated by Cython 0.25.2 */ #ifndef __PYX_HAVE__cefpython_py27 #define __PYX_HAVE__cefpython_py27 diff --git a/src/request.pyx b/src/request.pyx index 106504cb..3ae0e667 100644 --- a/src/request.pyx +++ b/src/request.pyx @@ -68,6 +68,8 @@ cdef class PyRequest: cdef cpp_vector[CefRefPtr[CefPostDataElement]] elementVector cdef CefRefPtr[CefPostData] postData = ( self.GetCefRequest().get().GetPostData()) + if postData.get() == NULL: + return {} if postData.get().GetElementCount() == 0: return {} postData.get().GetElements(elementVector) @@ -113,9 +115,7 @@ cdef class PyRequest: return retUrlEncoded cpdef py_void SetPostData(self, object pyPostData): - cdef CefRefPtr[CefPostData] postData = ( - self.GetCefRequest().get().GetPostData()) - postData.get().RemoveElements() + cdef CefRefPtr[CefPostData] postData = CefPostData_Create() cdef CefRefPtr[CefPostDataElement] postDataElement cdef py_string pyElement cdef CefString sfile 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/main_message_loop/main_message_loop.h b/src/subprocess/main_message_loop/main_message_loop.h index 564c118e..50ef9f7b 100644 --- a/src/subprocess/main_message_loop/main_message_loop.h +++ b/src/subprocess/main_message_loop/main_message_loop.h @@ -1,11 +1,9 @@ -// Copied from upstream cefclient with minor modifications. - // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. -#ifndef CEF_TESTS_CEFCLIENT_BROWSER_MAIN_MESSAGE_LOOP_H_ -#define CEF_TESTS_CEFCLIENT_BROWSER_MAIN_MESSAGE_LOOP_H_ +#ifndef CEF_TESTS_SHARED_BROWSER_MAIN_MESSAGE_LOOP_H_ +#define CEF_TESTS_SHARED_BROWSER_MAIN_MESSAGE_LOOP_H_ #pragma once #include "include/base/cef_bind.h" @@ -51,7 +49,7 @@ class MainMessageLoop { protected: // Only allow deletion via scoped_ptr. - friend DEFAULT_DELETER(MainMessageLoop); + friend struct base::DefaultDeleter; MainMessageLoop(); virtual ~MainMessageLoop(); @@ -103,4 +101,4 @@ struct DeleteOnMainThread { } }; -#endif // CEF_TESTS_CEFCLIENT_BROWSER_MAIN_MESSAGE_LOOP_H_ +#endif // CEF_TESTS_SHARED_BROWSER_MAIN_MESSAGE_LOOP_H_ diff --git a/src/subprocess/main_message_loop/main_message_loop_external_pump.h b/src/subprocess/main_message_loop/main_message_loop_external_pump.h index cbe341ab..d94bb037 100644 --- a/src/subprocess/main_message_loop/main_message_loop_external_pump.h +++ b/src/subprocess/main_message_loop/main_message_loop_external_pump.h @@ -1,11 +1,9 @@ -// Copied from upstream cefclient with minor modifications. - // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. -#ifndef CEF_TESTS_CEFCLIENT_BROWSER_MAIN_MESSAGE_LOOP_EXTERNAL_PUMP_H_ -#define CEF_TESTS_CEFCLIENT_BROWSER_MAIN_MESSAGE_LOOP_EXTERNAL_PUMP_H_ +#ifndef CEF_TESTS_SHARED_BROWSER_MAIN_MESSAGE_LOOP_EXTERNAL_PUMP_H_ +#define CEF_TESTS_SHARED_BROWSER_MAIN_MESSAGE_LOOP_EXTERNAL_PUMP_H_ #pragma once #include "main_message_loop_std.h" @@ -17,13 +15,13 @@ // correctly). See comments in Chromium's platform-specific // base/message_loop/message_pump_* source files for additional guidance when // implementing CefBrowserProcessHandler::OnScheduleMessagePumpWork() in your -// application. Run cefclient or cef_unittests with the +// application. Run cefclient or ceftests with the // "--external-message-pump" command-line flag to test this mode. class MainMessageLoopExternalPump : public MainMessageLoopStd { public: // Creates the singleton instance of this object. Must be called on the main // application thread. - static SCOPED_PTR(MainMessageLoopExternalPump) Create(); + static scoped_ptr Create(); // Returns the singleton instance of this object. Safe to call from any // thread. @@ -36,7 +34,7 @@ class MainMessageLoopExternalPump : public MainMessageLoopStd { protected: // Only allow deletion via scoped_ptr. - friend DEFAULT_DELETER(MainMessageLoopExternalPump); + friend struct base::DefaultDeleter; // Construct and destruct this object on the main application thread. MainMessageLoopExternalPump(); @@ -65,4 +63,4 @@ class MainMessageLoopExternalPump : public MainMessageLoopStd { bool reentrancy_detected_; }; -#endif // CEF_TESTS_CEFCLIENT_BROWSER_MAIN_MESSAGE_LOOP_EXTERNAL_PUMP_H_ +#endif // CEF_TESTS_SHARED_BROWSER_MAIN_MESSAGE_LOOP_EXTERNAL_PUMP_H_ diff --git a/src/subprocess/main_message_loop/main_message_loop_external_pump_linux.cpp b/src/subprocess/main_message_loop/main_message_loop_external_pump_linux.cpp index 18484b50..773149f6 100644 --- a/src/subprocess/main_message_loop/main_message_loop_external_pump_linux.cpp +++ b/src/subprocess/main_message_loop/main_message_loop_external_pump_linux.cpp @@ -99,7 +99,7 @@ class MainMessageLoopExternalPumpLinux : public MainMessageLoopExternalPump { int wakeup_pipe_write_; // Use a scoped_ptr to avoid needing the definition of GPollFD in the header. - SCOPED_PTR(GPollFD) wakeup_gpollfd_; + scoped_ptr wakeup_gpollfd_; }; // Return a timeout suitable for the glib loop, -1 to block forever, @@ -296,8 +296,8 @@ bool MainMessageLoopExternalPumpLinux::IsTimerPending() { } // namespace // static -SCOPED_PTR(MainMessageLoopExternalPump) +scoped_ptr MainMessageLoopExternalPump::Create() { - return SCOPED_PTR(MainMessageLoopExternalPump)( + return scoped_ptr( new MainMessageLoopExternalPumpLinux()); } diff --git a/src/subprocess/main_message_loop/main_message_loop_external_pump_mac.mm b/src/subprocess/main_message_loop/main_message_loop_external_pump_mac.mm index b10b4fc1..f77c4d27 100644 --- a/src/subprocess/main_message_loop/main_message_loop_external_pump_mac.mm +++ b/src/subprocess/main_message_loop/main_message_loop_external_pump_mac.mm @@ -1,5 +1,3 @@ -// Copied from upstream cefclient with minor modifications. - // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. @@ -158,8 +156,8 @@ - (void)timerTimeout:(id)obj { } // static -SCOPED_PTR(MainMessageLoopExternalPump) +scoped_ptr MainMessageLoopExternalPump::Create() { - return SCOPED_PTR(MainMessageLoopExternalPump)( + return scoped_ptr( new MainMessageLoopExternalPumpMac()); } diff --git a/src/subprocess/main_message_loop/main_message_loop_external_pump_win.cpp b/src/subprocess/main_message_loop/main_message_loop_external_pump_win.cpp index 8247761b..0de7ebf8 100644 --- a/src/subprocess/main_message_loop/main_message_loop_external_pump_win.cpp +++ b/src/subprocess/main_message_loop/main_message_loop_external_pump_win.cpp @@ -140,8 +140,8 @@ LRESULT CALLBACK MainMessageLoopExternalPumpWin::WndProc( } // namespace // static -SCOPED_PTR(MainMessageLoopExternalPump) +scoped_ptr>MainMessageLoopExternalPump> MainMessageLoopExternalPump::Create() { - return SCOPED_PTR(MainMessageLoopExternalPump)( + return scoped_ptr>MainMessageLoopExternalPump>( new MainMessageLoopExternalPumpWin()); } diff --git a/src/utils.pyx b/src/utils.pyx index e74e9515..86ced211 100644 --- a/src/utils.pyx +++ b/src/utils.pyx @@ -116,9 +116,16 @@ cpdef str GetNavigateUrl(py_string url): url = re.sub(r"^([a-zA-Z])%3A", r"\1:", url) # Allow hash when loading urls. The pathname2url function - # replaced hashes with "%23" (Issue 114). + # replaced hashes with "%23" (Issue #114). url = url.replace("%23", "#") + # Allow more special characters when loading urls. The pathname2url + # function encoded them and need to decode them back here + # Characters: ? & = (Issue #273). + url = url.replace("%3F", "?") + url = url.replace("%26", "&") + url = url.replace("%3D", "=") + return str(url) cpdef py_bool IsFunctionOrMethod(object valueType): diff --git a/src/version/cef_version_linux.h b/src/version/cef_version_linux.h index 6c74ecd3..b1cc4dc7 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.2883.1506.ga6c42a7" +#define CEF_VERSION "3.2883.1539.gd7f087e" #define CEF_VERSION_MAJOR 3 -#define CEF_COMMIT_NUMBER 1506 -#define CEF_COMMIT_HASH "a6c42a74b1370e8aa15ff7a8ac40606e9a34b907" +#define CEF_COMMIT_NUMBER 1539 +#define CEF_COMMIT_HASH "d7f087e76634af8ceffdef28c794b7310bb507e5" #define COPYRIGHT_YEAR 2016 #define CHROME_VERSION_MAJOR 55 #define CHROME_VERSION_MINOR 0 #define CHROME_VERSION_BUILD 2883 -#define CHROME_VERSION_PATCH 21 +#define CHROME_VERSION_PATCH 59 #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 "570e8814b7133a7d60b30ddbb04fda2612dfa47a" +#define CEF_API_HASH_UNIVERSAL "95aeb3fed6b2c813abe66fda168b5176cc520f6e" #if defined(OS_WIN) -#define CEF_API_HASH_PLATFORM "069ab812ebbe0769838fd21514a7880f187c9cc5" +#define CEF_API_HASH_PLATFORM "7ece9a94eb706c0814b34b3bb4dc227edf46fdec" #elif defined(OS_MACOSX) -#define CEF_API_HASH_PLATFORM "5178238cc5b4e6207e1798838c09c291b1c74322" +#define CEF_API_HASH_PLATFORM "6361eb5f8e0440c4e103f1c95373eef83c16f242" #elif defined(OS_LINUX) -#define CEF_API_HASH_PLATFORM "fd911beb3f55bbaafd5a5a02c25b26b222bbdef3" +#define CEF_API_HASH_PLATFORM "37b7bf683bd6d8d858acbaba00f30796ca530b2a" #endif // Returns CEF version information for the libcef library. The |entry| diff --git a/tools/automate.py b/tools/automate.py index 321377c9..5b5a0667 100644 --- a/tools/automate.py +++ b/tools/automate.py @@ -147,7 +147,6 @@ def setup_options(docopt_args): Options.cef_branch = get_cefpython_version()["CHROME_VERSION_BUILD"] Options.cef_commit = get_cefpython_version()["CEF_COMMIT_HASH"] - # --gyp-msvs-version if not Options.gyp_msvs_version: if int(Options.cef_branch) >= 2704: @@ -212,7 +211,7 @@ def build_cef(): # Run automate-git.py run_automate_git() - # Build cefclient, cefsimple, libcef_dll_wrapper + # Build cefclient, cefsimple, ceftests, libcef_dll_wrapper build_cef_projects() @@ -282,7 +281,7 @@ def update_cef_patches(): def build_cef_projects(): - """Build cefclient, cefsimple, libcef_dll_wrapper.""" + """Build cefclient, cefsimple, ceftests, libcef_dll_wrapper.""" print("[automate.py] Binary distrib created in %s" % Options.binary_distrib) print("[automate.py] Building cef projects...") @@ -308,8 +307,8 @@ def build_cef_projects(): build_cefclient = os.path.join(cef_binary, "build_cefclient") os.makedirs(build_cefclient) - # Build cefclient and cefsimple - print("[automate.py] Building cefclient and cefsimple...") + # Build cefclient, cefsimple, ceftests + print("[automate.py] Building cefclient, cefsimple, ceftests ...") command = "" if platform.system() == "Windows": if int(Options.cef_branch) >= 2704: @@ -321,16 +320,18 @@ def build_cef_projects(): run_command(command, build_cefclient) print("[automate.py] OK") # On Linux cannot pass "&&" and run two commands using run_command() - command = "ninja cefclient cefsimple" + command = "ninja cefclient cefsimple ceftests" run_command(command, build_cefclient) print("[automate.py] OK") if platform.system() == "Windows": assert(os.path.exists(os.path.join(build_cefclient, + "tests", "cefclient", Options.build_type, "cefclient.exe"))) else: assert (os.path.exists(os.path.join(build_cefclient, + "tests", "cefclient", Options.build_type, "cefclient"))) @@ -408,19 +409,51 @@ def create_prebuilt_binaries(): cpdir(os.path.join(src, Options.build_type), bindir) cpdir(os.path.join(src, "Resources"), bindir) - # Copy cefclient, cefsimple - cefclient = os.path.join(src, "build_cefclient", "cefclient", - Options.build_type, "cefclient") - cefclient_files = os.path.join(src, "build_cefclient", "cefclient", - Options.build_type, "files") - cpdir(cefclient_files, os.path.join(bindir, "files")) - cefsimple = os.path.join(src, "build_cefclient", "cefsimple", - Options.build_type, "cefsimple") + # Copy cefclient, cefsimple, ceftests + + # cefclient + cefclient = os.path.join( + src, + "build_cefclient", "tests", "cefclient", + Options.build_type, + "cefclient") + cefclient_files = os.path.join( + src, + "build_cefclient", "tests", "cefclient", + Options.build_type, + "cefclient_files") + cpdir(cefclient_files, os.path.join(bindir, "cefclient_files")) + + # cefsimple + cefsimple = os.path.join( + src, + "build_cefclient", "tests", "cefsimple", + Options.build_type, + "cefsimple") + + # ceftests + ceftests = os.path.join( + src, + "build_cefclient", "tests", "ceftests", + Options.build_type, + "ceftests") + ceftests_files = os.path.join( + src, + "build_cefclient", "tests", "ceftests", + Options.build_type, + "ceftests_files") + cpdir(ceftests_files, os.path.join(bindir, "ceftests_files")) + if platform.system() == "Windows": cefclient += ".exe" cefsimple += ".exe" + ceftests += ".exe" + shutil.copy(cefclient, bindir) shutil.copy(cefsimple, bindir) + shutil.copy(ceftests, bindir) + + # END: Copy cefclient, cefsimple, ceftests # Copy libraries if platform.system() == "Windows": diff --git a/tools/requirements.txt b/tools/requirements.txt index 397ee868..c5ba053d 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,2 +1,2 @@ -cython == 0.25.1 +cython == 0.25.2 docopt >= 0.6.2 diff --git a/unittests/main_test.py b/unittests/main_test.py index 344f0157..33fdebbc 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -52,9 +52,14 @@ print("test_function() ok"); // Test binding external object and use of javascript<>python callbacks + var start_time = new Date().getTime(); + print("[TIMER] Call Python function and then js callback that was"+ + " passed (Issue #277 test)"); external.test_callbacks(function(msg_from_python, py_callback){ if (msg_from_python == "String sent from Python") { print("test_callbacks() ok"); + var execution_time = new Date().getTime() - start_time; + print("[TIMER]: Elapsed = "+String(execution_time)+" ms"); } else { throw new Error("test_callbacks(): msg_from_python contains"+ " invalid value");