Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/ApplicationSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Table of contents:
* [product_version](#product_version)
* [remote_debugging_port](#remote_debugging_port)
* [resources_dir_path](#resources_dir_path)
* [root_cache_path](#root_cache_path)
* [single_process](#single_process)
* [string_encoding](#string_encoding)
* [uncaught_exception_stack_size](#uncaught_exception_stack_size)
Expand Down Expand Up @@ -376,6 +377,27 @@ the module directory on Windows/Linux or the app bundle Resources directory
on Mac OS X. Also configurable using the --resources-dir-path switch.


### root_cache_path

(string)
The root directory for installation-specific data and the parent directory
for profile-specific data. All `cache_path` values must have this parent
directory in common. If this value is empty and `cache_path` is non-empty
then it will default to the `cache_path` value. Any non-empty value must be
an absolute path.

If both `root_cache_path` and `cache_path` are empty then a default
platform-specific directory will be used ("~/.config/cef_user_data" on
Linux, "~/Library/Application Support/CEF/User Data" on Mac, and
"AppData\Local\CEF\User Data" on Windows). Use of the default directory is
not recommended in production applications: recent CEF/Chromium versions use
a process singleton lock based on the `root_cache_path` value to guard
against multiple application instances writing to the same directory, and
relying on the default value may lead to unintended process singleton
behavior (CEF logs a warning in this case). You should customize
`root_cache_path` for your application.


### single_process

(bool)
Expand Down
1 change: 1 addition & 0 deletions src/extern/cef/cef_types.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cdef extern from "include/internal/cef_types.h":
cef_string_t browser_subprocess_path
int command_line_args_disabled
cef_string_t cache_path
cef_string_t root_cache_path
int enable_net_security_expiration
int persist_session_cookies
cef_string_t user_agent
Expand Down
4 changes: 4 additions & 0 deletions src/settings.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ cdef void SetApplicationSettings(
cefString = new CefString(&cefAppSettings.cache_path)
PyToCefStringPointer(appSettings[key], cefString)
del cefString
elif key == "root_cache_path":
cefString = new CefString(&cefAppSettings.root_cache_path)
PyToCefStringPointer(appSettings[key], cefString)
del cefString
elif key == "persist_session_cookies":
cefAppSettings.persist_session_cookies = int(appSettings[key])
elif key == "user_agent":
Expand Down
10 changes: 10 additions & 0 deletions unittests/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import platform
import sys
import tempfile
import time

# Platforms
Expand All @@ -18,6 +19,15 @@
LINUX = SYSTEM if SYSTEM == "LINUX" else False
MAC = SYSTEM if SYSTEM == "MAC" else False

# Issue #685: set ApplicationSettings.root_cache_path so that CEF does not
# log a warning about using the default user-data directory which "may lead
# to unintended process singleton behavior". A fixed directory in the
# system temp folder is reused across runs (the tests run a single instance
# at a time, so there is no singleton conflict).
ROOT_CACHE_PATH = os.path.join(tempfile.gettempdir(), "cefpython_tests")
if not os.path.isdir(ROOT_CACHE_PATH):
os.makedirs(ROOT_CACHE_PATH)

# To show the window for an extended period of time increase this number.
MESSAGE_LOOP_RANGE = 200 # each iteration is 0.01 sec

Expand Down
1 change: 1 addition & 0 deletions unittests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def test_main(self):
"debug": False,
"log_severity": cef.LOGSEVERITY_ERROR,
"log_file": "",
"root_cache_path": ROOT_CACHE_PATH,
}
if not LINUX:
# On Linux you get a lot of "X error received" messages
Expand Down
3 changes: 2 additions & 1 deletion unittests/osr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def test_osr(self):
"debug": False,
"log_severity": cef.LOGSEVERITY_ERROR,
"log_file": "",
"windowless_rendering_enabled": True
"windowless_rendering_enabled": True,
"root_cache_path": ROOT_CACHE_PATH,
}
if not LINUX:
# On Linux you get a lot of "X error received" messages
Expand Down