electron/shell/browser/api/atom_api_cookies.h

71 lines
1.8 KiB
C
Raw Normal View History

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.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_BROWSER_API_ATOM_API_COOKIES_H_
#define SHELL_BROWSER_API_ATOM_API_COOKIES_H_
2015-06-14 08:19:53 +00:00
#include <memory>
2015-06-14 08:19:53 +00:00
#include <string>
#include "base/callback_list.h"
#include "gin/handle.h"
2015-06-14 08:19:53 +00:00
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_change_dispatcher.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/gin_helper/trackable_object.h"
2015-06-14 08:19:53 +00:00
namespace base {
class DictionaryValue;
}
namespace gin_helper {
class Dictionary;
}
namespace net {
class URLRequestContextGetter;
}
namespace electron {
2015-06-14 08:19:53 +00:00
2016-07-04 06:08:55 +00:00
class AtomBrowserContext;
2015-06-14 08:19:53 +00:00
namespace api {
class Cookies : public gin_helper::TrackableObject<Cookies> {
2015-06-14 08:19:53 +00:00
public:
static gin::Handle<Cookies> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
2015-06-14 08:19:53 +00:00
// gin_helper::TrackableObject:
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
2015-06-14 08:19:53 +00:00
protected:
2016-07-04 06:08:55 +00:00
Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context);
2016-04-25 01:17:54 +00:00
~Cookies() override;
2015-06-14 08:19:53 +00:00
v8::Local<v8::Promise> Get(const gin_helper::Dictionary& filter);
v8::Local<v8::Promise> Set(base::DictionaryValue details);
v8::Local<v8::Promise> Remove(const GURL& url, const std::string& name);
v8::Local<v8::Promise> FlushStore();
2015-06-15 13:18:40 +00:00
// CookieChangeNotifier subscription:
void OnCookieChanged(const net::CookieChangeInfo& change);
2015-06-14 08:19:53 +00:00
private:
std::unique_ptr<base::CallbackList<void(
const net::CookieChangeInfo& change)>::Subscription>
cookie_change_subscription_;
scoped_refptr<AtomBrowserContext> browser_context_;
2015-06-14 08:19:53 +00:00
DISALLOW_COPY_AND_ASSIGN(Cookies);
};
} // namespace api
} // namespace electron
2015-06-14 08:19:53 +00:00
2019-06-19 20:56:58 +00:00
#endif // SHELL_BROWSER_API_ATOM_API_COOKIES_H_