| 
									
										
										
										
											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.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 |  |  | #ifndef SHELL_BROWSER_API_ELECTRON_API_COOKIES_H_
 | 
					
						
							|  |  |  | #define SHELL_BROWSER_API_ELECTRON_API_COOKIES_H_
 | 
					
						
							| 
									
										
										
										
											2015-06-14 16:19:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 19:25:56 -05:00
										 |  |  | #include <memory>
 | 
					
						
							| 
									
										
										
										
											2015-06-14 16:19:53 +08:00
										 |  |  | #include <string>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 02:37:53 +05:30
										 |  |  | #include "base/callback_list.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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 15:02:16 +08:00
										 |  |  | namespace base { | 
					
						
							|  |  |  | class DictionaryValue; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 22:03:28 +09:00
										 |  |  | namespace gin_helper { | 
					
						
							| 
									
										
										
										
											2019-10-09 15:57:40 +09:00
										 |  |  | class Dictionary; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 15:02:16 +08:00
										 |  |  | namespace net { | 
					
						
							|  |  |  | class URLRequestContextGetter; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 |  |  | namespace electron { | 
					
						
							| 
									
										
										
										
											2015-06-14 16:19:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 |  |  | class ElectronBrowserContext; | 
					
						
							| 
									
										
										
										
											2016-07-04 15:08:55 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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, | 
					
						
							| 
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 |  |  |                                      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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 16:19:53 +08:00
										 |  |  |  protected: | 
					
						
							| 
									
										
										
										
											2020-02-04 12:19:40 -08: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); | 
					
						
							|  |  |  |   v8::Local<v8::Promise> Set(v8::Isolate*, | 
					
						
							|  |  |  |                              const base::DictionaryValue& details); | 
					
						
							|  |  |  |   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: | 
					
						
							| 
									
										
										
										
											2019-10-28 18:12:35 -04:00
										 |  |  |   std::unique_ptr<base::CallbackList<void( | 
					
						
							|  |  |  |       const net::CookieChangeInfo& change)>::Subscription> | 
					
						
							| 
									
										
										
										
											2018-08-15 02:37:53 +05:30
										 |  |  |       cookie_change_subscription_; | 
					
						
							| 
									
										
										
										
											2020-03-25 15:34:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Weak reference; ElectronBrowserContext is guaranteed to outlive us.
 | 
					
						
							|  |  |  |   ElectronBrowserContext* browser_context_; | 
					
						
							| 
									
										
										
										
											2017-11-28 12:53:42 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-14 16:19:53 +08:00
										 |  |  |   DISALLOW_COPY_AND_ASSIGN(Cookies); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }  // namespace api
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 |  |  | }  // namespace electron
 | 
					
						
							| 
									
										
										
										
											2015-06-14 16:19:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 |  |  | #endif  // SHELL_BROWSER_API_ELECTRON_API_COOKIES_H_
 |