Move cookie load/save callbacks to CefCookieAccessFilter (see issue #2622).

This change allows the NetworkService to handle cookie load/save in cases where
cookies will not be filtered (CefResourceRequestHandler::GetCookieAccessFilter
returns null) and the request will be handled by the default network loader.
This represents a minor performance improvement by reducing the volume of cross-
process messaging in the default (no filtering or custom handing) case. Cookie
load/save still needs to be routed through the browser process if a filter is
returned, or if a CefResourceHandler is used for the request.

To test: Test expectations are unchanged.
This commit is contained in:
Marshall Greenblatt
2019-04-26 13:02:47 -04:00
parent edd9efd1b3
commit 2ace33f8b7
16 changed files with 750 additions and 337 deletions

View File

@@ -48,6 +48,8 @@
#include "include/cef_response_filter.h"
#include "include/internal/cef_types_wrappers.h"
class CefCookieAccessFilter;
///
// Implement this interface to handle events related to browser requests. The
// methods of this class will be called on the IO thread unless otherwise
@@ -59,6 +61,21 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
typedef cef_return_value_t ReturnValue;
typedef cef_urlrequest_status_t URLRequestStatus;
///
// Called on the IO thread before a resource request is loaded. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers. To optionally filter cookies for
// the request return a CefCookieAccessFilter object. The |request| object
// cannot not be modified in this callback.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual CefRefPtr<CefCookieAccessFilter> GetCookieAccessFilter(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
return NULL;
}
///
// Called on the IO thread before a resource request is loaded. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
@@ -85,7 +102,7 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
// |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers. To allow the resource to load
// using the default network loader return NULL. To specify a handler for the
// resource return a CefResourceHandler object. The |request| object should
// resource return a CefResourceHandler object. The |request| object cannot
// not be modified in this callback.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
@@ -167,7 +184,7 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
///
// Called on the IO thread to handle requests for URLs with an unknown
// protocol component. The |browser| and |frame| values represent the source
// protocol component. The |browser| and |frame| values represent the source
// of the request, and may be NULL for requests originating from service
// workers. |request| cannot be modified in this callback. Set
// |allow_os_execution| to true to attempt execution via the registered OS
@@ -180,10 +197,22 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool& allow_os_execution) {}
};
///
// Implement this interface to filter cookies that may be sent or received from
// resource requests. The methods of this class will be called on the IO thread
// unless otherwise indicated.
///
/*--cef(source=client)--*/
class CefCookieAccessFilter : public virtual CefBaseRefCounted {
public:
///
// Called on the IO thread before a resource request is sent. Return true if
// the specified cookie can be sent with the request or false otherwise.
// Called on the IO thread before a resource request is sent. The |browser|
// and |frame| values represent the source of the request, and may be NULL for
// requests originating from service workers. |request| cannot be modified in
// this callback. Return true if the specified cookie can be sent with the
// request or false otherwise.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual bool CanSendCookie(CefRefPtr<CefBrowser> browser,
@@ -194,9 +223,11 @@ class CefResourceRequestHandler : public virtual CefBaseRefCounted {
}
///
// Called on the IO thread after a resource response is received. Return true
// if the specified cookie returned with the response can be saved or false
// otherwise.
// Called on the IO thread after a resource response is received. The
// |browser| and |frame| values represent the source of the request, and may
// be NULL for requests originating from service workers. |request| cannot be
// modified in this callback. Return true if the specified cookie returned
// with the response can be saved or false otherwise.
///
/*--cef(optional_param=browser,optional_param=frame)--*/
virtual bool CanSaveCookie(CefRefPtr<CefBrowser> browser,