1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Defines the Chrome Extensions Debugger API functions for attaching debugger 6 // to the page. 7 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_DEBUGGER_DEBUGGER_API_H_ 9 #define CHROME_BROWSER_EXTENSIONS_API_DEBUGGER_DEBUGGER_API_H_ 10 11 #include <string> 12 #include <vector> 13 14 #include "chrome/browser/extensions/chrome_extension_function.h" 15 #include "chrome/common/extensions/api/debugger.h" 16 17 using extensions::api::debugger::Debuggee; 18 19 // Base debugger function. 20 21 class ExtensionDevToolsClientHost; 22 class DevToolsTargetImpl; 23 24 namespace base { 25 class DictionaryValue; 26 } 27 28 namespace content { 29 class DevToolsAgentHost; 30 class WebContents; 31 } 32 33 class DebuggerFunction : public ChromeAsyncExtensionFunction { 34 protected: 35 DebuggerFunction(); 36 virtual ~DebuggerFunction(); 37 38 void FormatErrorMessage(const std::string& format); 39 40 bool InitAgentHost(); 41 bool InitClientHost(); 42 43 Debuggee debuggee_; 44 scoped_refptr<content::DevToolsAgentHost> agent_host_; 45 ExtensionDevToolsClientHost* client_host_; 46 }; 47 48 // Implements the debugger.attach() extension function. 49 class DebuggerAttachFunction : public DebuggerFunction { 50 public: 51 DECLARE_EXTENSION_FUNCTION("debugger.attach", DEBUGGER_ATTACH) 52 53 DebuggerAttachFunction(); 54 55 protected: 56 virtual ~DebuggerAttachFunction(); 57 58 // ExtensionFunction: 59 virtual bool RunImpl() OVERRIDE; 60 }; 61 62 // Implements the debugger.detach() extension function. 63 class DebuggerDetachFunction : public DebuggerFunction { 64 public: 65 DECLARE_EXTENSION_FUNCTION("debugger.detach", DEBUGGER_DETACH) 66 67 DebuggerDetachFunction(); 68 69 protected: 70 virtual ~DebuggerDetachFunction(); 71 72 // ExtensionFunction: 73 virtual bool RunImpl() OVERRIDE; 74 }; 75 76 // Implements the debugger.sendCommand() extension function. 77 class DebuggerSendCommandFunction : public DebuggerFunction { 78 public: 79 DECLARE_EXTENSION_FUNCTION("debugger.sendCommand", DEBUGGER_SENDCOMMAND) 80 81 DebuggerSendCommandFunction(); 82 void SendResponseBody(base::DictionaryValue* result); 83 84 protected: 85 virtual ~DebuggerSendCommandFunction(); 86 87 // ExtensionFunction: 88 virtual bool RunImpl() OVERRIDE; 89 }; 90 91 // Implements the debugger.getTargets() extension function. 92 class DebuggerGetTargetsFunction : public DebuggerFunction { 93 public: 94 DECLARE_EXTENSION_FUNCTION("debugger.getTargets", DEBUGGER_ATTACH) 95 96 DebuggerGetTargetsFunction(); 97 98 protected: 99 virtual ~DebuggerGetTargetsFunction(); 100 101 // ExtensionFunction: 102 virtual bool RunImpl() OVERRIDE; 103 104 private: 105 void SendTargetList(const std::vector<DevToolsTargetImpl*>& target_list); 106 }; 107 108 #endif // CHROME_BROWSER_EXTENSIONS_API_DEBUGGER_DEBUGGER_API_H_ 109