diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 210b03613..5cceff6af 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 6d91e32f7..eddb623c2 100644 --- a/libcef/browser/browser_context.cc +++ b/libcef/browser/browser_context.cc @@ -155,6 +155,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 = @@ -174,6 +179,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) @@ -197,13 +208,7 @@ void CefBrowserContext::Initialize() { } 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() { @@ -426,11 +431,7 @@ CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() { CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes() const { CEF_REQUIRE_UIT(); - if (cookieable_schemes_) { - return cookieable_schemes_; - } - - return GetGlobalCookieableSchemes(); + return cookieable_schemes_; } // static @@ -439,15 +440,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; }