2019-04-24 04:50:25 +02:00
|
|
|
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_HELPER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_HELPER_H_
|
|
|
|
|
2022-01-10 22:11:16 +01:00
|
|
|
#include "libcef/browser/browser_context.h"
|
|
|
|
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "base/functional/callback_forward.h"
|
2019-04-24 04:50:25 +02:00
|
|
|
#include "net/cookies/canonical_cookie.h"
|
|
|
|
|
2020-03-04 01:29:39 +01:00
|
|
|
namespace net {
|
|
|
|
class HttpResponseHeaders;
|
|
|
|
}
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
namespace network {
|
|
|
|
struct ResourceRequest;
|
|
|
|
} // namespace network
|
|
|
|
|
|
|
|
namespace net_service {
|
2020-09-04 21:08:55 +02:00
|
|
|
namespace cookie_helper {
|
|
|
|
|
|
|
|
// Returns true if the scheme for |url| supports cookies. |cookieable_schemes|
|
|
|
|
// is the optional list of schemes that the client has explicitly registered as
|
|
|
|
// cookieable, which may intentionally exclude standard schemes.
|
|
|
|
bool IsCookieableScheme(
|
|
|
|
const GURL& url,
|
2021-06-04 03:34:56 +02:00
|
|
|
const absl::optional<std::vector<std::string>>& cookieable_schemes);
|
2019-04-24 04:50:25 +02:00
|
|
|
|
|
|
|
using AllowCookieCallback =
|
2021-06-04 03:34:56 +02:00
|
|
|
base::RepeatingCallback<void(const net::CanonicalCookie&,
|
|
|
|
bool* /* allow */)>;
|
2019-04-24 04:50:25 +02:00
|
|
|
using DoneCookieCallback =
|
|
|
|
base::OnceCallback<void(int /* total_count */,
|
|
|
|
net::CookieList /* allowed_cookies */)>;
|
|
|
|
|
|
|
|
// Load cookies for |request|. |allow_cookie_callback| will be executed for each
|
|
|
|
// cookie and should return true to allow it. |done_callback| will be executed
|
|
|
|
// on completion with |total_count| representing the total number of cookies
|
|
|
|
// retrieved, and |allowed_cookies| representing the list of cookies that were
|
|
|
|
// both retrieved and allowed by |allow_cookie_callback|. The loaded cookies
|
|
|
|
// will not be set on |request|; that should be done in |done_callback|. Must be
|
|
|
|
// called on the IO thread.
|
2022-01-10 22:11:16 +01:00
|
|
|
void LoadCookies(const CefBrowserContext::Getter& browser_context_getter,
|
2019-04-24 04:50:25 +02:00
|
|
|
const network::ResourceRequest& request,
|
|
|
|
const AllowCookieCallback& allow_cookie_callback,
|
|
|
|
DoneCookieCallback done_callback);
|
|
|
|
|
|
|
|
// Save cookies from |head|. |allow_cookie_callback| will be executed for each
|
|
|
|
// cookie and should return true to allow it. |done_callback| will be executed
|
|
|
|
// on completion with |total_count| representing the total number of cookies
|
|
|
|
// retrieved, and |allowed_cookies| representing the list of cookies that were
|
|
|
|
// both allowed by |allow_cookie_callback| an successfully saved. Must be called
|
|
|
|
// on the IO thread.
|
2022-01-10 22:11:16 +01:00
|
|
|
void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
|
2019-04-24 04:50:25 +02:00
|
|
|
const network::ResourceRequest& request,
|
2020-03-04 01:29:39 +01:00
|
|
|
net::HttpResponseHeaders* headers,
|
2019-04-24 04:50:25 +02:00
|
|
|
const AllowCookieCallback& allow_cookie_callback,
|
|
|
|
DoneCookieCallback done_callback);
|
|
|
|
|
2020-09-04 21:08:55 +02:00
|
|
|
} // namespace cookie_helper
|
2019-04-24 04:50:25 +02:00
|
|
|
} // namespace net_service
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_HELPER_H_
|