mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Move cookieable scheme configuration to settings (see issue #2969)
The Chrome runtime requires that cookieable scheme information be available at Profile initialization time because it also triggers NetworkContext creation at the same time. To make this possible, and to avoid various race conditions when setting state, the cookieable scheme configuration has been added as |cookieable_schemes_list| and |cookieable_schemes_exclude_defaults| in CefSettings and CefBrowserContextSettings. The CefCookieManager:: SetSupportedSchemes and CefBrowserProcessHandler::GetCookieableSchemes methods are no longer required and have been removed. This change also modifies chrome to delay OffTheRecordProfileImpl initialization so that |ChromeBrowserContext::profile_| can be set before ChromeContentBrowserClientCef::ConfigureNetworkContextParams calls CefBrowserContext::FromBrowserContext to retrieve the ChromeBrowserContext and associated cookieable scheme information. Otherwise, the ChromeBrowserContext will not be matched and the NetworkContext will not be configured correctly. The CookieTest suite now passes with the Chrome runtime enabled.
This commit is contained in:
@@ -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=54c5210924095c7e43173a2843bd28729645922b$
|
// $hash=ade537f836add7fe0b5fd94ceba26d678abb3e43$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||||
@@ -60,25 +60,6 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
|
||||||
// Called on the browser process UI thread to retrieve the list of schemes
|
|
||||||
// that should support cookies. If |include_defaults| is true (1) the default
|
|
||||||
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
|
|
||||||
// an NULL |schemes| value and setting |include_defaults| to false (0) will
|
|
||||||
// disable all loading and saving of cookies.
|
|
||||||
//
|
|
||||||
// This state will apply to the cef_cookie_manager_t associated with the
|
|
||||||
// global cef_request_context_t. It will also be used as the initial state for
|
|
||||||
// any new cef_request_context_ts created by the client. After creating a new
|
|
||||||
// cef_request_context_t the cef_cookie_manager_t::SetSupportedSchemes
|
|
||||||
// function may be called on the associated cef_cookie_manager_t to futher
|
|
||||||
// override these values.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* get_cookieable_schemes)(
|
|
||||||
struct _cef_browser_process_handler_t* self,
|
|
||||||
cef_string_list_t schemes,
|
|
||||||
int* include_defaults);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process UI thread immediately after the CEF context
|
// Called on the browser process UI thread immediately after the CEF context
|
||||||
// has been initialized.
|
// has been initialized.
|
||||||
|
@@ -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=20ba58ac3e861344ee738b58433869223c757e24$
|
// $hash=b19ef1c8a781f8d59276357609fe64370bb8a107$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||||
@@ -61,21 +61,6 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
|
||||||
// Set the schemes supported by this manager. If |include_defaults| is true
|
|
||||||
// (1) the default schemes ("http", "https", "ws" and "wss") will also be
|
|
||||||
// supported. Calling this function with an NULL |schemes| value and
|
|
||||||
// |include_defaults| set to false (0) will disable all loading and saving of
|
|
||||||
// cookies for this manager. If |callback| is non-NULL it will be executed
|
|
||||||
// asnychronously on the UI thread after the change has been applied. Must be
|
|
||||||
// called before any cookies are accessed.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* set_supported_schemes)(
|
|
||||||
struct _cef_cookie_manager_t* self,
|
|
||||||
cef_string_list_t schemes,
|
|
||||||
int include_defaults,
|
|
||||||
struct _cef_completion_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Visit all cookies on the UI thread. The returned cookies are ordered by
|
// Visit all cookies on the UI thread. The returned cookies are ordered by
|
||||||
// longest path, then by earliest creation date. Returns false (0) if cookies
|
// longest path, then by earliest creation date. Returns false (0) if cookies
|
||||||
|
@@ -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 "4291ac099ef9b3f618e9343acf4deb7e36bb5508"
|
#define CEF_API_HASH_UNIVERSAL "09fa2caf6574279a82c1293ab731add98d6124fd"
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "0637d7a76f9339dc446c364b3fc7c1a317b0460a"
|
#define CEF_API_HASH_PLATFORM "1cf8e3e6d8163fc9f600b919bec62dbd3687a481"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "83c4d72b1190a35bac919806c7e9b27b6a1efcf6"
|
#define CEF_API_HASH_PLATFORM "74b89a1b187e5bb5ecd4b97aa21d4abc80d3dcbe"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "f57499977f5166862b1f39ce22374b8e506b317b"
|
#define CEF_API_HASH_PLATFORM "b78332272b672f9d3db77a83af92857b226bb294"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -50,23 +50,6 @@
|
|||||||
/*--cef(source=client,no_debugct_check)--*/
|
/*--cef(source=client,no_debugct_check)--*/
|
||||||
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
||||||
public:
|
public:
|
||||||
///
|
|
||||||
// Called on the browser process UI thread to retrieve the list of schemes
|
|
||||||
// that should support cookies. If |include_defaults| is true the default
|
|
||||||
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
|
|
||||||
// an empty |schemes| value and setting |include_defaults| to false will
|
|
||||||
// disable all loading and saving of cookies.
|
|
||||||
//
|
|
||||||
// This state will apply to the CefCookieManager associated with the global
|
|
||||||
// CefRequestContext. It will also be used as the initial state for any new
|
|
||||||
// CefRequestContexts created by the client. After creating a new
|
|
||||||
// CefRequestContext the CefCookieManager::SetSupportedSchemes method may be
|
|
||||||
// called on the associated CefCookieManager to futher override these values.
|
|
||||||
///
|
|
||||||
/*--cef()--*/
|
|
||||||
virtual void GetCookieableSchemes(std::vector<CefString>& schemes,
|
|
||||||
bool& include_defaults) {}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process UI thread immediately after the CEF context
|
// Called on the browser process UI thread immediately after the CEF context
|
||||||
// has been initialized.
|
// has been initialized.
|
||||||
|
@@ -64,21 +64,6 @@ class CefCookieManager : public virtual CefBaseRefCounted {
|
|||||||
static CefRefPtr<CefCookieManager> GetGlobalManager(
|
static CefRefPtr<CefCookieManager> GetGlobalManager(
|
||||||
CefRefPtr<CefCompletionCallback> callback);
|
CefRefPtr<CefCompletionCallback> callback);
|
||||||
|
|
||||||
///
|
|
||||||
// Set the schemes supported by this manager. If |include_defaults| is true
|
|
||||||
// the default schemes ("http", "https", "ws" and "wss") will also be
|
|
||||||
// supported. Calling this method with an empty |schemes| value and
|
|
||||||
// |include_defaults| set to false will disable all loading and saving of
|
|
||||||
// cookies for this manager. If |callback| is non-NULL it will be executed
|
|
||||||
// asnychronously on the UI thread after the change has been applied. Must be
|
|
||||||
// called before any cookies are accessed.
|
|
||||||
///
|
|
||||||
/*--cef(optional_param=callback)--*/
|
|
||||||
virtual void SetSupportedSchemes(
|
|
||||||
const std::vector<CefString>& schemes,
|
|
||||||
bool include_defaults,
|
|
||||||
CefRefPtr<CefCompletionCallback> callback) = 0;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Visit all cookies on the UI thread. The returned cookies are ordered by
|
// Visit all cookies on the UI thread. The returned cookies are ordered by
|
||||||
// longest path, then by earliest creation date. Returns false if cookies
|
// longest path, then by earliest creation date. Returns false if cookies
|
||||||
|
@@ -422,6 +422,20 @@ typedef struct _cef_settings_t {
|
|||||||
///
|
///
|
||||||
cef_string_t accept_language_list;
|
cef_string_t accept_language_list;
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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
|
||||||
|
// |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
|
||||||
|
// CefRequestContextSettings.cookieable_schemes_exclude_defaults values.
|
||||||
|
///
|
||||||
|
cef_string_t cookieable_schemes_list;
|
||||||
|
int cookieable_schemes_exclude_defaults;
|
||||||
|
|
||||||
///
|
///
|
||||||
// GUID string used for identifying the application. This is passed to the
|
// GUID string used for identifying the application. This is passed to the
|
||||||
// system AV function for scanning downloaded files. By default, the GUID
|
// system AV function for scanning downloaded files. By default, the GUID
|
||||||
@@ -490,6 +504,18 @@ typedef struct _cef_request_context_settings_t {
|
|||||||
// ignored if |cache_path| matches the CefSettings.cache_path value.
|
// ignored if |cache_path| matches the CefSettings.cache_path value.
|
||||||
///
|
///
|
||||||
cef_string_t accept_language_list;
|
cef_string_t accept_language_list;
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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
|
||||||
|
// |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.
|
||||||
|
///
|
||||||
|
cef_string_t cookieable_schemes_list;
|
||||||
|
int cookieable_schemes_exclude_defaults;
|
||||||
} cef_request_context_settings_t;
|
} cef_request_context_settings_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -654,7 +680,7 @@ typedef struct _cef_browser_settings_t {
|
|||||||
///
|
///
|
||||||
// Comma delimited ordered list of language codes without any whitespace that
|
// Comma delimited ordered list of language codes without any whitespace that
|
||||||
// will be used in the "Accept-Language" HTTP header. May be set globally
|
// will be used in the "Accept-Language" HTTP header. May be set globally
|
||||||
// using the CefBrowserSettings.accept_language_list value. If both values are
|
// using the CefSettings.accept_language_list value. If both values are
|
||||||
// empty then "en-US,en" will be used.
|
// empty then "en-US,en" will be used.
|
||||||
///
|
///
|
||||||
cef_string_t accept_language_list;
|
cef_string_t accept_language_list;
|
||||||
|
@@ -555,6 +555,7 @@ struct CefSettingsTraits {
|
|||||||
cef_string_clear(&s->resources_dir_path);
|
cef_string_clear(&s->resources_dir_path);
|
||||||
cef_string_clear(&s->locales_dir_path);
|
cef_string_clear(&s->locales_dir_path);
|
||||||
cef_string_clear(&s->accept_language_list);
|
cef_string_clear(&s->accept_language_list);
|
||||||
|
cef_string_clear(&s->cookieable_schemes_list);
|
||||||
cef_string_clear(&s->application_client_id_for_file_scanning);
|
cef_string_clear(&s->application_client_id_for_file_scanning);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,6 +610,13 @@ struct CefSettingsTraits {
|
|||||||
cef_string_set(src->accept_language_list.str,
|
cef_string_set(src->accept_language_list.str,
|
||||||
src->accept_language_list.length,
|
src->accept_language_list.length,
|
||||||
&target->accept_language_list, copy);
|
&target->accept_language_list, copy);
|
||||||
|
|
||||||
|
cef_string_set(src->cookieable_schemes_list.str,
|
||||||
|
src->cookieable_schemes_list.length,
|
||||||
|
&target->cookieable_schemes_list, copy);
|
||||||
|
target->cookieable_schemes_exclude_defaults =
|
||||||
|
src->cookieable_schemes_exclude_defaults;
|
||||||
|
|
||||||
cef_string_set(src->application_client_id_for_file_scanning.str,
|
cef_string_set(src->application_client_id_for_file_scanning.str,
|
||||||
src->application_client_id_for_file_scanning.length,
|
src->application_client_id_for_file_scanning.length,
|
||||||
&target->application_client_id_for_file_scanning, copy);
|
&target->application_client_id_for_file_scanning, copy);
|
||||||
@@ -628,6 +636,7 @@ struct CefRequestContextSettingsTraits {
|
|||||||
static inline void clear(struct_type* s) {
|
static inline void clear(struct_type* s) {
|
||||||
cef_string_clear(&s->cache_path);
|
cef_string_clear(&s->cache_path);
|
||||||
cef_string_clear(&s->accept_language_list);
|
cef_string_clear(&s->accept_language_list);
|
||||||
|
cef_string_clear(&s->cookieable_schemes_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set(const struct_type* src,
|
static inline void set(const struct_type* src,
|
||||||
@@ -641,6 +650,12 @@ struct CefRequestContextSettingsTraits {
|
|||||||
cef_string_set(src->accept_language_list.str,
|
cef_string_set(src->accept_language_list.str,
|
||||||
src->accept_language_list.length,
|
src->accept_language_list.length,
|
||||||
&target->accept_language_list, copy);
|
&target->accept_language_list, copy);
|
||||||
|
|
||||||
|
cef_string_set(src->cookieable_schemes_list.str,
|
||||||
|
src->cookieable_schemes_list.length,
|
||||||
|
&target->cookieable_schemes_list, copy);
|
||||||
|
target->cookieable_schemes_exclude_defaults =
|
||||||
|
src->cookieable_schemes_exclude_defaults;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/media_router/media_router_manager.h"
|
#include "libcef/browser/media_router/media_router_manager.h"
|
||||||
#include "libcef/browser/request_context_impl.h"
|
#include "libcef/browser/request_context_impl.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
@@ -16,6 +17,8 @@
|
|||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/no_destructor.h"
|
||||||
|
#include "base/strings/string_split.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
@@ -142,6 +145,28 @@ CefBrowserContext* GetSelf(base::WeakPtr<CefBrowserContext> self) {
|
|||||||
return self.get();
|
return self.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefBrowserContext::CookieableSchemes MakeSupportedSchemes(
|
||||||
|
const CefString& schemes_list,
|
||||||
|
bool include_defaults) {
|
||||||
|
std::vector<std::string> all_schemes;
|
||||||
|
if (!schemes_list.empty()) {
|
||||||
|
all_schemes =
|
||||||
|
base::SplitString(schemes_list.ToString(), std::string(","),
|
||||||
|
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (include_defaults) {
|
||||||
|
// Add default schemes that should always support cookies.
|
||||||
|
// This list should match CookieMonster::kDefaultCookieableSchemes.
|
||||||
|
all_schemes.push_back("http");
|
||||||
|
all_schemes.push_back("https");
|
||||||
|
all_schemes.push_back("ws");
|
||||||
|
all_schemes.push_back("wss");
|
||||||
|
}
|
||||||
|
|
||||||
|
return base::make_optional(all_schemes);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
|
CefBrowserContext::CefBrowserContext(const CefRequestContextSettings& settings)
|
||||||
@@ -164,6 +189,13 @@ void CefBrowserContext::Initialize() {
|
|||||||
g_manager.Get().SetImplPath(this, cache_path_);
|
g_manager.Get().SetImplPath(this, cache_path_);
|
||||||
|
|
||||||
iothread_state_ = base::MakeRefCounted<CefIOThreadState>();
|
iothread_state_ = base::MakeRefCounted<CefIOThreadState>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserContext::Shutdown() {
|
void CefBrowserContext::Shutdown() {
|
||||||
@@ -468,5 +500,24 @@ CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()
|
|||||||
if (cookieable_schemes_)
|
if (cookieable_schemes_)
|
||||||
return cookieable_schemes_;
|
return cookieable_schemes_;
|
||||||
|
|
||||||
return CefCookieManagerImpl::GetGlobalCookieableSchemes();
|
return GetGlobalCookieableSchemes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefBrowserContext::CookieableSchemes
|
||||||
|
CefBrowserContext::GetGlobalCookieableSchemes() {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
static base::NoDestructor<CookieableSchemes> 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 base::nullopt;
|
||||||
|
}());
|
||||||
|
return *schemes;
|
||||||
}
|
}
|
||||||
|
@@ -198,11 +198,7 @@ class CefBrowserContext {
|
|||||||
// Returns the schemes associated with this context specifically, or the
|
// Returns the schemes associated with this context specifically, or the
|
||||||
// global configuration if unset.
|
// global configuration if unset.
|
||||||
CookieableSchemes GetCookieableSchemes() const;
|
CookieableSchemes GetCookieableSchemes() const;
|
||||||
|
static CookieableSchemes GetGlobalCookieableSchemes();
|
||||||
// Set the schemes associated with this context specifically.
|
|
||||||
void set_cookieable_schemes(const CookieableSchemes& schemes) {
|
|
||||||
cookieable_schemes_ = schemes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These accessors are safe to call from any thread because the values don't
|
// These accessors are safe to call from any thread because the values don't
|
||||||
// change during this object's lifespan.
|
// change during this object's lifespan.
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "libcef/browser/prefs/browser_prefs.h"
|
#include "libcef/browser/prefs/browser_prefs.h"
|
||||||
|
|
||||||
#include "chrome/browser/browser_process.h"
|
#include "chrome/browser/browser_process.h"
|
||||||
|
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
|
||||||
|
|
||||||
ChromeBrowserContext::ChromeBrowserContext(
|
ChromeBrowserContext::ChromeBrowserContext(
|
||||||
const CefRequestContextSettings& settings)
|
const CefRequestContextSettings& settings)
|
||||||
@@ -33,8 +34,9 @@ void ChromeBrowserContext::InitializeAsync(base::OnceClosure initialized_cb) {
|
|||||||
|
|
||||||
if (cache_path_ == user_data_dir) {
|
if (cache_path_ == user_data_dir) {
|
||||||
// Use the default disk-based profile.
|
// Use the default disk-based profile.
|
||||||
ProfileCreated(profile_manager->GetActiveUserProfile(),
|
auto profile = profile_manager->GetActiveUserProfile();
|
||||||
Profile::CreateStatus::CREATE_STATUS_INITIALIZED);
|
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_CREATED);
|
||||||
|
ProfileCreated(profile, Profile::CreateStatus::CREATE_STATUS_INITIALIZED);
|
||||||
return;
|
return;
|
||||||
} else if (cache_path_.DirName() == user_data_dir) {
|
} else if (cache_path_.DirName() == user_data_dir) {
|
||||||
// Create or load a specific disk-based profile. May continue
|
// Create or load a specific disk-based profile. May continue
|
||||||
@@ -69,26 +71,41 @@ void ChromeBrowserContext::Shutdown() {
|
|||||||
|
|
||||||
void ChromeBrowserContext::ProfileCreated(Profile* profile,
|
void ChromeBrowserContext::ProfileCreated(Profile* profile,
|
||||||
Profile::CreateStatus status) {
|
Profile::CreateStatus status) {
|
||||||
|
Profile* parent_profile = nullptr;
|
||||||
|
OffTheRecordProfileImpl* otr_profile = nullptr;
|
||||||
|
|
||||||
if (status != Profile::CreateStatus::CREATE_STATUS_CREATED &&
|
if (status != Profile::CreateStatus::CREATE_STATUS_CREATED &&
|
||||||
status != Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
|
status != Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
|
||||||
DCHECK(!profile);
|
DCHECK(!profile);
|
||||||
|
DCHECK(!profile_);
|
||||||
|
|
||||||
// Creation of a disk-based profile failed for some reason. Create a
|
// Creation of a disk-based profile failed for some reason. Create a
|
||||||
// new/unique OffTheRecord profile instead.
|
// new/unique OffTheRecord profile instead.
|
||||||
const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF();
|
const auto& profile_id = Profile::OTRProfileID::CreateUniqueForCEF();
|
||||||
profile = g_browser_process->profile_manager()
|
parent_profile =
|
||||||
->GetActiveUserProfile()
|
g_browser_process->profile_manager()->GetActiveUserProfile();
|
||||||
->GetOffTheRecordProfile(profile_id);
|
profile_ = parent_profile->GetOffTheRecordProfile(profile_id);
|
||||||
|
otr_profile = static_cast<OffTheRecordProfileImpl*>(profile_);
|
||||||
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;
|
status = Profile::CreateStatus::CREATE_STATUS_INITIALIZED;
|
||||||
should_destroy_ = true;
|
should_destroy_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
|
if (status == Profile::CreateStatus::CREATE_STATUS_CREATED) {
|
||||||
DCHECK(profile);
|
DCHECK(profile);
|
||||||
DCHECK(!profile_);
|
DCHECK(!profile_);
|
||||||
profile_ = profile;
|
profile_ = profile;
|
||||||
|
} else if (status == Profile::CreateStatus::CREATE_STATUS_INITIALIZED) {
|
||||||
|
DCHECK(profile_);
|
||||||
browser_prefs::SetLanguagePrefs(profile_);
|
browser_prefs::SetLanguagePrefs(profile_);
|
||||||
|
|
||||||
|
// Must set |profile_| before Init() calls
|
||||||
|
// ChromeContentBrowserClientCef::ConfigureNetworkContextParams so that
|
||||||
|
// CefBrowserContext::FromBrowserContext can find us.
|
||||||
|
if (otr_profile) {
|
||||||
|
otr_profile->Init();
|
||||||
|
parent_profile->NotifyOffTheRecordProfileCreated(otr_profile);
|
||||||
|
}
|
||||||
|
|
||||||
std::move(initialized_cb_).Run();
|
std::move(initialized_cb_).Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -258,7 +258,7 @@ void ChromeContentBrowserClientCef::ConfigureNetworkContextParams(
|
|||||||
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
||||||
network_context_params->cookieable_schemes =
|
network_context_params->cookieable_schemes =
|
||||||
cef_context ? cef_context->GetCookieableSchemes()
|
cef_context ? cef_context->GetCookieableSchemes()
|
||||||
: CefCookieManagerImpl::GetGlobalCookieableSchemes();
|
: CefBrowserContext::GetGlobalCookieableSchemes();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<content::LoginDelegate>
|
std::unique_ptr<content::LoginDelegate>
|
||||||
|
@@ -436,6 +436,11 @@ void CefContext::PopulateGlobalRequestContextSettings(
|
|||||||
command_line->HasSwitch(switches::kIgnoreCertificateErrors);
|
command_line->HasSwitch(switches::kIgnoreCertificateErrors);
|
||||||
CefString(&settings->accept_language_list) =
|
CefString(&settings->accept_language_list) =
|
||||||
CefString(&settings_.accept_language_list);
|
CefString(&settings_.accept_language_list);
|
||||||
|
|
||||||
|
CefString(&settings->cookieable_schemes_list) =
|
||||||
|
CefString(&settings_.cookieable_schemes_list);
|
||||||
|
settings->cookieable_schemes_exclude_defaults =
|
||||||
|
settings_.cookieable_schemes_exclude_defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefContext::NormalizeRequestContextSettings(
|
void CefContext::NormalizeRequestContextSettings(
|
||||||
|
@@ -4,13 +4,11 @@
|
|||||||
|
|
||||||
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
||||||
|
|
||||||
#include "libcef/common/app_manager.h"
|
|
||||||
#include "libcef/common/net_service/net_service_util.h"
|
#include "libcef/common/net_service/net_service_util.h"
|
||||||
#include "libcef/common/time_util.h"
|
#include "libcef/common/time_util.h"
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/no_destructor.h"
|
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/storage_partition.h"
|
#include "content/public/browser/storage_partition.h"
|
||||||
#include "services/network/public/mojom/cookie_manager.mojom.h"
|
#include "services/network/public/mojom/cookie_manager.mojom.h"
|
||||||
@@ -117,25 +115,6 @@ void GetCookiesCallbackImpl(
|
|||||||
GetAllCookiesCallbackImpl(visitor, browser_context_getter, cookies);
|
GetAllCookiesCallbackImpl(visitor, browser_context_getter, cookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
CefCookieManagerImpl::CookieableSchemes MakeSupportedSchemes(
|
|
||||||
const std::vector<CefString>& schemes,
|
|
||||||
bool include_defaults) {
|
|
||||||
std::vector<std::string> all_schemes;
|
|
||||||
for (const auto& scheme : schemes)
|
|
||||||
all_schemes.push_back(scheme);
|
|
||||||
|
|
||||||
if (include_defaults) {
|
|
||||||
// Add default schemes that should always support cookies.
|
|
||||||
// This list should match CookieMonster::kDefaultCookieableSchemes.
|
|
||||||
all_schemes.push_back("http");
|
|
||||||
all_schemes.push_back("https");
|
|
||||||
all_schemes.push_back("ws");
|
|
||||||
all_schemes.push_back("wss");
|
|
||||||
}
|
|
||||||
|
|
||||||
return base::make_optional(all_schemes);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefCookieManagerImpl::CefCookieManagerImpl() {}
|
CefCookieManagerImpl::CefCookieManagerImpl() {}
|
||||||
@@ -150,29 +129,6 @@ void CefCookieManagerImpl::Initialize(
|
|||||||
RunAsyncCompletionOnUIThread(callback);
|
RunAsyncCompletionOnUIThread(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefCookieManagerImpl::SetSupportedSchemes(
|
|
||||||
const std::vector<CefString>& schemes,
|
|
||||||
bool include_defaults,
|
|
||||||
CefRefPtr<CefCompletionCallback> callback) {
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT,
|
|
||||||
base::Bind(&CefCookieManagerImpl::SetSupportedSchemes, this,
|
|
||||||
schemes, include_defaults, callback));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
|
||||||
if (!browser_context)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// This will be forwarded to the CookieMonster that lives in the
|
|
||||||
// NetworkService process when the NetworkContext is created via
|
|
||||||
// AlloyContentBrowserClient::CreateNetworkContext.
|
|
||||||
browser_context->set_cookieable_schemes(
|
|
||||||
MakeSupportedSchemes(schemes, include_defaults));
|
|
||||||
RunAsyncCompletionOnUIThread(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefCookieManagerImpl::VisitAllCookies(
|
bool CefCookieManagerImpl::VisitAllCookies(
|
||||||
CefRefPtr<CefCookieVisitor> visitor) {
|
CefRefPtr<CefCookieVisitor> visitor) {
|
||||||
if (!visitor.get())
|
if (!visitor.get())
|
||||||
@@ -352,26 +308,6 @@ bool CefCookieManagerImpl::FlushStore(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
CefCookieManagerImpl::CookieableSchemes
|
|
||||||
CefCookieManagerImpl::GetGlobalCookieableSchemes() {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
|
|
||||||
static base::NoDestructor<CookieableSchemes> schemes(
|
|
||||||
[]() -> CefCookieManagerImpl::CookieableSchemes {
|
|
||||||
if (auto application = CefAppManager::Get()->GetApplication()) {
|
|
||||||
if (auto handler = application->GetBrowserProcessHandler()) {
|
|
||||||
std::vector<CefString> schemes;
|
|
||||||
bool include_defaults = true;
|
|
||||||
handler->GetCookieableSchemes(schemes, include_defaults);
|
|
||||||
return MakeSupportedSchemes(schemes, include_defaults);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return base::nullopt;
|
|
||||||
}());
|
|
||||||
return *schemes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CefCookieManager methods ----------------------------------------------------
|
// CefCookieManager methods ----------------------------------------------------
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@@ -23,9 +23,6 @@ class CefCookieManagerImpl : public CefCookieManager {
|
|||||||
CefRefPtr<CefCompletionCallback> callback);
|
CefRefPtr<CefCompletionCallback> callback);
|
||||||
|
|
||||||
// CefCookieManager methods.
|
// CefCookieManager methods.
|
||||||
void SetSupportedSchemes(const std::vector<CefString>& schemes,
|
|
||||||
bool include_defaults,
|
|
||||||
CefRefPtr<CefCompletionCallback> callback) override;
|
|
||||||
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) override;
|
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) override;
|
||||||
bool VisitUrlCookies(const CefString& url,
|
bool VisitUrlCookies(const CefString& url,
|
||||||
bool includeHttpOnly,
|
bool includeHttpOnly,
|
||||||
@@ -38,9 +35,6 @@ class CefCookieManagerImpl : public CefCookieManager {
|
|||||||
CefRefPtr<CefDeleteCookiesCallback> callback) override;
|
CefRefPtr<CefDeleteCookiesCallback> callback) override;
|
||||||
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
|
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
|
||||||
|
|
||||||
using CookieableSchemes = base::Optional<std::vector<std::string>>;
|
|
||||||
static CookieableSchemes GetGlobalCookieableSchemes();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Only accessed on the UI thread. Will be non-null after Initialize().
|
// Only accessed on the UI thread. Will be non-null after Initialize().
|
||||||
CefBrowserContext::Getter browser_context_getter_;
|
CefBrowserContext::Getter browser_context_getter_;
|
||||||
|
@@ -9,55 +9,17 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=deb93b82f75f2e3f59cccf3a82ce8e47b400f5c1$
|
// $hash=160f499a80898e5b6934960c4f41764c0610458e$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
||||||
#include "libcef_dll/transfer_util.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
void CEF_CALLBACK browser_process_handler_get_cookieable_schemes(
|
|
||||||
struct _cef_browser_process_handler_t* self,
|
|
||||||
cef_string_list_t schemes,
|
|
||||||
int* include_defaults) {
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
DCHECK(self);
|
|
||||||
if (!self)
|
|
||||||
return;
|
|
||||||
// Verify param: schemes; type: string_vec_byref
|
|
||||||
DCHECK(schemes);
|
|
||||||
if (!schemes)
|
|
||||||
return;
|
|
||||||
// Verify param: include_defaults; type: bool_byref
|
|
||||||
DCHECK(include_defaults);
|
|
||||||
if (!include_defaults)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Translate param: schemes; type: string_vec_byref
|
|
||||||
std::vector<CefString> schemesList;
|
|
||||||
transfer_string_list_contents(schemes, schemesList);
|
|
||||||
// Translate param: include_defaults; type: bool_byref
|
|
||||||
bool include_defaultsBool =
|
|
||||||
(include_defaults && *include_defaults) ? true : false;
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
CefBrowserProcessHandlerCppToC::Get(self)->GetCookieableSchemes(
|
|
||||||
schemesList, include_defaultsBool);
|
|
||||||
|
|
||||||
// Restore param: schemes; type: string_vec_byref
|
|
||||||
cef_string_list_clear(schemes);
|
|
||||||
transfer_string_list_contents(schemesList, schemes);
|
|
||||||
// Restore param: include_defaults; type: bool_byref
|
|
||||||
if (include_defaults)
|
|
||||||
*include_defaults = include_defaultsBool ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CEF_CALLBACK browser_process_handler_on_context_initialized(
|
void CEF_CALLBACK browser_process_handler_on_context_initialized(
|
||||||
struct _cef_browser_process_handler_t* self) {
|
struct _cef_browser_process_handler_t* self) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
@@ -123,8 +85,6 @@ struct _cef_client_t* CEF_CALLBACK browser_process_handler_get_default_client(
|
|||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() {
|
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() {
|
||||||
GetStruct()->get_cookieable_schemes =
|
|
||||||
browser_process_handler_get_cookieable_schemes;
|
|
||||||
GetStruct()->on_context_initialized =
|
GetStruct()->on_context_initialized =
|
||||||
browser_process_handler_on_context_initialized;
|
browser_process_handler_on_context_initialized;
|
||||||
GetStruct()->on_before_child_process_launch =
|
GetStruct()->on_before_child_process_launch =
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=5136747d18b12c6b1d50f74d7f74dbad147c4401$
|
// $hash=0307287ed355556f7c6dab1e4a4fd188ce11d919$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
|
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/set_cookie_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/set_cookie_callback_ctocpp.h"
|
||||||
#include "libcef_dll/transfer_util.h"
|
|
||||||
|
|
||||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
@@ -39,32 +38,6 @@ namespace {
|
|||||||
|
|
||||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
void CEF_CALLBACK
|
|
||||||
cookie_manager_set_supported_schemes(struct _cef_cookie_manager_t* self,
|
|
||||||
cef_string_list_t schemes,
|
|
||||||
int include_defaults,
|
|
||||||
cef_completion_callback_t* callback) {
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
DCHECK(self);
|
|
||||||
if (!self)
|
|
||||||
return;
|
|
||||||
// Verify param: schemes; type: string_vec_byref_const
|
|
||||||
DCHECK(schemes);
|
|
||||||
if (!schemes)
|
|
||||||
return;
|
|
||||||
// Unverified params: callback
|
|
||||||
|
|
||||||
// Translate param: schemes; type: string_vec_byref_const
|
|
||||||
std::vector<CefString> schemesList;
|
|
||||||
transfer_string_list_contents(schemes, schemesList);
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
CefCookieManagerCppToC::Get(self)->SetSupportedSchemes(
|
|
||||||
schemesList, include_defaults ? true : false,
|
|
||||||
CefCompletionCallbackCToCpp::Wrap(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
int CEF_CALLBACK
|
int CEF_CALLBACK
|
||||||
cookie_manager_visit_all_cookies(struct _cef_cookie_manager_t* self,
|
cookie_manager_visit_all_cookies(struct _cef_cookie_manager_t* self,
|
||||||
struct _cef_cookie_visitor_t* visitor) {
|
struct _cef_cookie_visitor_t* visitor) {
|
||||||
@@ -191,7 +164,6 @@ cookie_manager_flush_store(struct _cef_cookie_manager_t* self,
|
|||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
CefCookieManagerCppToC::CefCookieManagerCppToC() {
|
CefCookieManagerCppToC::CefCookieManagerCppToC() {
|
||||||
GetStruct()->set_supported_schemes = cookie_manager_set_supported_schemes;
|
|
||||||
GetStruct()->visit_all_cookies = cookie_manager_visit_all_cookies;
|
GetStruct()->visit_all_cookies = cookie_manager_visit_all_cookies;
|
||||||
GetStruct()->visit_url_cookies = cookie_manager_visit_url_cookies;
|
GetStruct()->visit_url_cookies = cookie_manager_visit_url_cookies;
|
||||||
GetStruct()->set_cookie = cookie_manager_set_cookie;
|
GetStruct()->set_cookie = cookie_manager_set_cookie;
|
||||||
|
@@ -9,47 +9,15 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=f70d18a15f7c01ce5171d781577312fa7d2fb93b$
|
// $hash=5efe4243d536139501e58591c6f875e08001c8b7$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||||
#include "libcef_dll/transfer_util.h"
|
|
||||||
|
|
||||||
// VIRTUAL METHODS - Body may be edited by hand.
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
NO_SANITIZE("cfi-icall")
|
|
||||||
void CefBrowserProcessHandlerCToCpp::GetCookieableSchemes(
|
|
||||||
std::vector<CefString>& schemes,
|
|
||||||
bool& include_defaults) {
|
|
||||||
cef_browser_process_handler_t* _struct = GetStruct();
|
|
||||||
if (CEF_MEMBER_MISSING(_struct, get_cookieable_schemes))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
// Translate param: schemes; type: string_vec_byref
|
|
||||||
cef_string_list_t schemesList = cef_string_list_alloc();
|
|
||||||
DCHECK(schemesList);
|
|
||||||
if (schemesList)
|
|
||||||
transfer_string_list_contents(schemes, schemesList);
|
|
||||||
// Translate param: include_defaults; type: bool_byref
|
|
||||||
int include_defaultsInt = include_defaults;
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
_struct->get_cookieable_schemes(_struct, schemesList, &include_defaultsInt);
|
|
||||||
|
|
||||||
// Restore param:schemes; type: string_vec_byref
|
|
||||||
if (schemesList) {
|
|
||||||
schemes.clear();
|
|
||||||
transfer_string_list_contents(schemesList, schemes);
|
|
||||||
cef_string_list_free(schemesList);
|
|
||||||
}
|
|
||||||
// Restore param:include_defaults; type: bool_byref
|
|
||||||
include_defaults = include_defaultsInt ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NO_SANITIZE("cfi-icall")
|
NO_SANITIZE("cfi-icall")
|
||||||
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
|
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
|
||||||
cef_browser_process_handler_t* _struct = GetStruct();
|
cef_browser_process_handler_t* _struct = GetStruct();
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=e6881fab8b5f8b46c08f0b472abdc8508edaed52$
|
// $hash=719a890627d0b2ba0746415c0dd8631e387567fe$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
#error This file can be included DLL-side only
|
#error This file can be included DLL-side only
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "include/capi/cef_browser_process_handler_capi.h"
|
#include "include/capi/cef_browser_process_handler_capi.h"
|
||||||
#include "include/cef_browser_process_handler.h"
|
#include "include/cef_browser_process_handler.h"
|
||||||
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
||||||
@@ -36,8 +35,6 @@ class CefBrowserProcessHandlerCToCpp
|
|||||||
virtual ~CefBrowserProcessHandlerCToCpp();
|
virtual ~CefBrowserProcessHandlerCToCpp();
|
||||||
|
|
||||||
// CefBrowserProcessHandler methods.
|
// CefBrowserProcessHandler methods.
|
||||||
void GetCookieableSchemes(std::vector<CefString>& schemes,
|
|
||||||
bool& include_defaults) override;
|
|
||||||
void OnContextInitialized() override;
|
void OnContextInitialized() override;
|
||||||
void OnBeforeChildProcessLaunch(
|
void OnBeforeChildProcessLaunch(
|
||||||
CefRefPtr<CefCommandLine> command_line) override;
|
CefRefPtr<CefCommandLine> command_line) override;
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=ca2d5effc1d414cebf46e33d1282a8e6d04bc317$
|
// $hash=2682019770bd002410e9e292747e861c907d3c0c$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
#include "libcef_dll/cpptoc/cookie_visitor_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/set_cookie_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/set_cookie_callback_cpptoc.h"
|
||||||
#include "libcef_dll/transfer_util.h"
|
|
||||||
|
|
||||||
// STATIC METHODS - Body may be edited by hand.
|
// STATIC METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
@@ -38,34 +37,6 @@ CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager(
|
|||||||
|
|
||||||
// VIRTUAL METHODS - Body may be edited by hand.
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
NO_SANITIZE("cfi-icall")
|
|
||||||
void CefCookieManagerCToCpp::SetSupportedSchemes(
|
|
||||||
const std::vector<CefString>& schemes,
|
|
||||||
bool include_defaults,
|
|
||||||
CefRefPtr<CefCompletionCallback> callback) {
|
|
||||||
cef_cookie_manager_t* _struct = GetStruct();
|
|
||||||
if (CEF_MEMBER_MISSING(_struct, set_supported_schemes))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
|
||||||
|
|
||||||
// Unverified params: callback
|
|
||||||
|
|
||||||
// Translate param: schemes; type: string_vec_byref_const
|
|
||||||
cef_string_list_t schemesList = cef_string_list_alloc();
|
|
||||||
DCHECK(schemesList);
|
|
||||||
if (schemesList)
|
|
||||||
transfer_string_list_contents(schemes, schemesList);
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
_struct->set_supported_schemes(_struct, schemesList, include_defaults,
|
|
||||||
CefCompletionCallbackCppToC::Wrap(callback));
|
|
||||||
|
|
||||||
// Restore param:schemes; type: string_vec_byref_const
|
|
||||||
if (schemesList)
|
|
||||||
cef_string_list_free(schemesList);
|
|
||||||
}
|
|
||||||
|
|
||||||
NO_SANITIZE("cfi-icall")
|
NO_SANITIZE("cfi-icall")
|
||||||
bool CefCookieManagerCToCpp::VisitAllCookies(
|
bool CefCookieManagerCToCpp::VisitAllCookies(
|
||||||
CefRefPtr<CefCookieVisitor> visitor) {
|
CefRefPtr<CefCookieVisitor> visitor) {
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=f90075499dbca71125c6ec1746fd2d3168699ee1$
|
// $hash=86450b60ca929d794339574809c956ab0fec709e$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_COOKIE_MANAGER_CTOCPP_H_
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
#error This file can be included wrapper-side only
|
#error This file can be included wrapper-side only
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "include/capi/cef_cookie_capi.h"
|
#include "include/capi/cef_cookie_capi.h"
|
||||||
#include "include/cef_cookie.h"
|
#include "include/cef_cookie.h"
|
||||||
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
||||||
@@ -36,9 +35,6 @@ class CefCookieManagerCToCpp
|
|||||||
virtual ~CefCookieManagerCToCpp();
|
virtual ~CefCookieManagerCToCpp();
|
||||||
|
|
||||||
// CefCookieManager methods.
|
// CefCookieManager methods.
|
||||||
void SetSupportedSchemes(const std::vector<CefString>& schemes,
|
|
||||||
bool include_defaults,
|
|
||||||
CefRefPtr<CefCompletionCallback> callback) OVERRIDE;
|
|
||||||
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) OVERRIDE;
|
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) OVERRIDE;
|
||||||
bool VisitUrlCookies(const CefString& url,
|
bool VisitUrlCookies(const CefString& url,
|
||||||
bool includeHttpOnly,
|
bool includeHttpOnly,
|
||||||
|
@@ -239,6 +239,7 @@ patches = [
|
|||||||
# https://bitbucket.org/chromiumembedded/cef/issues/1917
|
# https://bitbucket.org/chromiumembedded/cef/issues/1917
|
||||||
#
|
#
|
||||||
# chrome: Support CEF incognito Profiles that allow Browser creation.
|
# chrome: Support CEF incognito Profiles that allow Browser creation.
|
||||||
|
# chrome: Allow CEF to delay OffTheRecordProfileImpl initialization.
|
||||||
# https://bitbucket.org/chromiumembedded/cef/issues/2969
|
# https://bitbucket.org/chromiumembedded/cef/issues/2969
|
||||||
'name': 'chrome_browser_profiles',
|
'name': 'chrome_browser_profiles',
|
||||||
},
|
},
|
||||||
|
@@ -1,5 +1,20 @@
|
|||||||
|
diff --git chrome/browser/profiles/off_the_record_profile_impl.cc chrome/browser/profiles/off_the_record_profile_impl.cc
|
||||||
|
index 6a9d6e152136..8d710c7617df 100644
|
||||||
|
--- chrome/browser/profiles/off_the_record_profile_impl.cc
|
||||||
|
+++ chrome/browser/profiles/off_the_record_profile_impl.cc
|
||||||
|
@@ -618,7 +618,9 @@ std::unique_ptr<Profile> Profile::CreateOffTheRecordProfile(
|
||||||
|
#endif
|
||||||
|
if (!profile)
|
||||||
|
profile.reset(new OffTheRecordProfileImpl(parent, otr_profile_id));
|
||||||
|
- profile->Init();
|
||||||
|
+ // With CEF we want to delay initialization.
|
||||||
|
+ if (!otr_profile_id.IsUniqueForCEF())
|
||||||
|
+ profile->Init();
|
||||||
|
return std::move(profile);
|
||||||
|
}
|
||||||
|
|
||||||
diff --git chrome/browser/profiles/profile.cc chrome/browser/profiles/profile.cc
|
diff --git chrome/browser/profiles/profile.cc chrome/browser/profiles/profile.cc
|
||||||
index 8e8a7abdcf17..89c47d18d379 100644
|
index 8e8a7abdcf17..15822ab615eb 100644
|
||||||
--- chrome/browser/profiles/profile.cc
|
--- chrome/browser/profiles/profile.cc
|
||||||
+++ chrome/browser/profiles/profile.cc
|
+++ chrome/browser/profiles/profile.cc
|
||||||
@@ -77,6 +77,7 @@ base::LazyInstance<std::set<content::BrowserContext*>>::Leaky
|
@@ -77,6 +77,7 @@ base::LazyInstance<std::set<content::BrowserContext*>>::Leaky
|
||||||
@@ -19,7 +34,7 @@ index 8e8a7abdcf17..89c47d18d379 100644
|
|||||||
base::StartsWith(profile_id_, kDevToolsOTRProfileIDPrefix,
|
base::StartsWith(profile_id_, kDevToolsOTRProfileIDPrefix,
|
||||||
base::CompareCase::SENSITIVE) ||
|
base::CompareCase::SENSITIVE) ||
|
||||||
base::StartsWith(profile_id_, kMediaRouterOTRProfileIDPrefix,
|
base::StartsWith(profile_id_, kMediaRouterOTRProfileIDPrefix,
|
||||||
@@ -111,6 +114,11 @@ Profile::OTRProfileID Profile::OTRProfileID::CreateUnique(
|
@@ -111,6 +114,16 @@ Profile::OTRProfileID Profile::OTRProfileID::CreateUnique(
|
||||||
first_unused_index_++));
|
first_unused_index_++));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,24 +42,63 @@ index 8e8a7abdcf17..89c47d18d379 100644
|
|||||||
+Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForCEF() {
|
+Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForCEF() {
|
||||||
+ return CreateUnique(kCEFOTRProfileIDPrefix);
|
+ return CreateUnique(kCEFOTRProfileIDPrefix);
|
||||||
+}
|
+}
|
||||||
|
+
|
||||||
|
+bool Profile::OTRProfileID::IsUniqueForCEF() const {
|
||||||
|
+ return base::StartsWith(profile_id_, kCEFOTRProfileIDPrefix,
|
||||||
|
+ base::CompareCase::SENSITIVE);
|
||||||
|
+}
|
||||||
+
|
+
|
||||||
// static
|
// static
|
||||||
Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForDevTools() {
|
Profile::OTRProfileID Profile::OTRProfileID::CreateUniqueForDevTools() {
|
||||||
return CreateUnique(kDevToolsOTRProfileIDPrefix);
|
return CreateUnique(kDevToolsOTRProfileIDPrefix);
|
||||||
diff --git chrome/browser/profiles/profile.h chrome/browser/profiles/profile.h
|
diff --git chrome/browser/profiles/profile.h chrome/browser/profiles/profile.h
|
||||||
index e77f4b15ce32..13569302c96b 100644
|
index e77f4b15ce32..3f5d61aeabe5 100644
|
||||||
--- chrome/browser/profiles/profile.h
|
--- chrome/browser/profiles/profile.h
|
||||||
+++ chrome/browser/profiles/profile.h
|
+++ chrome/browser/profiles/profile.h
|
||||||
@@ -116,6 +116,9 @@ class Profile : public content::BrowserContext {
|
@@ -116,6 +116,10 @@ class Profile : public content::BrowserContext {
|
||||||
// Creates a unique OTR profile id with the given profile id prefix.
|
// Creates a unique OTR profile id with the given profile id prefix.
|
||||||
static OTRProfileID CreateUnique(const std::string& profile_id_prefix);
|
static OTRProfileID CreateUnique(const std::string& profile_id_prefix);
|
||||||
|
|
||||||
+ // Creates a unique OTR profile id to be used for CEF browser contexts.
|
+ // Creates a unique OTR profile id to be used for CEF browser contexts.
|
||||||
+ static OTRProfileID CreateUniqueForCEF();
|
+ static OTRProfileID CreateUniqueForCEF();
|
||||||
|
+ bool IsUniqueForCEF() const;
|
||||||
+
|
+
|
||||||
// Creates a unique OTR profile id to be used for DevTools browser contexts.
|
// Creates a unique OTR profile id to be used for DevTools browser contexts.
|
||||||
static OTRProfileID CreateUniqueForDevTools();
|
static OTRProfileID CreateUniqueForDevTools();
|
||||||
|
|
||||||
|
@@ -523,6 +527,8 @@ class Profile : public content::BrowserContext {
|
||||||
|
std::vector<network::mojom::CorsOriginPatternPtr> block_patterns,
|
||||||
|
base::OnceClosure closure) override;
|
||||||
|
|
||||||
|
+ void NotifyOffTheRecordProfileCreated(Profile* off_the_record);
|
||||||
|
+
|
||||||
|
protected:
|
||||||
|
void set_is_guest_profile(bool is_guest_profile) {
|
||||||
|
is_guest_profile_ = is_guest_profile;
|
||||||
|
@@ -542,8 +548,6 @@ class Profile : public content::BrowserContext {
|
||||||
|
static PrefStore* CreateExtensionPrefStore(Profile*,
|
||||||
|
bool incognito_pref_store);
|
||||||
|
|
||||||
|
- void NotifyOffTheRecordProfileCreated(Profile* off_the_record);
|
||||||
|
-
|
||||||
|
// Returns whether the user has signed in this profile to an account.
|
||||||
|
virtual bool IsSignedIn() = 0;
|
||||||
|
|
||||||
|
diff --git chrome/browser/profiles/profile_impl.cc chrome/browser/profiles/profile_impl.cc
|
||||||
|
index e33b9cff8827..50b89735481e 100644
|
||||||
|
--- chrome/browser/profiles/profile_impl.cc
|
||||||
|
+++ chrome/browser/profiles/profile_impl.cc
|
||||||
|
@@ -953,7 +953,9 @@ Profile* ProfileImpl::GetOffTheRecordProfile(
|
||||||
|
|
||||||
|
otr_profiles_[otr_profile_id] = std::move(otr_profile);
|
||||||
|
|
||||||
|
- NotifyOffTheRecordProfileCreated(raw_otr_profile);
|
||||||
|
+ // With CEF we want to delay initialization.
|
||||||
|
+ if (!otr_profile_id.IsUniqueForCEF())
|
||||||
|
+ NotifyOffTheRecordProfileCreated(raw_otr_profile);
|
||||||
|
|
||||||
|
return raw_otr_profile;
|
||||||
|
}
|
||||||
diff --git chrome/browser/profiles/profile_manager.cc chrome/browser/profiles/profile_manager.cc
|
diff --git chrome/browser/profiles/profile_manager.cc chrome/browser/profiles/profile_manager.cc
|
||||||
index 71730949d2bd..eedcde617f01 100644
|
index 71730949d2bd..eedcde617f01 100644
|
||||||
--- chrome/browser/profiles/profile_manager.cc
|
--- chrome/browser/profiles/profile_manager.cc
|
||||||
|
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
|
// static
|
||||||
|
void ClientAppBrowser::RegisterCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes) {}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void ClientAppBrowser::CreateDelegates(DelegateSet& delegates) {
|
void ClientAppBrowser::CreateDelegates(DelegateSet& delegates) {
|
||||||
browser::CreateDelegates(delegates);
|
browser::CreateDelegates(delegates);
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "include/cef_parser.h"
|
#include "include/cef_parser.h"
|
||||||
#include "include/cef_web_plugin.h"
|
#include "include/cef_web_plugin.h"
|
||||||
|
#include "tests/shared/browser/client_app_browser.h"
|
||||||
#include "tests/shared/common/client_switches.h"
|
#include "tests/shared/common/client_switches.h"
|
||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
@@ -188,15 +189,7 @@ bool MainContextImpl::TouchEventsEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainContextImpl::PopulateSettings(CefSettings* settings) {
|
void MainContextImpl::PopulateSettings(CefSettings* settings) {
|
||||||
#if defined(OS_WIN) || defined(OS_LINUX)
|
client::ClientAppBrowser::PopulateSettings(command_line_, *settings);
|
||||||
settings->multi_threaded_message_loop =
|
|
||||||
command_line_->HasSwitch(switches::kMultiThreadedMessageLoop);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!settings->multi_threaded_message_loop) {
|
|
||||||
settings->external_message_pump =
|
|
||||||
command_line_->HasSwitch(switches::kExternalMessagePump);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (use_chrome_runtime_)
|
if (use_chrome_runtime_)
|
||||||
settings->chrome_runtime = true;
|
settings->chrome_runtime = true;
|
||||||
|
@@ -8,10 +8,8 @@
|
|||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void ClientApp::RegisterCustomSchemes(
|
void ClientApp::RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
scheme_test::RegisterCustomSchemes(registrar);
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@@ -9,8 +9,7 @@
|
|||||||
namespace client {
|
namespace client {
|
||||||
namespace scheme_test {
|
namespace scheme_test {
|
||||||
|
|
||||||
void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar,
|
void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
registrar->AddCustomScheme(
|
registrar->AddCustomScheme(
|
||||||
"client", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
"client", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,7 @@ namespace scheme_test {
|
|||||||
// See browser/scheme_test.h for creation/registration of the custom scheme
|
// See browser/scheme_test.h for creation/registration of the custom scheme
|
||||||
// handler which only occurs in the browser process. Called from
|
// handler which only occurs in the browser process. Called from
|
||||||
// client_app_delegates_common.cc.
|
// client_app_delegates_common.cc.
|
||||||
void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar,
|
void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
std::vector<CefString>& cookiable_schemes);
|
|
||||||
|
|
||||||
} // namespace scheme_test
|
} // namespace scheme_test
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@@ -84,31 +84,43 @@ void CreateRenderDelegates(ClientAppRenderer::DelegateSet& delegates) {
|
|||||||
CreateV8RendererTests(delegates);
|
CreateV8RendererTests(delegates);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar,
|
void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
// Bring in the scheme handler tests.
|
// Bring in the scheme handler tests.
|
||||||
extern void RegisterSchemeHandlerCustomSchemes(
|
extern void RegisterSchemeHandlerCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
std::vector<CefString> & cookiable_schemes);
|
RegisterSchemeHandlerCustomSchemes(registrar);
|
||||||
RegisterSchemeHandlerCustomSchemes(registrar, cookiable_schemes);
|
|
||||||
|
|
||||||
// Bring in the cookie tests.
|
// Bring in the cookie tests.
|
||||||
extern void RegisterCookieCustomSchemes(
|
extern void RegisterCookieCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
std::vector<CefString> & cookiable_schemes);
|
RegisterCookieCustomSchemes(registrar);
|
||||||
RegisterCookieCustomSchemes(registrar, cookiable_schemes);
|
|
||||||
|
|
||||||
// Bring in the URLRequest tests.
|
// Bring in the URLRequest tests.
|
||||||
extern void RegisterURLRequestCustomSchemes(
|
extern void RegisterURLRequestCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
std::vector<CefString> & cookiable_schemes);
|
RegisterURLRequestCustomSchemes(registrar);
|
||||||
RegisterURLRequestCustomSchemes(registrar, cookiable_schemes);
|
|
||||||
|
|
||||||
// Bring in the resource request handler tests.
|
// Bring in the resource request handler tests.
|
||||||
extern void RegisterResourceRequestHandlerCustomSchemes(
|
extern void RegisterResourceRequestHandlerCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
std::vector<CefString> & cookiable_schemes);
|
RegisterResourceRequestHandlerCustomSchemes(registrar);
|
||||||
RegisterResourceRequestHandlerCustomSchemes(registrar, cookiable_schemes);
|
}
|
||||||
|
|
||||||
|
void RegisterCookieableSchemes(std::vector<std::string>& cookieable_schemes) {
|
||||||
|
// Bring in the scheme handler tests.
|
||||||
|
extern void RegisterSchemeHandlerCookieableSchemes(std::vector<std::string> &
|
||||||
|
cookieable_schemes);
|
||||||
|
RegisterSchemeHandlerCookieableSchemes(cookieable_schemes);
|
||||||
|
|
||||||
|
// Bring in the cookie tests.
|
||||||
|
extern void RegisterCookieCookieableSchemes(std::vector<std::string> &
|
||||||
|
cookieable_schemes);
|
||||||
|
RegisterCookieCookieableSchemes(cookieable_schemes);
|
||||||
|
|
||||||
|
// Bring in the URLRequest tests.
|
||||||
|
extern void RegisterURLRequestCookieableSchemes(std::vector<std::string> &
|
||||||
|
cookieable_schemes);
|
||||||
|
RegisterURLRequestCookieableSchemes(cookieable_schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace client {
|
namespace client {
|
||||||
@@ -124,10 +136,14 @@ void ClientAppRenderer::CreateDelegates(DelegateSet& delegates) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void ClientApp::RegisterCustomSchemes(
|
void ClientApp::RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
::RegisterCustomSchemes(registrar);
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
}
|
||||||
::RegisterCustomSchemes(registrar, cookiable_schemes);
|
|
||||||
|
// static
|
||||||
|
void ClientAppBrowser::RegisterCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes) {
|
||||||
|
::RegisterCookieableSchemes(cookieable_schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@@ -28,6 +28,11 @@ const char* kTestPath = "/path/to/cookietest";
|
|||||||
|
|
||||||
const int kIgnoreNumDeleted = -2;
|
const int kIgnoreNumDeleted = -2;
|
||||||
|
|
||||||
|
bool IgnoreURL(const std::string& url) {
|
||||||
|
return IsChromeRuntimeEnabled() &&
|
||||||
|
url.find("/favicon.ico") != std::string::npos;
|
||||||
|
}
|
||||||
|
|
||||||
typedef std::vector<CefCookie> CookieVector;
|
typedef std::vector<CefCookie> CookieVector;
|
||||||
|
|
||||||
class TestCompletionCallback : public CefCompletionCallback {
|
class TestCompletionCallback : public CefCompletionCallback {
|
||||||
@@ -843,36 +848,31 @@ class CookieTestSchemeHandler : public TestHandler {
|
|||||||
} else {
|
} else {
|
||||||
// Create the request context that will use an in-memory cache.
|
// Create the request context that will use an in-memory cache.
|
||||||
CefRequestContextSettings settings;
|
CefRequestContextSettings settings;
|
||||||
|
|
||||||
|
if (scheme_ == kCustomCookieScheme || block_cookies_) {
|
||||||
|
if (!block_cookies_) {
|
||||||
|
CefString(&settings.cookieable_schemes_list) = kCustomCookieScheme;
|
||||||
|
} else {
|
||||||
|
settings.cookieable_schemes_exclude_defaults = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
request_context_ = CefRequestContext::CreateContext(settings, nullptr);
|
request_context_ = CefRequestContext::CreateContext(settings, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the scheme handler.
|
// Register the scheme handler.
|
||||||
request_context_->RegisterSchemeHandlerFactory(
|
request_context_->RegisterSchemeHandlerFactory(
|
||||||
scheme_, "cookie-tests", new SchemeHandlerFactory(this));
|
scheme_, "cookie-tests", new SchemeHandlerFactory(this));
|
||||||
manager_ = request_context_->GetCookieManager(nullptr);
|
|
||||||
if (!use_global_ && (scheme_ == kCustomCookieScheme || block_cookies_)) {
|
|
||||||
std::vector<CefString> schemes;
|
|
||||||
if (!block_cookies_)
|
|
||||||
schemes.push_back(kCustomCookieScheme);
|
|
||||||
|
|
||||||
// Need to wait for completion before creating the browser.
|
manager_ = request_context_->GetCookieManager(nullptr);
|
||||||
manager_->SetSupportedSchemes(
|
|
||||||
schemes, !block_cookies_ /* include_defaults */,
|
// Create the browser.
|
||||||
new CompletionCallback(base::Bind(
|
CreateBrowser(url1_, request_context_);
|
||||||
&CookieTestSchemeHandler::CreateBrowserContinue, this)));
|
|
||||||
} else {
|
|
||||||
CreateBrowserContinue();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Time out the test after a reasonable period of time.
|
// Time out the test after a reasonable period of time.
|
||||||
SetTestTimeout();
|
SetTestTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateBrowserContinue() {
|
|
||||||
// Create the browser.
|
|
||||||
CreateBrowser(url1_, request_context_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Go to the next URL.
|
// Go to the next URL.
|
||||||
void LoadNextURL(CefRefPtr<CefFrame> frame, const std::string& url) {
|
void LoadNextURL(CefRefPtr<CefFrame> frame, const std::string& url) {
|
||||||
if (!CefCurrentlyOn(TID_UI)) {
|
if (!CefCurrentlyOn(TID_UI)) {
|
||||||
@@ -1220,7 +1220,9 @@ class CookieAccessSchemeHandlerFactory : public CefSchemeHandlerFactory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unknown test.
|
// Unknown test.
|
||||||
ADD_FAILURE() << "Unexpected url: " << url;
|
if (!IgnoreURL(url)) {
|
||||||
|
ADD_FAILURE() << "Unexpected url: " << url;
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1253,8 +1255,6 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
public:
|
public:
|
||||||
CookieAccessServerHandler()
|
CookieAccessServerHandler()
|
||||||
: initialized_(false),
|
: initialized_(false),
|
||||||
expected_connection_ct_(-1),
|
|
||||||
actual_connection_ct_(0),
|
|
||||||
expected_http_request_ct_(-1),
|
expected_http_request_ct_(-1),
|
||||||
actual_http_request_ct_(0) {}
|
actual_http_request_ct_(0) {}
|
||||||
|
|
||||||
@@ -1269,7 +1269,7 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
// Must be called before CreateServer().
|
// Must be called before CreateServer().
|
||||||
void SetExpectedRequestCount(int count) {
|
void SetExpectedRequestCount(int count) {
|
||||||
EXPECT_FALSE(initialized_);
|
EXPECT_FALSE(initialized_);
|
||||||
expected_connection_ct_ = expected_http_request_ct_ = count;
|
expected_http_request_ct_ = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// |complete_callback| will be executed on the UI thread after the server is
|
// |complete_callback| will be executed on the UI thread after the server is
|
||||||
@@ -1277,7 +1277,7 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
void CreateServer(const base::Closure& complete_callback) {
|
void CreateServer(const base::Closure& complete_callback) {
|
||||||
EXPECT_UI_THREAD();
|
EXPECT_UI_THREAD();
|
||||||
|
|
||||||
if (expected_connection_ct_ < 0) {
|
if (expected_http_request_ct_ < 0) {
|
||||||
// Default to the assumption of one request per registered URL.
|
// Default to the assumption of one request per registered URL.
|
||||||
SetExpectedRequestCount(static_cast<int>(data_map_.size()));
|
SetExpectedRequestCount(static_cast<int>(data_map_.size()));
|
||||||
}
|
}
|
||||||
@@ -1325,36 +1325,11 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnClientConnected(CefRefPtr<CefServer> server,
|
|
||||||
int connection_id) override {
|
|
||||||
EXPECT_UI_THREAD();
|
|
||||||
|
|
||||||
EXPECT_TRUE(connection_id_set_.find(connection_id) ==
|
|
||||||
connection_id_set_.end());
|
|
||||||
connection_id_set_.insert(connection_id);
|
|
||||||
|
|
||||||
actual_connection_ct_++;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OnClientDisconnected(CefRefPtr<CefServer> server,
|
|
||||||
int connection_id) override {
|
|
||||||
EXPECT_UI_THREAD();
|
|
||||||
|
|
||||||
ConnectionIdSet::iterator it = connection_id_set_.find(connection_id);
|
|
||||||
EXPECT_TRUE(it != connection_id_set_.end());
|
|
||||||
connection_id_set_.erase(it);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OnHttpRequest(CefRefPtr<CefServer> server,
|
bool OnHttpRequest(CefRefPtr<CefServer> server,
|
||||||
int connection_id,
|
int connection_id,
|
||||||
const CefString& client_address,
|
const CefString& client_address,
|
||||||
CefRefPtr<CefRequest> request) override {
|
CefRefPtr<CefRequest> request) override {
|
||||||
EXPECT_UI_THREAD();
|
EXPECT_UI_THREAD();
|
||||||
EXPECT_TRUE(VerifyConnection(connection_id));
|
|
||||||
EXPECT_FALSE(client_address.empty());
|
EXPECT_FALSE(client_address.empty());
|
||||||
|
|
||||||
// Log the requests for better error reporting.
|
// Log the requests for better error reporting.
|
||||||
@@ -1369,15 +1344,9 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool VerifyConnection(int connection_id) {
|
|
||||||
return connection_id_set_.find(connection_id) != connection_id_set_.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void VerifyResults() {
|
void VerifyResults() {
|
||||||
EXPECT_TRUE(got_server_created_);
|
EXPECT_TRUE(got_server_created_);
|
||||||
EXPECT_TRUE(got_server_destroyed_);
|
EXPECT_TRUE(got_server_destroyed_);
|
||||||
EXPECT_TRUE(connection_id_set_.empty());
|
|
||||||
EXPECT_EQ(expected_connection_ct_, actual_connection_ct_) << request_log_;
|
|
||||||
EXPECT_EQ(expected_http_request_ct_, actual_http_request_ct_)
|
EXPECT_EQ(expected_http_request_ct_, actual_http_request_ct_)
|
||||||
<< request_log_;
|
<< request_log_;
|
||||||
}
|
}
|
||||||
@@ -1400,7 +1369,9 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
it->second->response_data);
|
it->second->response_data);
|
||||||
} else {
|
} else {
|
||||||
// Unknown test.
|
// Unknown test.
|
||||||
ADD_FAILURE() << "Unexpected url: " << url;
|
if (!IgnoreURL(url)) {
|
||||||
|
ADD_FAILURE() << "Unexpected url: " << url;
|
||||||
|
}
|
||||||
server->SendHttp500Response(connection_id, "Unknown test");
|
server->SendHttp500Response(connection_id, "Unknown test");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1461,11 +1432,6 @@ class CookieAccessServerHandler : public test_server::ObserverHelper,
|
|||||||
TrackCallback got_server_created_;
|
TrackCallback got_server_created_;
|
||||||
TrackCallback got_server_destroyed_;
|
TrackCallback got_server_destroyed_;
|
||||||
|
|
||||||
typedef std::set<int> ConnectionIdSet;
|
|
||||||
ConnectionIdSet connection_id_set_;
|
|
||||||
|
|
||||||
int expected_connection_ct_;
|
|
||||||
int actual_connection_ct_;
|
|
||||||
int expected_http_request_ct_;
|
int expected_http_request_ct_;
|
||||||
int actual_http_request_ct_;
|
int actual_http_request_ct_;
|
||||||
|
|
||||||
@@ -1484,9 +1450,9 @@ class CookieAccessTestHandler : public RoutingTestHandler,
|
|||||||
BLOCK_READ_WRITE = BLOCK_READ | BLOCK_WRITE,
|
BLOCK_READ_WRITE = BLOCK_READ | BLOCK_WRITE,
|
||||||
ALLOW_NO_FILTER = 1 << 2,
|
ALLOW_NO_FILTER = 1 << 2,
|
||||||
|
|
||||||
// Block all cookies using SetSupportedSchemes. Can only be used with a
|
// Block all cookies using CefRequestContextSettings. Can only be used with
|
||||||
// non-global request context because it's too late (during test execution)
|
// a non-global request context because it's too late (during test
|
||||||
// to call this method on the global context.
|
// execution) to call this method on the global context.
|
||||||
BLOCK_ALL_COOKIES = 1 << 3,
|
BLOCK_ALL_COOKIES = 1 << 3,
|
||||||
|
|
||||||
// Return nullptr from GetResourceRequestHandler. Can only be used in
|
// Return nullptr from GetResourceRequestHandler. Can only be used in
|
||||||
@@ -1528,27 +1494,23 @@ class CookieAccessTestHandler : public RoutingTestHandler,
|
|||||||
} else {
|
} else {
|
||||||
// Create the request context that will use an in-memory cache.
|
// Create the request context that will use an in-memory cache.
|
||||||
CefRequestContextSettings settings;
|
CefRequestContextSettings settings;
|
||||||
|
|
||||||
|
const bool block_cookies = (test_mode_ == BLOCK_ALL_COOKIES);
|
||||||
|
if (scheme_ == kCustomCookieScheme || block_cookies) {
|
||||||
|
if (!block_cookies) {
|
||||||
|
CefString(&settings.cookieable_schemes_list) = kCustomCookieScheme;
|
||||||
|
} else {
|
||||||
|
settings.cookieable_schemes_exclude_defaults = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context_ = CefRequestContext::CreateContext(settings, nullptr);
|
context_ = CefRequestContext::CreateContext(settings, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie_manager_ = context_->GetCookieManager(nullptr);
|
|
||||||
|
|
||||||
SetTestTimeout();
|
SetTestTimeout();
|
||||||
|
|
||||||
const bool block_cookies = (test_mode_ == BLOCK_ALL_COOKIES);
|
cookie_manager_ = context_->GetCookieManager(nullptr);
|
||||||
if (!use_global_ && (scheme_ == kCustomCookieScheme || block_cookies)) {
|
RunTestSetupContinue();
|
||||||
std::vector<CefString> schemes;
|
|
||||||
if (!block_cookies)
|
|
||||||
schemes.push_back(kCustomCookieScheme);
|
|
||||||
|
|
||||||
// Need to wait for completion before creating the browser.
|
|
||||||
cookie_manager_->SetSupportedSchemes(
|
|
||||||
schemes, !block_cookies /* include_defaults */,
|
|
||||||
new CompletionCallback(base::Bind(
|
|
||||||
&CookieAccessTestHandler::RunTestSetupContinue, this)));
|
|
||||||
} else {
|
|
||||||
RunTestSetupContinue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyTest() override {
|
void DestroyTest() override {
|
||||||
@@ -1665,7 +1627,7 @@ class CookieAccessTestHandler : public RoutingTestHandler,
|
|||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefRequest> request) override {
|
CefRefPtr<CefRequest> request) override {
|
||||||
if (test_backend_ == RESOURCE_HANDLER) {
|
if (test_backend_ == RESOURCE_HANDLER && scheme_factory_) {
|
||||||
return scheme_factory_->Create(browser, frame, scheme_, request);
|
return scheme_factory_->Create(browser, frame, scheme_, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1681,7 +1643,7 @@ class CookieAccessTestHandler : public RoutingTestHandler,
|
|||||||
const std::string& url = request->GetURL();
|
const std::string& url = request->GetURL();
|
||||||
if (url == GetCookieAccessUrl2(scheme_, test_backend_ == SERVER)) {
|
if (url == GetCookieAccessUrl2(scheme_, test_backend_ == SERVER)) {
|
||||||
can_send_cookie2_ct_++;
|
can_send_cookie2_ct_++;
|
||||||
} else {
|
} else if (!IgnoreURL(url)) {
|
||||||
ADD_FAILURE() << "Unexpected url: " << url;
|
ADD_FAILURE() << "Unexpected url: " << url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1702,7 +1664,7 @@ class CookieAccessTestHandler : public RoutingTestHandler,
|
|||||||
const std::string& url = request->GetURL();
|
const std::string& url = request->GetURL();
|
||||||
if (url == GetCookieAccessUrl1(scheme_, test_backend_ == SERVER)) {
|
if (url == GetCookieAccessUrl1(scheme_, test_backend_ == SERVER)) {
|
||||||
can_save_cookie1_ct_++;
|
can_save_cookie1_ct_++;
|
||||||
} else {
|
} else if (!IgnoreURL(url)) {
|
||||||
ADD_FAILURE() << "Unexpected url: " << url;
|
ADD_FAILURE() << "Unexpected url: " << url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2367,11 +2329,17 @@ TEST(CookieTest, RestartInMemory) {
|
|||||||
|
|
||||||
// Entry point for registering custom schemes.
|
// Entry point for registering custom schemes.
|
||||||
// Called from client_app_delegates.cc.
|
// Called from client_app_delegates.cc.
|
||||||
void RegisterCookieCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar,
|
void RegisterCookieCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
// Used by GetCookieManagerCustom* tests.
|
// Used by GetCookieManagerCustom* tests.
|
||||||
registrar->AddCustomScheme(
|
registrar->AddCustomScheme(
|
||||||
kCustomCookieScheme,
|
kCustomCookieScheme,
|
||||||
CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
||||||
cookiable_schemes.push_back(kCustomCookieScheme);
|
}
|
||||||
|
|
||||||
|
// Entry point for registering cookieable schemes.
|
||||||
|
// Called from client_app_delegates.cc.
|
||||||
|
void RegisterCookieCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes) {
|
||||||
|
// Used by GetCookieManagerCustom* tests.
|
||||||
|
cookieable_schemes.push_back(kCustomCookieScheme);
|
||||||
}
|
}
|
||||||
|
@@ -3943,8 +3943,7 @@ TEST(ResourceRequestHandlerTest, FilterError) {
|
|||||||
// Entry point for registering custom schemes.
|
// Entry point for registering custom schemes.
|
||||||
// Called from client_app_delegates.cc.
|
// Called from client_app_delegates.cc.
|
||||||
void RegisterResourceRequestHandlerCustomSchemes(
|
void RegisterResourceRequestHandlerCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
// Add a custom standard scheme.
|
// Add a custom standard scheme.
|
||||||
registrar->AddCustomScheme(
|
registrar->AddCustomScheme(
|
||||||
"rrhcustom", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
"rrhcustom", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
||||||
|
@@ -2579,8 +2579,7 @@ TEST(SchemeHandlerTest, AcceptLanguage) {
|
|||||||
// Entry point for registering custom schemes.
|
// Entry point for registering custom schemes.
|
||||||
// Called from client_app_delegates.cc.
|
// Called from client_app_delegates.cc.
|
||||||
void RegisterSchemeHandlerCustomSchemes(
|
void RegisterSchemeHandlerCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
// Registering the custom standard schemes as secure because requests from
|
// Registering the custom standard schemes as secure because requests from
|
||||||
// non-secure origins to the loopback address will be blocked by
|
// non-secure origins to the loopback address will be blocked by
|
||||||
// https://chromestatus.com/feature/5436853517811712.
|
// https://chromestatus.com/feature/5436853517811712.
|
||||||
@@ -2589,15 +2588,22 @@ void RegisterSchemeHandlerCustomSchemes(
|
|||||||
registrar->AddCustomScheme("customstd", CEF_SCHEME_OPTION_STANDARD |
|
registrar->AddCustomScheme("customstd", CEF_SCHEME_OPTION_STANDARD |
|
||||||
CEF_SCHEME_OPTION_SECURE |
|
CEF_SCHEME_OPTION_SECURE |
|
||||||
CEF_SCHEME_OPTION_CORS_ENABLED);
|
CEF_SCHEME_OPTION_CORS_ENABLED);
|
||||||
cookiable_schemes.push_back("customstd");
|
|
||||||
// Also used in cors_unittest.cc.
|
// Also used in cors_unittest.cc.
|
||||||
registrar->AddCustomScheme(
|
registrar->AddCustomScheme(
|
||||||
"customstdfetch", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_SECURE |
|
"customstdfetch", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_SECURE |
|
||||||
CEF_SCHEME_OPTION_CORS_ENABLED |
|
CEF_SCHEME_OPTION_CORS_ENABLED |
|
||||||
CEF_SCHEME_OPTION_FETCH_ENABLED);
|
CEF_SCHEME_OPTION_FETCH_ENABLED);
|
||||||
cookiable_schemes.push_back("customstdfetch");
|
|
||||||
// Add a custom non-standard scheme.
|
// Add a custom non-standard scheme.
|
||||||
registrar->AddCustomScheme("customnonstd", CEF_SCHEME_OPTION_NONE);
|
registrar->AddCustomScheme("customnonstd", CEF_SCHEME_OPTION_NONE);
|
||||||
registrar->AddCustomScheme("customnonstdfetch",
|
registrar->AddCustomScheme("customnonstdfetch",
|
||||||
CEF_SCHEME_OPTION_FETCH_ENABLED);
|
CEF_SCHEME_OPTION_FETCH_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Entry point for registering cookieable schemes.
|
||||||
|
// Called from client_app_delegates.cc.
|
||||||
|
void RegisterSchemeHandlerCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes) {
|
||||||
|
cookieable_schemes.push_back("customstd");
|
||||||
|
// Also used in cors_unittest.cc.
|
||||||
|
cookieable_schemes.push_back("customstdfetch");
|
||||||
|
}
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "include/cef_file_util.h"
|
#include "include/cef_file_util.h"
|
||||||
#include "include/wrapper/cef_scoped_temp_dir.h"
|
#include "include/wrapper/cef_scoped_temp_dir.h"
|
||||||
#include "tests/gtest/include/gtest/gtest.h"
|
#include "tests/gtest/include/gtest/gtest.h"
|
||||||
|
#include "tests/shared/browser/client_app_browser.h"
|
||||||
#include "tests/shared/common/client_switches.h"
|
#include "tests/shared/common/client_switches.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -132,20 +133,12 @@ int CefTestSuite::Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefTestSuite::GetSettings(CefSettings& settings) const {
|
void CefTestSuite::GetSettings(CefSettings& settings) const {
|
||||||
|
client::ClientAppBrowser::PopulateSettings(command_line_, settings);
|
||||||
|
|
||||||
// Enable the experimental Chrome runtime. See issue #2969 for details.
|
// Enable the experimental Chrome runtime. See issue #2969 for details.
|
||||||
settings.chrome_runtime =
|
settings.chrome_runtime =
|
||||||
command_line_->HasSwitch(client::switches::kEnableChromeRuntime);
|
command_line_->HasSwitch(client::switches::kEnableChromeRuntime);
|
||||||
|
|
||||||
#if (defined(OS_WIN) || defined(OS_LINUX))
|
|
||||||
settings.multi_threaded_message_loop =
|
|
||||||
command_line_->HasSwitch(client::switches::kMultiThreadedMessageLoop);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!settings.multi_threaded_message_loop) {
|
|
||||||
settings.external_message_pump =
|
|
||||||
command_line_->HasSwitch(client::switches::kExternalMessagePump);
|
|
||||||
}
|
|
||||||
|
|
||||||
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_;
|
CefString(&settings.user_data_path) = root_cache_path_;
|
||||||
|
@@ -2900,6 +2900,11 @@ class RequestTestHandler : public TestHandler {
|
|||||||
CefString(&settings.cache_path) = context_tmpdir_path_;
|
CefString(&settings.cache_path) = context_tmpdir_path_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!test_server_backend_) {
|
||||||
|
// Set the schemes that are allowed to store cookies.
|
||||||
|
CefString(&settings.cookieable_schemes_list) = GetRequestScheme(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Create a new temporary request context. Calls OnContextInitialized.
|
// Create a new temporary request context. Calls OnContextInitialized.
|
||||||
CefRequestContext::CreateContext(settings,
|
CefRequestContext::CreateContext(settings,
|
||||||
new RequestContextHandler(this));
|
new RequestContextHandler(this));
|
||||||
@@ -2910,20 +2915,7 @@ class RequestTestHandler : public TestHandler {
|
|||||||
EXPECT_TRUE(CefCurrentlyOn(TID_UI));
|
EXPECT_TRUE(CefCurrentlyOn(TID_UI));
|
||||||
EXPECT_TRUE(request_context.get());
|
EXPECT_TRUE(request_context.get());
|
||||||
test_runner_->SetRequestContext(request_context);
|
test_runner_->SetRequestContext(request_context);
|
||||||
|
PreSetupComplete();
|
||||||
if (!test_server_backend_) {
|
|
||||||
// Set the schemes that are allowed to store cookies.
|
|
||||||
std::vector<CefString> supported_schemes;
|
|
||||||
supported_schemes.push_back(GetRequestScheme(false));
|
|
||||||
|
|
||||||
// Continue the test once supported schemes has been set.
|
|
||||||
request_context->GetCookieManager(nullptr)->SetSupportedSchemes(
|
|
||||||
supported_schemes, true,
|
|
||||||
new TestCompletionCallback(
|
|
||||||
base::Bind(&RequestTestHandler::PreSetupComplete, this)));
|
|
||||||
} else {
|
|
||||||
PreSetupComplete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreSetupComplete() {
|
void PreSetupComplete() {
|
||||||
@@ -3269,13 +3261,18 @@ void CreateURLRequestRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
|||||||
|
|
||||||
// Entry point for registering custom schemes.
|
// Entry point for registering custom schemes.
|
||||||
// Called from client_app_delegates.cc.
|
// Called from client_app_delegates.cc.
|
||||||
void RegisterURLRequestCustomSchemes(
|
void RegisterURLRequestCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar,
|
|
||||||
std::vector<CefString>& cookiable_schemes) {
|
|
||||||
const std::string& scheme = GetRequestScheme(false);
|
const std::string& scheme = GetRequestScheme(false);
|
||||||
registrar->AddCustomScheme(
|
registrar->AddCustomScheme(
|
||||||
scheme, CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
scheme, CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_CORS_ENABLED);
|
||||||
cookiable_schemes.push_back(scheme);
|
}
|
||||||
|
|
||||||
|
// Entry point for registering cookieable schemes.
|
||||||
|
// Called from client_app_delegates.cc.
|
||||||
|
void RegisterURLRequestCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes) {
|
||||||
|
const std::string& scheme = GetRequestScheme(false);
|
||||||
|
cookieable_schemes.push_back(scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers for defining URLRequest tests.
|
// Helpers for defining URLRequest tests.
|
||||||
|
@@ -15,6 +15,32 @@ ClientAppBrowser::ClientAppBrowser() {
|
|||||||
CreateDelegates(delegates_);
|
CreateDelegates(delegates_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
void ClientAppBrowser::PopulateSettings(CefRefPtr<CefCommandLine> command_line,
|
||||||
|
CefSettings& settings) {
|
||||||
|
#if (defined(OS_WIN) || defined(OS_LINUX))
|
||||||
|
settings.multi_threaded_message_loop =
|
||||||
|
command_line->HasSwitch(client::switches::kMultiThreadedMessageLoop);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!settings.multi_threaded_message_loop) {
|
||||||
|
settings.external_message_pump =
|
||||||
|
command_line->HasSwitch(client::switches::kExternalMessagePump);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> cookieable_schemes;
|
||||||
|
RegisterCookieableSchemes(cookieable_schemes);
|
||||||
|
if (!cookieable_schemes.empty()) {
|
||||||
|
std::string list_str;
|
||||||
|
for (const auto& scheme : cookieable_schemes) {
|
||||||
|
if (!list_str.empty())
|
||||||
|
list_str += ",";
|
||||||
|
list_str += scheme;
|
||||||
|
}
|
||||||
|
CefString(&settings.cookieable_schemes_list) = list_str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ClientAppBrowser::OnBeforeCommandLineProcessing(
|
void ClientAppBrowser::OnBeforeCommandLineProcessing(
|
||||||
const CefString& process_type,
|
const CefString& process_type,
|
||||||
CefRefPtr<CefCommandLine> command_line) {
|
CefRefPtr<CefCommandLine> command_line) {
|
||||||
@@ -61,14 +87,6 @@ void ClientAppBrowser::OnBeforeCommandLineProcessing(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientAppBrowser::GetCookieableSchemes(std::vector<CefString>& schemes,
|
|
||||||
bool& include_defaults) {
|
|
||||||
if (!cookieable_schemes_.empty()) {
|
|
||||||
schemes = cookieable_schemes_;
|
|
||||||
include_defaults = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientAppBrowser::OnContextInitialized() {
|
void ClientAppBrowser::OnContextInitialized() {
|
||||||
DelegateSet::iterator it = delegates_.begin();
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
for (; it != delegates_.end(); ++it)
|
for (; it != delegates_.end(); ++it)
|
||||||
|
@@ -35,7 +35,17 @@ class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
|
|||||||
|
|
||||||
ClientAppBrowser();
|
ClientAppBrowser();
|
||||||
|
|
||||||
|
// Called to populate |settings| based on |command_line| and other global
|
||||||
|
// state.
|
||||||
|
static void PopulateSettings(CefRefPtr<CefCommandLine> command_line,
|
||||||
|
CefSettings& settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Registers cookieable schemes. Implemented by cefclient in
|
||||||
|
// client_app_delegates_browser.cc
|
||||||
|
static void RegisterCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes);
|
||||||
|
|
||||||
// Creates all of the Delegate objects. Implemented by cefclient in
|
// Creates all of the Delegate objects. Implemented by cefclient in
|
||||||
// client_app_delegates_browser.cc
|
// client_app_delegates_browser.cc
|
||||||
static void CreateDelegates(DelegateSet& delegates);
|
static void CreateDelegates(DelegateSet& delegates);
|
||||||
@@ -49,8 +59,6 @@ class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CefBrowserProcessHandler methods.
|
// CefBrowserProcessHandler methods.
|
||||||
void GetCookieableSchemes(std::vector<CefString>& schemes,
|
|
||||||
bool& include_defaults) OVERRIDE;
|
|
||||||
void OnContextInitialized() OVERRIDE;
|
void OnContextInitialized() OVERRIDE;
|
||||||
void OnBeforeChildProcessLaunch(
|
void OnBeforeChildProcessLaunch(
|
||||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||||
|
@@ -41,7 +41,7 @@ ClientApp::ProcessType ClientApp::GetProcessType(
|
|||||||
|
|
||||||
void ClientApp::OnRegisterCustomSchemes(
|
void ClientApp::OnRegisterCustomSchemes(
|
||||||
CefRawPtr<CefSchemeRegistrar> registrar) {
|
CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
RegisterCustomSchemes(registrar, cookieable_schemes_);
|
RegisterCustomSchemes(registrar);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
@@ -27,15 +27,10 @@ class ClientApp : public CefApp {
|
|||||||
// Determine the process type based on command-line arguments.
|
// Determine the process type based on command-line arguments.
|
||||||
static ProcessType GetProcessType(CefRefPtr<CefCommandLine> command_line);
|
static ProcessType GetProcessType(CefRefPtr<CefCommandLine> command_line);
|
||||||
|
|
||||||
protected:
|
|
||||||
// Schemes that will be registered with the global cookie manager.
|
|
||||||
std::vector<CefString> cookieable_schemes_;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Registers custom schemes. Implemented by cefclient in
|
// Registers custom schemes. Implemented by cefclient in
|
||||||
// client_app_delegates_common.cc
|
// client_app_delegates_common.cc
|
||||||
static void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar,
|
static void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
std::vector<CefString>& cookiable_schemes);
|
|
||||||
|
|
||||||
// CefApp methods.
|
// CefApp methods.
|
||||||
void OnRegisterCustomSchemes(
|
void OnRegisterCustomSchemes(
|
||||||
|
Reference in New Issue
Block a user