alloy: Remove CefSettings.user_data_path (fixes #3511)

This change replaces existing CefSettings.user_data_path usage with
CefSettings.root_cache_path for better alignment with the Chrome runtime.
All files should now be written inside the root_cache_path directory.
This commit is contained in:
Marshall Greenblatt 2023-06-06 17:41:53 +03:00
parent 36a645ffd8
commit b5386249bd
11 changed files with 37 additions and 62 deletions

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for // by hand. See the translator.README.txt file in the tools directory for
// more information. // more information.
// //
// $hash=5c6e0b9e37b8103a182f200fccdf5973104fcd70$ // $hash=22cfd717df9032a01214d9abfe3e0e51949b3319$
// //
#ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_ #ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
@ -90,7 +90,7 @@ extern "C" {
/// If "AppName" is set on Windows then crash report information (metrics, /// If "AppName" is set on Windows then crash report information (metrics,
/// database and dumps) will be stored locally on disk under the /// database and dumps) will be stored locally on disk under the
/// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other /// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other
/// platforms the cef_settings_t.user_data_path value will be used. /// platforms the cef_settings_t.root_cache_path value will be used.
/// ///
/// If "ExternalHandler" is set on Windows then the specified exe will be /// If "ExternalHandler" is set on Windows then the specified exe will be
/// launched as the crashpad-handler instead of re-launching the main process /// launched as the crashpad-handler instead of re-launching the main process

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal // way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash // hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected. // values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "19ae20c25645845eb850e794d6a5720e62ca0da2" #define CEF_API_HASH_UNIVERSAL "5ee382b5a4b7a02d0285f9af00e9205e03b456d0"
#if defined(OS_WIN) #if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "c9755cb731be425f3e92c7be23908ca3c8ac26b4" #define CEF_API_HASH_PLATFORM "f4db8c7c65b7a95af22e0adf0c6b86c087d988f1"
#elif defined(OS_MAC) #elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "794acfa185a6be3edea15de4a8bbafebccc7e34c" #define CEF_API_HASH_PLATFORM "932566b79377996c56a3d97128404491f94699cf"
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "39de0cd2c1d9b526c77deb72a77bbeaa5254c309" #define CEF_API_HASH_PLATFORM "ae753fb624eec885a3dc64c815360f9bca58f17e"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -82,7 +82,7 @@
/// If "AppName" is set on Windows then crash report information (metrics, /// If "AppName" is set on Windows then crash report information (metrics,
/// database and dumps) will be stored locally on disk under the /// database and dumps) will be stored locally on disk under the
/// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other /// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other
/// platforms the cef_settings_t.user_data_path value will be used. /// platforms the cef_settings_t.root_cache_path value will be used.
/// ///
/// If "ExternalHandler" is set on Windows then the specified exe will be /// If "ExternalHandler" is set on Windows then the specified exe will be
/// launched as the crashpad-handler instead of re-launching the main process /// launched as the crashpad-handler instead of re-launching the main process

View File

@ -260,24 +260,16 @@ typedef struct _cef_settings_t {
/// The root directory that all CefSettings.cache_path and /// The root directory that all CefSettings.cache_path and
/// CefRequestContextSettings.cache_path values must have in common. If this /// CefRequestContextSettings.cache_path values must have in common. If this
/// value is empty and CefSettings.cache_path is non-empty then it will /// value is empty and CefSettings.cache_path is non-empty then it will
/// default to the CefSettings.cache_path value. If this value is non-empty /// default to the CefSettings.cache_path value. If both values are empty
/// then it must be an absolute path. Failure to set this value correctly may /// then the default platform-specific directory will be used
/// result in the sandbox blocking read/write access to the cache_path
/// directory.
///
cef_string_t root_cache_path;
///
/// The location where user data such as the Widevine CDM module and spell
/// checking dictionary files will be stored on disk. If this value is empty
/// then the default platform-specific user data directory will be used
/// ("~/.config/cef_user_data" directory on Linux, "~/Library/Application /// ("~/.config/cef_user_data" directory on Linux, "~/Library/Application
/// Support/CEF/User Data" directory on MacOS, "AppData\Local\CEF\User Data" /// Support/CEF/User Data" directory on MacOS, "AppData\Local\CEF\User Data"
/// directory under the user profile directory on Windows). If this value is /// directory under the user profile directory on Windows). If this value is
/// non-empty then it must be an absolute path. When using the Chrome runtime /// non-empty then it must be an absolute path. Failure to set this value
/// this value will be ignored in favor of the |root_cache_path| value. /// correctly may result in the sandbox blocking read/write access to certain
/// files.
/// ///
cef_string_t user_data_path; cef_string_t root_cache_path;
/// ///
/// To persist session cookies (cookies without an expiry date or validity /// To persist session cookies (cookies without an expiry date or validity

View File

@ -364,7 +364,6 @@ struct CefSettingsTraits {
cef_string_clear(&s->main_bundle_path); cef_string_clear(&s->main_bundle_path);
cef_string_clear(&s->cache_path); cef_string_clear(&s->cache_path);
cef_string_clear(&s->root_cache_path); cef_string_clear(&s->root_cache_path);
cef_string_clear(&s->user_data_path);
cef_string_clear(&s->user_agent); cef_string_clear(&s->user_agent);
cef_string_clear(&s->user_agent_product); cef_string_clear(&s->user_agent_product);
cef_string_clear(&s->locale); cef_string_clear(&s->locale);
@ -397,8 +396,6 @@ struct CefSettingsTraits {
&target->cache_path, copy); &target->cache_path, copy);
cef_string_set(src->root_cache_path.str, src->root_cache_path.length, cef_string_set(src->root_cache_path.str, src->root_cache_path.length,
&target->root_cache_path, copy); &target->root_cache_path, copy);
cef_string_set(src->user_data_path.str, src->user_data_path.length,
&target->user_data_path, copy);
target->persist_session_cookies = src->persist_session_cookies; target->persist_session_cookies = src->persist_session_cookies;
target->persist_user_preferences = src->persist_user_preferences; target->persist_user_preferences = src->persist_user_preferences;

View File

@ -32,6 +32,7 @@
#include "chrome/browser/ui/color/chrome_color_mixers.h" #include "chrome/browser/ui/color/chrome_color_mixers.h"
#include "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h" #include "chrome/browser/ui/javascript_dialogs/chrome_javascript_app_modal_dialog_view_factory.h"
#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
@ -58,6 +59,7 @@
#if BUILDFLAG(IS_WIN) #if BUILDFLAG(IS_WIN)
#include "base/enterprise_util.h" #include "base/enterprise_util.h"
#include "base/files/file_util.h"
#include "chrome/browser/chrome_browser_main_win.h" #include "chrome/browser/chrome_browser_main_win.h"
#include "chrome/browser/win/parental_controls.h" #include "chrome/browser/win/parental_controls.h"
#endif #endif
@ -82,7 +84,6 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "chrome/browser/themes/theme_service_aura_linux.h" #include "chrome/browser/themes/theme_service_aura_linux.h"
#include "chrome/browser/ui/views/theme_profile_key.h" #include "chrome/browser/ui/views/theme_profile_key.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "components/os_crypt/sync/key_storage_config_linux.h" #include "components/os_crypt/sync/key_storage_config_linux.h"
#include "libcef/browser/printing/print_dialog_linux.h" #include "libcef/browser/printing/print_dialog_linux.h"
@ -241,6 +242,10 @@ void AlloyBrowserMainParts::PostCreateMainMessageLoop() {
DCHECK(!config->user_data_path.empty()); DCHECK(!config->user_data_path.empty());
OSCrypt::SetConfig(std::move(config)); OSCrypt::SetConfig(std::move(config));
#endif // BUILDFLAG(IS_LINUX) #endif // BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_WIN)
base::SetExtraNoExecuteAllowedPath(chrome::DIR_USER_DATA);
#endif
} }
int AlloyBrowserMainParts::PreCreateThreads() { int AlloyBrowserMainParts::PreCreateThreads() {

View File

@ -300,11 +300,11 @@ void BindNetworkHintsHandler(
predictors::NetworkHintsHandlerImpl::Create(frame_host, std::move(receiver)); predictors::NetworkHintsHandlerImpl::Create(frame_host, std::move(receiver));
} }
base::FilePath GetRootCachePath() { base::FilePath GetUserDataPath() {
// The CefContext::ValidateCachePath method enforces the requirement that all base::FilePath user_data_path;
// cache_path values be either equal to or a child of root_cache_path. base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
return base::FilePath( DCHECK(!user_data_path.empty());
CefString(&CefContext::Get()->settings().root_cache_path)); return user_data_path;
} }
const extensions::Extension* GetEnabledExtensionFromSiteURL( const extensions::Extension* GetEnabledExtensionFromSiteURL(
@ -1159,19 +1159,7 @@ bool AlloyContentBrowserClient::ConfigureNetworkContextParams(
// directories that are not returned by this method. // directories that are not returned by this method.
std::vector<base::FilePath> std::vector<base::FilePath>
AlloyContentBrowserClient::GetNetworkContextsParentDirectory() { AlloyContentBrowserClient::GetNetworkContextsParentDirectory() {
base::FilePath user_data_path; return {GetUserDataPath()};
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
DCHECK(!user_data_path.empty());
const auto& root_cache_path = GetRootCachePath();
// root_cache_path may sometimes be empty or a child of user_data_path, so
// only return the one path in that case.
if (root_cache_path.empty() || user_data_path.IsParent(root_cache_path)) {
return {user_data_path};
}
return {user_data_path, root_cache_path};
} }
bool AlloyContentBrowserClient::HandleExternalProtocol( bool AlloyContentBrowserClient::HandleExternalProtocol(
@ -1282,7 +1270,7 @@ void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker(
base::FilePath base::FilePath
AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() { AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
return GetRootCachePath(); return GetUserDataPath();
} }
std::string AlloyContentBrowserClient::GetProduct() { std::string AlloyContentBrowserClient::GetProduct() {

View File

@ -16,6 +16,7 @@
#include "libcef/common/extensions/extensions_util.h" #include "libcef/common/extensions/extensions_util.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/path_service.h"
#include "chrome/browser/component_updater/chrome_component_updater_configurator.h" #include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/permissions/chrome_permissions_client.h" #include "chrome/browser/permissions/chrome_permissions_client.h"
@ -24,6 +25,7 @@
#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h" #include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/ui/prefs/pref_watcher.h" #include "chrome/browser/ui/prefs/pref_watcher.h"
#include "chrome/common/chrome_paths.h"
#include "components/component_updater/component_updater_service.h" #include "components/component_updater/component_updater_service.h"
#include "components/component_updater/timer_update_scheduler.h" #include "components/component_updater/timer_update_scheduler.h"
#include "components/net_log/chrome_net_log.h" #include "components/net_log/chrome_net_log.h"
@ -186,16 +188,15 @@ ProfileManager* ChromeBrowserProcessAlloy::profile_manager() {
PrefService* ChromeBrowserProcessAlloy::local_state() { PrefService* ChromeBrowserProcessAlloy::local_state() {
DCHECK(initialized_); DCHECK(initialized_);
if (!local_state_) { if (!local_state_) {
// Use a location that is shared by all request contexts. base::FilePath user_data_path;
const CefSettings& settings = CefContext::Get()->settings(); base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
const base::FilePath& root_cache_path = DCHECK(!user_data_path.empty());
base::FilePath(CefString(&settings.root_cache_path));
// Used for very early NetworkService initialization. // Used for very early NetworkService initialization.
// Always persist preferences for this PrefService if possible because it // Always persist preferences for this PrefService if possible because it
// contains the cookie encryption key on Windows. // contains the cookie encryption key on Windows.
local_state_ = local_state_ =
browser_prefs::CreatePrefService(nullptr /* profile */, root_cache_path, browser_prefs::CreatePrefService(nullptr /* profile */, user_data_path,
true /* persist_user_preferences */); true /* persist_user_preferences */);
} }
return local_state_.get(); return local_state_.get();

View File

@ -462,7 +462,6 @@ bool CefContext::Initialize(const CefMainArgs& args,
"browser_subprocess_path"); "browser_subprocess_path");
NormalizePathAndSet(settings_.framework_dir_path, "framework_dir_path"); NormalizePathAndSet(settings_.framework_dir_path, "framework_dir_path");
NormalizePathAndSet(settings_.main_bundle_path, "main_bundle_path"); NormalizePathAndSet(settings_.main_bundle_path, "main_bundle_path");
NormalizePathAndSet(settings_.user_data_path, "user_data_path");
NormalizePathAndSet(settings_.resources_dir_path, "resources_dir_path"); NormalizePathAndSet(settings_.resources_dir_path, "resources_dir_path");
NormalizePathAndSet(settings_.locales_dir_path, "locales_dir_path"); NormalizePathAndSet(settings_.locales_dir_path, "locales_dir_path");

View File

@ -83,18 +83,12 @@ base::FilePath GetUserDataPath(CefSettings* settings,
const base::CommandLine* command_line) { const base::CommandLine* command_line) {
// |settings| will be non-nullptr in the main process only. // |settings| will be non-nullptr in the main process only.
if (settings) { if (settings) {
// With the Chrome runtime Profile paths must always be relative to the CefString root_cache_path;
// user data directory, so defaulting to |root_cache_path| first is if (settings->root_cache_path.length > 0) {
// appropriate. root_cache_path = CefString(&settings->root_cache_path);
CefString user_data_path;
if (cef::IsChromeRuntimeEnabled() && settings->root_cache_path.length > 0) {
user_data_path = CefString(&settings->root_cache_path);
} }
if (user_data_path.empty() && settings->user_data_path.length > 0) { if (!root_cache_path.empty()) {
user_data_path = CefString(&settings->user_data_path); return base::FilePath(root_cache_path);
}
if (!user_data_path.empty()) {
return base::FilePath(user_data_path);
} }
} }

View File

@ -150,7 +150,6 @@ void CefTestSuite::GetSettings(CefSettings& settings) const {
CefString(&settings.cache_path) = root_cache_path_; CefString(&settings.cache_path) = root_cache_path_;
CefString(&settings.root_cache_path) = root_cache_path_; CefString(&settings.root_cache_path) = root_cache_path_;
CefString(&settings.user_data_path) = root_cache_path_;
// Always expose the V8 gc() function to give tests finer-grained control over // Always expose the V8 gc() function to give tests finer-grained control over
// memory management. // memory management.