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