2019-03-25 19:14:23 +01: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_MANAGER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_MANAGER_IMPL_H_
|
|
|
|
|
|
|
|
#include "base/files/file_path.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_cookie.h"
|
|
|
|
#include "cef/libcef/browser/browser_context.h"
|
|
|
|
#include "cef/libcef/browser/thread_util.h"
|
2019-03-25 19:14:23 +01:00
|
|
|
|
2020-03-27 21:00:36 +01:00
|
|
|
// Implementation of the CefCookieManager interface. May be created on any
|
|
|
|
// thread.
|
2019-03-25 19:14:23 +01:00
|
|
|
class CefCookieManagerImpl : public CefCookieManager {
|
|
|
|
public:
|
|
|
|
CefCookieManagerImpl();
|
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefCookieManagerImpl(const CefCookieManagerImpl&) = delete;
|
|
|
|
CefCookieManagerImpl& operator=(const CefCookieManagerImpl&) = delete;
|
|
|
|
|
2020-03-27 21:00:36 +01:00
|
|
|
// Called on the UI thread after object creation and before any other object
|
|
|
|
// methods are executed on the UI thread.
|
|
|
|
void Initialize(CefBrowserContext::Getter browser_context_getter,
|
2019-03-25 19:14:23 +01:00
|
|
|
CefRefPtr<CefCompletionCallback> callback);
|
|
|
|
|
|
|
|
// CefCookieManager methods.
|
|
|
|
bool VisitAllCookies(CefRefPtr<CefCookieVisitor> visitor) override;
|
|
|
|
bool VisitUrlCookies(const CefString& url,
|
|
|
|
bool includeHttpOnly,
|
|
|
|
CefRefPtr<CefCookieVisitor> visitor) override;
|
|
|
|
bool SetCookie(const CefString& url,
|
|
|
|
const CefCookie& cookie,
|
|
|
|
CefRefPtr<CefSetCookieCallback> callback) override;
|
|
|
|
bool DeleteCookies(const CefString& url,
|
|
|
|
const CefString& cookie_name,
|
|
|
|
CefRefPtr<CefDeleteCookiesCallback> callback) override;
|
|
|
|
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
|
|
|
|
|
|
|
|
private:
|
2021-04-15 01:28:22 +02:00
|
|
|
bool VisitAllCookiesInternal(CefRefPtr<CefCookieVisitor> visitor);
|
|
|
|
bool VisitUrlCookiesInternal(const GURL& url,
|
|
|
|
bool includeHttpOnly,
|
|
|
|
CefRefPtr<CefCookieVisitor> visitor);
|
|
|
|
bool SetCookieInternal(const GURL& url,
|
|
|
|
const CefCookie& cookie,
|
|
|
|
CefRefPtr<CefSetCookieCallback> callback);
|
|
|
|
bool DeleteCookiesInternal(const GURL& url,
|
|
|
|
const CefString& cookie_name,
|
|
|
|
CefRefPtr<CefDeleteCookiesCallback> callback);
|
|
|
|
bool FlushStoreInternal(CefRefPtr<CefCompletionCallback> callback);
|
|
|
|
|
|
|
|
// If the context is fully initialized execute |callback|, otherwise
|
|
|
|
// store it until the context is fully initialized.
|
|
|
|
void StoreOrTriggerInitCallback(base::OnceClosure callback);
|
|
|
|
|
|
|
|
bool ValidContext() const;
|
|
|
|
|
2020-03-27 21:00:36 +01:00
|
|
|
// Only accessed on the UI thread. Will be non-null after Initialize().
|
|
|
|
CefBrowserContext::Getter browser_context_getter_;
|
2019-03-25 19:14:23 +01:00
|
|
|
|
2021-04-15 01:28:22 +02:00
|
|
|
bool initialized_ = false;
|
|
|
|
std::vector<base::OnceClosure> init_callbacks_;
|
|
|
|
|
2019-03-25 19:14:23 +01:00
|
|
|
IMPLEMENT_REFCOUNTING(CefCookieManagerImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_NET_SERVICE_COOKIE_MANAGER_IMPL_H_
|