forked from adamlaska/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie_change_notifier.h
More file actions
48 lines (35 loc) · 1.6 KB
/
cookie_change_notifier.h
File metadata and controls
48 lines (35 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_
#define ELECTRON_SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_
#include "base/callback_list.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/cookies/cookie_change_dispatcher.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
namespace electron {
class ElectronBrowserContext;
// Sends cookie-change notifications on the UI thread.
class CookieChangeNotifier : public network::mojom::CookieChangeListener {
public:
explicit CookieChangeNotifier(ElectronBrowserContext* browser_context);
~CookieChangeNotifier() override;
// disable copy
CookieChangeNotifier(const CookieChangeNotifier&) = delete;
CookieChangeNotifier& operator=(const CookieChangeNotifier&) = delete;
// Register callbacks that needs to notified on any cookie store changes.
base::CallbackListSubscription RegisterCookieChangeCallback(
const base::RepeatingCallback<void(const net::CookieChangeInfo& change)>&
cb);
private:
void StartListening();
void OnConnectionError();
// network::mojom::CookieChangeListener implementation.
void OnCookieChange(const net::CookieChangeInfo& change) override;
ElectronBrowserContext* browser_context_;
base::RepeatingCallbackList<void(const net::CookieChangeInfo& change)>
cookie_change_sub_list_;
mojo::Receiver<network::mojom::CookieChangeListener> receiver_;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_