2015-06-14 08:19:53 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_COOKIES_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_COOKIES_H_
|
2015-06-14 08:19:53 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2018-08-14 21:07:53 +00:00
|
|
|
#include "base/callback_list.h"
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2022-07-05 15:25:18 +00:00
|
|
|
#include "base/values.h"
|
2019-04-30 13:45:05 +00:00
|
|
|
#include "gin/handle.h"
|
2015-06-14 08:19:53 +00:00
|
|
|
#include "net/cookies/canonical_cookie.h"
|
2019-10-28 22:12:35 +00:00
|
|
|
#include "net/cookies/cookie_change_dispatcher.h"
|
2020-03-25 22:34:53 +00:00
|
|
|
#include "shell/browser/event_emitter_mixin.h"
|
2019-11-01 06:10:32 +00:00
|
|
|
#include "shell/common/gin_helper/promise.h"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "shell/common/gin_helper/trackable_object.h"
|
2015-06-14 08:19:53 +00:00
|
|
|
|
2019-10-25 13:03:28 +00:00
|
|
|
namespace gin_helper {
|
2019-10-09 06:57:40 +00:00
|
|
|
class Dictionary;
|
|
|
|
}
|
|
|
|
|
2015-06-14 08:19:53 +00:00
|
|
|
namespace electron {
|
|
|
|
|
2016-07-04 06:08:55 +00:00
|
|
|
class ElectronBrowserContext;
|
|
|
|
|
2015-06-14 08:19:53 +00:00
|
|
|
namespace api {
|
|
|
|
|
2020-03-25 22:34:53 +00:00
|
|
|
class Cookies : public gin::Wrappable<Cookies>,
|
|
|
|
public gin_helper::EventEmitterMixin<Cookies> {
|
2015-06-14 08:19:53 +00:00
|
|
|
public:
|
2019-04-30 13:45:05 +00:00
|
|
|
static gin::Handle<Cookies> Create(v8::Isolate* isolate,
|
|
|
|
ElectronBrowserContext* browser_context);
|
2015-06-14 08:19:53 +00:00
|
|
|
|
2020-03-25 22:34:53 +00:00
|
|
|
// gin::Wrappable
|
|
|
|
static gin::WrapperInfo kWrapperInfo;
|
|
|
|
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
|
|
|
v8::Isolate* isolate) override;
|
|
|
|
const char* GetTypeName() override;
|
2015-12-03 08:04:46 +00:00
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
Cookies(const Cookies&) = delete;
|
|
|
|
Cookies& operator=(const Cookies&) = delete;
|
|
|
|
|
2015-06-14 08:19:53 +00:00
|
|
|
protected:
|
2016-07-04 06:08:55 +00:00
|
|
|
Cookies(v8::Isolate* isolate, ElectronBrowserContext* browser_context);
|
2016-04-25 01:17:54 +00:00
|
|
|
~Cookies() override;
|
2015-06-14 08:19:53 +00:00
|
|
|
|
2020-03-25 22:34:53 +00:00
|
|
|
v8::Local<v8::Promise> Get(v8::Isolate*,
|
|
|
|
const gin_helper::Dictionary& filter);
|
2022-07-05 15:25:18 +00:00
|
|
|
v8::Local<v8::Promise> Set(v8::Isolate*, base::Value::Dict details);
|
2020-03-25 22:34:53 +00:00
|
|
|
v8::Local<v8::Promise> Remove(v8::Isolate*,
|
|
|
|
const GURL& url,
|
|
|
|
const std::string& name);
|
|
|
|
v8::Local<v8::Promise> FlushStore(v8::Isolate*);
|
2015-06-15 13:18:40 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
// CookieChangeNotifier subscription:
|
2019-10-28 22:12:35 +00:00
|
|
|
void OnCookieChanged(const net::CookieChangeInfo& change);
|
2016-09-21 23:24:03 +00:00
|
|
|
|
2015-06-14 08:19:53 +00:00
|
|
|
private:
|
2020-12-14 18:57:36 +00:00
|
|
|
base::CallbackListSubscription cookie_change_subscription_;
|
2020-03-25 22:34:53 +00:00
|
|
|
|
|
|
|
// Weak reference; ElectronBrowserContext is guaranteed to outlive us.
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<ElectronBrowserContext> browser_context_;
|
2015-06-14 08:19:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_COOKIES_H_
|