InspectorRuntimeAgent.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) 2011 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef InspectorRuntimeAgent_h
  31. #define InspectorRuntimeAgent_h
  32. #if ENABLE(INSPECTOR)
  33. #include "InspectorBaseAgent.h"
  34. #include "ScriptState.h"
  35. #include <wtf/Forward.h>
  36. #include <wtf/Noncopyable.h>
  37. namespace WebCore {
  38. class InjectedScript;
  39. class InjectedScriptManager;
  40. class InspectorArray;
  41. class InspectorFrontend;
  42. class InspectorObject;
  43. class InspectorValue;
  44. class InstrumentingAgents;
  45. class ScriptDebugServer;
  46. class WorkerContext;
  47. typedef String ErrorString;
  48. class InspectorRuntimeAgent : public InspectorBaseAgent<InspectorRuntimeAgent>, public InspectorBackendDispatcher::RuntimeCommandHandler {
  49. WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
  50. public:
  51. virtual ~InspectorRuntimeAgent();
  52. bool enabled() { return m_enabled; }
  53. // Part of the protocol.
  54. virtual void enable(ErrorString*) { m_enabled = true; }
  55. virtual void disable(ErrorString*) { m_enabled = false; }
  56. virtual void parse(ErrorString*, const String& expression, TypeBuilder::Runtime::SyntaxErrorType::Enum* result, TypeBuilder::OptOutput<String>* message, RefPtr<TypeBuilder::Runtime::ErrorRange>&);
  57. virtual void evaluate(ErrorString*,
  58. const String& expression,
  59. const String* objectGroup,
  60. const bool* includeCommandLineAPI,
  61. const bool* doNotPauseOnExceptionsAndMuteConsole,
  62. const int* executionContextId,
  63. const bool* returnByValue,
  64. const bool* generatePreview,
  65. RefPtr<TypeBuilder::Runtime::RemoteObject>& result,
  66. TypeBuilder::OptOutput<bool>* wasThrown);
  67. virtual void callFunctionOn(ErrorString*,
  68. const String& objectId,
  69. const String& expression,
  70. const RefPtr<InspectorArray>* optionalArguments,
  71. const bool* doNotPauseOnExceptionsAndMuteConsole,
  72. const bool* returnByValue,
  73. const bool* generatePreview,
  74. RefPtr<TypeBuilder::Runtime::RemoteObject>& result,
  75. TypeBuilder::OptOutput<bool>* wasThrown);
  76. virtual void releaseObject(ErrorString*, const String& objectId);
  77. virtual void getProperties(ErrorString*, const String& objectId, const bool* ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& internalProperties);
  78. virtual void releaseObjectGroup(ErrorString*, const String& objectGroup);
  79. virtual void run(ErrorString*);
  80. #if ENABLE(JAVASCRIPT_DEBUGGER)
  81. void setScriptDebugServer(ScriptDebugServer*);
  82. #endif
  83. protected:
  84. InspectorRuntimeAgent(InstrumentingAgents*, InspectorCompositeState*, InjectedScriptManager*);
  85. virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0;
  86. virtual void muteConsole() = 0;
  87. virtual void unmuteConsole() = 0;
  88. InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; }
  89. bool m_enabled;
  90. private:
  91. InjectedScriptManager* m_injectedScriptManager;
  92. #if ENABLE(JAVASCRIPT_DEBUGGER)
  93. ScriptDebugServer* m_scriptDebugServer;
  94. #endif
  95. };
  96. } // namespace WebCore
  97. #endif // ENABLE(INSPECTOR)
  98. #endif // InspectorRuntimeAgent_h