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

@@ -454,13 +454,19 @@ bool CefNetworkDelegate::OnCanGetCookies(const net::URLRequest& request,
if (!handler)
return true;
CefRefPtr<CefCookieAccessFilter> cookie_filter =
handler->GetCookieAccessFilter(browser, frame, requestPtr.get());
if (!cookie_filter)
return true;
bool cookie_blocked = false;
for (const auto& cookie : cookie_list) {
CefCookie cef_cookie;
if (!net_service::MakeCefCookie(cookie, cef_cookie))
continue;
if (!handler->CanSendCookie(browser, frame, requestPtr.get(), cef_cookie)) {
if (!cookie_filter->CanSendCookie(browser, frame, requestPtr.get(),
cef_cookie)) {
if (!cookie_blocked)
cookie_blocked = true;
}
@@ -486,6 +492,11 @@ bool CefNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
if (!handler)
return true;
CefRefPtr<CefCookieAccessFilter> cookie_filter =
handler->GetCookieAccessFilter(browser, frame, requestPtr.get());
if (!cookie_filter)
return true;
CefCookie cef_cookie;
if (!net_service::MakeCefCookie(cookie, cef_cookie))
return true;
@@ -494,8 +505,8 @@ bool CefNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
responsePtr->Set(&request);
responsePtr->SetReadOnly(true);
return handler->CanSaveCookie(browser, frame, requestPtr.get(),
responsePtr.get(), cef_cookie);
return cookie_filter->CanSaveCookie(browser, frame, requestPtr.get(),
responsePtr.get(), cef_cookie);
}
bool CefNetworkDelegate::OnCanAccessFile(