| 
									
										
										
										
											2016-01-22 10:27:25 +05:30
										 |  |  | // Copyright (c) 2016 GitHub, Inc.
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | // 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_DEBUGGER_H_
 | 
					
						
							|  |  |  | #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_DEBUGGER_H_
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | #include <map>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-11 16:07:39 -04:00
										 |  |  | #include "base/memory/raw_ptr.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | #include "base/values.h"
 | 
					
						
							|  |  |  | #include "content/public/browser/devtools_agent_host_client.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-06 20:14:22 +05:30
										 |  |  | #include "content/public/browser/web_contents_observer.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-18 12:57:08 -07:00
										 |  |  | #include "gin/wrappable.h"
 | 
					
						
							|  |  |  | #include "shell/browser/event_emitter_mixin.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | namespace content { | 
					
						
							|  |  |  | class DevToolsAgentHost; | 
					
						
							|  |  |  | class WebContents; | 
					
						
							| 
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 |  |  | }  // namespace content
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-22 04:31:32 -05:00
										 |  |  | namespace gin { | 
					
						
							|  |  |  | class Arguments; | 
					
						
							|  |  |  | }  // namespace gin
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-29 12:42:57 -05:00
										 |  |  | namespace gin_helper { | 
					
						
							|  |  |  | template <typename T> | 
					
						
							|  |  |  | class Handle; | 
					
						
							|  |  |  | template <typename T> | 
					
						
							|  |  |  | class Promise; | 
					
						
							|  |  |  | }  // namespace gin_helper
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-29 12:55:47 -07:00
										 |  |  | namespace electron::api { | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-04 18:40:02 -05:00
										 |  |  | class Debugger final : public gin::Wrappable<Debugger>, | 
					
						
							|  |  |  |                        public gin_helper::EventEmitterMixin<Debugger>, | 
					
						
							|  |  |  |                        public content::DevToolsAgentHostClient, | 
					
						
							|  |  |  |                        private content::WebContentsObserver { | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  |  public: | 
					
						
							| 
									
										
										
										
											2019-10-25 22:03:28 +09:00
										 |  |  |   static gin::Handle<Debugger> Create(v8::Isolate* isolate, | 
					
						
							|  |  |  |                                       content::WebContents* web_contents); | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 12:57:08 -07:00
										 |  |  |   // gin::Wrappable
 | 
					
						
							|  |  |  |   static gin::WrapperInfo kWrapperInfo; | 
					
						
							|  |  |  |   gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 
					
						
							|  |  |  |       v8::Isolate* isolate) override; | 
					
						
							|  |  |  |   const char* GetTypeName() override; | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-03 12:41:45 +01:00
										 |  |  |   // disable copy
 | 
					
						
							|  |  |  |   Debugger(const Debugger&) = delete; | 
					
						
							|  |  |  |   Debugger& operator=(const Debugger&) = delete; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  |  protected: | 
					
						
							| 
									
										
										
										
											2016-04-25 10:17:54 +09:00
										 |  |  |   Debugger(v8::Isolate* isolate, content::WebContents* web_contents); | 
					
						
							|  |  |  |   ~Debugger() override; | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |   // content::DevToolsAgentHostClient:
 | 
					
						
							| 
									
										
										
										
											2018-04-11 13:43:06 +02:00
										 |  |  |   void AgentHostClosed(content::DevToolsAgentHost* agent_host) override; | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  |   void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host, | 
					
						
							| 
									
										
										
										
											2020-01-17 10:41:52 -08:00
										 |  |  |                                base::span<const uint8_t> message) override; | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 20:14:22 +05:30
										 |  |  |   // content::WebContentsObserver:
 | 
					
						
							|  |  |  |   void RenderFrameHostChanged(content::RenderFrameHost* old_rfh, | 
					
						
							|  |  |  |                               content::RenderFrameHost* new_rfh) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  |  private: | 
					
						
							| 
									
										
										
										
											2019-08-22 17:03:28 -07:00
										 |  |  |   using PendingRequestMap = | 
					
						
							| 
									
										
										
										
											2022-07-05 08:25:18 -07:00
										 |  |  |       std::map<int, gin_helper::Promise<base::Value::Dict>>; | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-18 12:57:08 -07:00
										 |  |  |   void Attach(gin::Arguments* args); | 
					
						
							| 
									
										
										
										
											2016-01-22 14:17:23 +05:30
										 |  |  |   bool IsAttached(); | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  |   void Detach(); | 
					
						
							| 
									
										
										
										
											2020-03-18 12:57:08 -07:00
										 |  |  |   v8::Local<v8::Promise> SendCommand(gin::Arguments* args); | 
					
						
							| 
									
										
										
										
											2018-09-06 20:14:22 +05:30
										 |  |  |   void ClearPendingRequests(); | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-11 16:07:39 -04:00
										 |  |  |   raw_ptr<content::WebContents> web_contents_;  // Weak Reference.
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  |   scoped_refptr<content::DevToolsAgentHost> agent_host_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   PendingRequestMap pending_requests_; | 
					
						
							| 
									
										
										
										
											2018-05-22 00:18:38 +02:00
										 |  |  |   int previous_request_id_ = 0; | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-29 12:55:47 -07:00
										 |  |  | }  // namespace electron::api
 | 
					
						
							| 
									
										
										
										
											2016-01-21 23:52:23 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-22 08:34:31 +01:00
										 |  |  | #endif  // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_DEBUGGER_H_
 |