InspectorController.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 InspectorController_h
  31. #define InspectorController_h
  32. #if ENABLE(INSPECTOR)
  33. #include "InspectorBaseAgent.h"
  34. #include <wtf/Forward.h>
  35. #include <wtf/HashMap.h>
  36. #include <wtf/Noncopyable.h>
  37. #include <wtf/text/WTFString.h>
  38. namespace WebCore {
  39. class DOMWrapperWorld;
  40. class Frame;
  41. class GraphicsContext;
  42. class InjectedScriptManager;
  43. class InspectorAgent;
  44. class InspectorApplicationCacheAgent;
  45. class InspectorBackendDispatcher;
  46. class InspectorBaseAgentInterface;
  47. class InspectorClient;
  48. class InspectorDOMAgent;
  49. class InspectorDOMDebuggerAgent;
  50. class InspectorDebuggerAgent;
  51. class InspectorFrontend;
  52. class InspectorFrontendChannel;
  53. class InspectorFrontendClient;
  54. class InspectorMemoryAgent;
  55. class InspectorOverlay;
  56. class InspectorPageAgent;
  57. class InspectorProfilerAgent;
  58. class InspectorResourceAgent;
  59. class InspectorState;
  60. class InstrumentingAgents;
  61. class IntSize;
  62. class Page;
  63. class PostWorkerNotificationToFrontendTask;
  64. class Node;
  65. struct Highlight;
  66. class InspectorController {
  67. WTF_MAKE_NONCOPYABLE(InspectorController);
  68. WTF_MAKE_FAST_ALLOCATED;
  69. public:
  70. ~InspectorController();
  71. static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
  72. void inspectedPageDestroyed();
  73. bool enabled() const;
  74. Page* inspectedPage() const;
  75. void show();
  76. void close();
  77. void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient>);
  78. bool hasInspectorFrontendClient() const;
  79. void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
  80. void setInjectedScriptForOrigin(const String& origin, const String& source);
  81. void dispatchMessageFromFrontend(const String& message);
  82. bool hasFrontend() const { return m_inspectorFrontend; }
  83. void connectFrontend(InspectorFrontendChannel*);
  84. void disconnectFrontend();
  85. void reconnectFrontend(InspectorFrontendChannel*, const String& inspectorStateCookie);
  86. void setProcessId(long);
  87. void webViewResized(const IntSize&);
  88. void inspect(Node*);
  89. void drawHighlight(GraphicsContext&) const;
  90. void getHighlight(Highlight*) const;
  91. void hideHighlight();
  92. Node* highlightedNode() const;
  93. bool isUnderTest();
  94. void evaluateForTestInFrontend(long callId, const String& script);
  95. #if ENABLE(JAVASCRIPT_DEBUGGER)
  96. bool profilerEnabled();
  97. void setProfilerEnabled(bool);
  98. void resume();
  99. #endif
  100. void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
  101. InspectorClient* inspectorClient() const { return m_inspectorClient; }
  102. InspectorPageAgent* pageAgent() const { return m_pageAgent; }
  103. void willProcessTask();
  104. void didProcessTask();
  105. void didBeginFrame();
  106. void didCancelFrame();
  107. void willComposite();
  108. void didComposite();
  109. private:
  110. InspectorController(Page*, InspectorClient*);
  111. friend class PostWorkerNotificationToFrontendTask;
  112. friend InstrumentingAgents* instrumentationForPage(Page*);
  113. RefPtr<InstrumentingAgents> m_instrumentingAgents;
  114. OwnPtr<InjectedScriptManager> m_injectedScriptManager;
  115. OwnPtr<InspectorCompositeState> m_state;
  116. OwnPtr<InspectorOverlay> m_overlay;
  117. InspectorAgent* m_inspectorAgent;
  118. InspectorDOMAgent* m_domAgent;
  119. InspectorResourceAgent* m_resourceAgent;
  120. InspectorPageAgent* m_pageAgent;
  121. InspectorMemoryAgent* m_memoryAgent;
  122. #if ENABLE(JAVASCRIPT_DEBUGGER)
  123. InspectorDebuggerAgent* m_debuggerAgent;
  124. InspectorDOMDebuggerAgent* m_domDebuggerAgent;
  125. InspectorProfilerAgent* m_profilerAgent;
  126. #endif
  127. RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
  128. OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
  129. OwnPtr<InspectorFrontend> m_inspectorFrontend;
  130. Page* m_page;
  131. InspectorClient* m_inspectorClient;
  132. InspectorAgentRegistry m_agents;
  133. bool m_isUnderTest;
  134. };
  135. }
  136. #endif // ENABLE(INSPECTOR)
  137. #endif // !defined(InspectorController_h)