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