Skip to content

Commit 769d15c

Browse files
committed
This is CEF Python 3 version 27.2 release.
Added Browser.ParentWindowWillClose(). Fixed the Browser.CloseBrowser() behavior. Added the wx subpackage to CEF Python 3. The cefpython.g_debug variable is now propagated to the Renderer process. The same applies for the ApplicationSettings["log_file"] option.
1 parent 1f2e13f commit 769d15c

30 files changed

Lines changed: 722 additions & 49 deletions

cefpython/browser.pyx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -267,25 +267,24 @@ cdef class PyBrowser:
267267
cpdef object ClearHistory(self):
268268
self.GetCefBrowser().get().ClearHistory()
269269

270-
cpdef py_void CloseBrowser(self, py_bool forceClose=False):
271-
# In cefclient/cefclient_win.cpp there is only
272-
# ParentWindowWillClose() called. CloseBrowser() is called
273-
# only for popups.
274-
if self.GetUserData("__outerWindowHandle"):
275-
IF CEF_VERSION == 1:
276-
Debug("CefBrowser::ParentWindowWillClose()")
277-
self.GetCefBrowser().get().ParentWindowWillClose()
278-
ELIF CEF_VERSION == 3:
279-
Debug("CefBrowserHost::ParentWindowWillClose()")
280-
self.GetCefBrowserHost().get().ParentWindowWillClose()
281-
else:
282-
IF CEF_VERSION == 1:
283-
Debug("CefBrowser::CloseBrowser()")
284-
self.GetCefBrowser().get().CloseBrowser()
285-
ELIF CEF_VERSION == 3:
286-
Debug("CefBrowserHost::CloseBrowser()")
287-
self.GetCefBrowserHost().get().CloseBrowser(bool(forceClose))
270+
cpdef py_void ParentWindowWillClose(self):
271+
IF CEF_VERSION == 1:
272+
self.GetCefBrowser().get().ParentWindowWillClose()
273+
ELIF CEF_VERSION == 3:
274+
self.GetCefBrowserHost().get().ParentWindowWillClose()
288275

276+
cpdef py_void CloseBrowser(self, py_bool forceClose=False):
277+
IF CEF_VERSION == 1:
278+
Debug("CefBrowser::CloseBrowser(%s)" % forceClose)
279+
self.GetCefBrowser().get().CloseBrowser(bool(forceClose))
280+
ELIF CEF_VERSION == 3:
281+
# ParentWindowWillClose() should be called by user when
282+
# implementing LifespanHandler::DoClose().
283+
# | Debug("CefBrowser::ParentWindowWillClose()")
284+
# | self.GetCefBrowserHost().get().ParentWindowWillClose()
285+
Debug("CefBrowser::CloseBrowser(%s)" % forceClose)
286+
self.GetCefBrowserHost().get().CloseBrowser(bool(forceClose))
287+
289288
IF CEF_VERSION == 1:
290289

291290
cpdef py_void CloseDevTools(self):
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
2+
# License: New BSD License.
3+
# Website: http://code.google.com/p/cefpython/
4+
5+
cdef public void BrowserProcessHandler_OnRenderProcessThreadCreated(
6+
CefRefPtr[CefListValue] extra_info
7+
) except * with gil:
8+
global g_debug
9+
global g_applicationSettings
10+
cdef py_string logFile
11+
try:
12+
logFile = "debug.log"
13+
if "log_file" in g_applicationSettings:
14+
logFile = g_applicationSettings["log_file"]
15+
extra_info.get().SetBool(0, g_debug)
16+
extra_info.get().SetString(1, PyToCefStringValue(logFile))
17+
except:
18+
(exc_type, exc_value, exc_trace) = sys.exc_info()
19+
sys.excepthook(exc_type, exc_value, exc_trace)

cefpython/cef3/DebugLog.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
#pragma once
66
#include <stdio.h>
77

8+
extern bool g_debug;
9+
extern std::string g_logFile;
10+
811
// Defined as "inline" to get rid of the "already defined" errors
912
// when linking.
1013
inline void DebugLog(const char* szString)
1114
{
12-
// TODO: get the log_file option from CefSettings.
13-
printf("cefpython: %s\n", szString);
14-
FILE* pFile = fopen("debug.log", "a");
15-
fprintf(pFile, "cefpython_app: %s\n", szString);
16-
fclose(pFile);
15+
if (!g_debug)
16+
return;
17+
// TODO: get the log_file option from CefSettings.
18+
printf("cefpython: %s\n", szString);
19+
if (g_logFile.length()) {
20+
FILE* pFile = fopen(g_logFile.c_str(), "a");
21+
fprintf(pFile, "cefpython_app: %s\n", szString);
22+
fclose(pFile);
23+
}
1724
}

cefpython/cef3/cefpython_public_api.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// d:\cefpython\src\setup/cefpython.h(22) : warning C4190: 'RequestHandler_GetCookieManager'
22
// has C-linkage specified, but returns UDT 'CefRefPtr<T>' which is incompatible with C
3+
4+
#ifndef CEFPYTHON_PUBLIC_API_H
5+
#define CEFPYTHON_PUBLIC_API_H
6+
37
#if defined(OS_WIN)
48
#pragma warning(disable:4190)
59
#endif
@@ -31,3 +35,6 @@
3135
#if defined(OS_LINUX)
3236
#include "linux/setup/cefpython.h"
3337
#endif
38+
39+
// CEFPYTHON_PUBLIC_API_H
40+
#endif

cefpython/cef3/linux/binaries_32bit/wxpython.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ def OnExit(self):
454454

455455
if __name__ == '__main__':
456456
sys.excepthook = ExceptHook
457-
cefpython.g_debug = True
457+
cefpython.g_debug = False
458458
cefpython.g_debugFile = GetApplicationPath("debug.log")
459459
settings = {
460460
"log_severity": cefpython.LOGSEVERITY_INFO, # LOGSEVERITY_VERBOSE
461-
"log_file": GetApplicationPath("debug.log"),
461+
"log_file": GetApplicationPath("debug.log"), # Set to "" to disable.
462462
"release_dcheck_enabled": True, # Enable only when debugging.
463463
# This directories must be set on Linux
464464
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",

cefpython/cef3/linux/binaries_64bit/wxpython.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ def OnExit(self):
454454

455455
if __name__ == '__main__':
456456
sys.excepthook = ExceptHook
457-
cefpython.g_debug = True
457+
cefpython.g_debug = False
458458
cefpython.g_debugFile = GetApplicationPath("debug.log")
459459
settings = {
460460
"log_severity": cefpython.LOGSEVERITY_INFO, # LOGSEVERITY_VERBOSE
461-
"log_file": GetApplicationPath("debug.log"),
461+
"log_file": GetApplicationPath("debug.log"), # Set to "" to disable.
462462
"release_dcheck_enabled": True, # Enable only when debugging.
463463
# This directories must be set on Linux
464464
"locales_dir_path": cefpython.GetModuleDirectory()+"/locales",

cefpython/cef3/linux/installer/README.txt.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
cd examples/
1212
python wxpython.py
1313

14+
cd wx/
15+
python sample1.py
16+
python sample2.py
17+
python sample3.py
18+
1419
Note:
1520
Examples directory can also be found in the cefpython3 package directory:
1621
/usr/local/lib/python2.7/dist-packages/cefpython3/examples/

cefpython/cef3/linux/installer/create-setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def main():
8080
print("Creating examples dir in package dir")
8181
os.mkdir(package_dir+"/examples/")
8282

83-
# print("Creating wx dir in package dir")
84-
# os.mkdir(package_dir+"/wx/")
83+
print("Creating wx dir in package dir")
84+
os.mkdir(package_dir+"/wx/")
8585

8686
print("Moving example scripts from package dir to examples dir")
8787
examples = glob.glob(package_dir+"/*.py")
@@ -96,14 +96,14 @@ def main():
9696
ret = os.system("mv "+package_dir+"/*.html "+package_dir+"/examples/")
9797
assert ret == 0
9898

99-
# print("Copying wx-subpackage to wx dir in package dir")
100-
# wx_subpackage_dir = os.path.abspath(installer_dir+"/../../wx-subpackage/")
101-
# ret = os.system("cp -rf "+wx_subpackage_dir+"/* "+package_dir+"/wx/")
102-
# assert ret == 0
99+
print("Copying wx-subpackage to wx dir in package dir")
100+
wx_subpackage_dir = os.path.abspath(installer_dir+"/../../wx-subpackage/")
101+
ret = os.system("cp -rf "+wx_subpackage_dir+"/* "+package_dir+"/wx/")
102+
assert ret == 0
103103

104-
# print("Moving wx examples from wx/examples to examples/wx")
105-
# shutil.move(package_dir+"/wx/examples", package_dir+"/wx/wx/")
106-
# shutil.move(package_dir+"/wx/wx/", package_dir+"/examples/")
104+
print("Moving wx examples from wx/examples to examples/wx")
105+
shutil.move(package_dir+"/wx/examples", package_dir+"/wx/wx/")
106+
shutil.move(package_dir+"/wx/wx/", package_dir+"/examples/")
107107

108108
print("Copying package dir examples to setup dir")
109109
ret = os.system("cp -rf "+package_dir+"/examples/ "+setup_dir+"/examples/")

cefpython/cef3/linux/installer/setup.py.template

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ setup(
88
author='Czarek Tomczak',
99
author_email='czarek.tomczak@gmail.com',
1010
url='http://code.google.com/p/cefpython/',
11-
packages=['cefpython3'],
11+
packages=['cefpython3', 'cefpython3.wx'],
1212
package_data={'cefpython3': [
1313
'examples/*.py',
1414
'examples/*.html',
15-
# 'examples/wx/*.py',
16-
# 'examples/wx/*.html',
17-
# 'examples/wx/*.png',
15+
'examples/wx/*.py',
16+
'examples/wx/*.html',
17+
'examples/wx/*.png',
1818
'locales/*.pak',
19-
# 'wx/*.txt',
20-
# 'wx/images/*.png',
19+
'wx/*.txt',
20+
'wx/images/*.png',
2121
'*.txt',
2222
'cefclient',
2323
'subprocess',

cefpython/cef3/linux/setup/cefpython.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ __PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadEnd(CefRefPtr<CefBrowser>, CefR
4040
__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadError(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, enum cef_errorcode_t, CefString const &, CefString const &);
4141
__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnRendererProcessTerminated(CefRefPtr<CefBrowser>, enum cef_termination_status_t);
4242
__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnPluginCrashed(CefRefPtr<CefBrowser>, CefString const &);
43+
__PYX_EXTERN_C DL_IMPORT(void) BrowserProcessHandler_OnRenderProcessThreadCreated(CefRefPtr<CefListValue>);
4344

4445
#endif /* !__PYX_HAVE_API__cefpython_py27 */
4546

0 commit comments

Comments
 (0)