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