diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 3fef9a90c..127714cc8 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -420,11 +420,11 @@ typedef struct _cef_settings_t { /// Comma delimited list of schemes supported by the associated /// CefCookieManager. If |cookieable_schemes_exclude_defaults| is false (0) /// the default schemes ("http", "https", "ws" and "wss") will also be - /// supported. Specifying a |cookieable_schemes_list| value and setting + /// supported. Not specifying a |cookieable_schemes_list| value and setting /// |cookieable_schemes_exclude_defaults| to true (1) will disable all loading - /// and saving of cookies for this manager. Can be overridden - /// for individual CefRequestContext instances via the - /// CefRequestContextSettings.cookieable_schemes_list and + /// and saving of cookies. These settings will only impact the global + /// CefRequestContext. Individual CefRequestContext instances can be + /// configured via the CefRequestContextSettings.cookieable_schemes_list and /// CefRequestContextSettings.cookieable_schemes_exclude_defaults values. /// cef_string_t cookieable_schemes_list; @@ -486,10 +486,10 @@ typedef struct _cef_request_context_settings_t { /// Comma delimited list of schemes supported by the associated /// CefCookieManager. If |cookieable_schemes_exclude_defaults| is false (0) /// the default schemes ("http", "https", "ws" and "wss") will also be - /// supported. Specifying a |cookieable_schemes_list| value and setting + /// supported. Not specifying a |cookieable_schemes_list| value and setting /// |cookieable_schemes_exclude_defaults| to true (1) will disable all loading - /// and saving of cookies for this manager. These values will be ignored if - /// |cache_path| matches the CefSettings.cache_path value. + /// and saving of cookies. These values will be ignored if |cache_path| + /// matches the CefSettings.cache_path value. /// cef_string_t cookieable_schemes_list; int cookieable_schemes_exclude_defaults; diff --git a/libcef/browser/browser_context.cc b/libcef/browser/browser_context.cc index 0fcc1abe9..d1157cda9 100644 --- a/libcef/browser/browser_context.cc +++ b/libcef/browser/browser_context.cc @@ -150,6 +150,11 @@ CefBrowserContext* GetSelf(base::WeakPtr self) { CefBrowserContext::CookieableSchemes MakeSupportedSchemes( const CefString& schemes_list, bool include_defaults) { + if (schemes_list.empty() && include_defaults) { + // No explicit registration of schemes. + return absl::nullopt; + } + std::vector all_schemes; if (!schemes_list.empty()) { all_schemes = @@ -169,6 +174,12 @@ CefBrowserContext::CookieableSchemes MakeSupportedSchemes( return absl::make_optional(all_schemes); } +template +CefBrowserContext::CookieableSchemes MakeSupportedSchemes(const T& settings) { + return MakeSupportedSchemes(CefString(&settings.cookieable_schemes_list), + !settings.cookieable_schemes_exclude_defaults); +} + } // namespace CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings) @@ -191,13 +202,7 @@ void CefBrowserContext::Initialize() { g_manager.Get().SetImplPath(this, cache_path_); iothread_state_ = base::MakeRefCounted(); - - if (settings_.cookieable_schemes_list.length > 0 || - settings_.cookieable_schemes_exclude_defaults) { - cookieable_schemes_ = - MakeSupportedSchemes(CefString(&settings_.cookieable_schemes_list), - !settings_.cookieable_schemes_exclude_defaults); - } + cookieable_schemes_ = MakeSupportedSchemes(settings_); } void CefBrowserContext::Shutdown() { @@ -415,10 +420,7 @@ CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() { CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes() const { CEF_REQUIRE_UIT(); - if (cookieable_schemes_) - return cookieable_schemes_; - - return GetGlobalCookieableSchemes(); + return cookieable_schemes_; } // static @@ -427,15 +429,6 @@ CefBrowserContext::GetGlobalCookieableSchemes() { CEF_REQUIRE_UIT(); static base::NoDestructor schemes( - []() -> CookieableSchemes { - const auto& settings = CefContext::Get()->settings(); - if (settings.cookieable_schemes_list.length > 0 || - settings.cookieable_schemes_exclude_defaults) { - return MakeSupportedSchemes( - CefString(&settings.cookieable_schemes_list), - !settings.cookieable_schemes_exclude_defaults); - } - return absl::nullopt; - }()); + []() { return MakeSupportedSchemes(CefContext::Get()->settings()); }()); return *schemes; }