2018-10-04 18:08:56 +00:00
|
|
|
// Copyright (c) 2018 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_
|
|
|
|
#define SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_
|
2018-10-04 18:08:56 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "base/callback_list.h"
|
|
|
|
#include "base/macros.h"
|
2019-08-24 01:14:23 +00:00
|
|
|
#include "mojo/public/cpp/bindings/receiver.h"
|
2019-10-28 22:12:35 +00:00
|
|
|
#include "net/cookies/cookie_change_dispatcher.h"
|
2018-10-04 18:08:56 +00:00
|
|
|
#include "services/network/public/mojom/cookie_manager.mojom.h"
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2018-10-04 18:08:56 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
class ElectronBrowserContext;
|
2018-10-04 18:08:56 +00:00
|
|
|
|
|
|
|
// Sends cookie-change notifications on the UI thread.
|
|
|
|
class CookieChangeNotifier : public network::mojom::CookieChangeListener {
|
|
|
|
public:
|
2020-02-04 20:19:40 +00:00
|
|
|
explicit CookieChangeNotifier(ElectronBrowserContext* browser_context);
|
2018-10-04 18:08:56 +00:00
|
|
|
~CookieChangeNotifier() override;
|
|
|
|
|
|
|
|
// Register callbacks that needs to notified on any cookie store changes.
|
2020-12-14 18:57:36 +00:00
|
|
|
base::CallbackListSubscription RegisterCookieChangeCallback(
|
2019-10-28 22:12:35 +00:00
|
|
|
const base::Callback<void(const net::CookieChangeInfo& change)>& cb);
|
2018-10-04 18:08:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void StartListening();
|
|
|
|
void OnConnectionError();
|
|
|
|
|
|
|
|
// network::mojom::CookieChangeListener implementation.
|
2019-10-28 22:12:35 +00:00
|
|
|
void OnCookieChange(const net::CookieChangeInfo& change) override;
|
2018-10-04 18:08:56 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
ElectronBrowserContext* browser_context_;
|
2019-10-28 22:12:35 +00:00
|
|
|
base::CallbackList<void(const net::CookieChangeInfo& change)>
|
|
|
|
cookie_change_sub_list_;
|
2019-08-24 01:14:23 +00:00
|
|
|
|
|
|
|
mojo::Receiver<network::mojom::CookieChangeListener> receiver_;
|
2018-10-04 18:08:56 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CookieChangeNotifier);
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2018-10-04 18:08:56 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_
|