1 /* 2 * Copyright (C) 2010 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 WebDevToolsAgentImpl_h 32 #define WebDevToolsAgentImpl_h 33 34 #include "core/inspector/InspectorClient.h" 35 #include "core/inspector/InspectorFrontendChannel.h" 36 37 #include "public/platform/WebSize.h" 38 #include "public/platform/WebThread.h" 39 #include "public/web/WebPageOverlay.h" 40 #include "web/WebDevToolsAgentPrivate.h" 41 #include "wtf/Forward.h" 42 #include "wtf/OwnPtr.h" 43 #include "wtf/Vector.h" 44 45 namespace WebCore { 46 class Document; 47 class LocalFrame; 48 class FrameView; 49 class GraphicsContext; 50 class InspectorClient; 51 class InspectorController; 52 class Node; 53 class Page; 54 class PlatformKeyboardEvent; 55 } 56 57 namespace blink { 58 59 class WebDevToolsAgentClient; 60 class WebFrame; 61 class WebLocalFrameImpl; 62 class WebString; 63 class WebURLRequest; 64 class WebURLResponse; 65 class WebViewImpl; 66 struct WebMemoryUsageInfo; 67 struct WebURLError; 68 struct WebDevToolsMessageData; 69 70 class WebDevToolsAgentImpl FINAL : 71 public WebDevToolsAgentPrivate, 72 public WebCore::InspectorClient, 73 public WebCore::InspectorFrontendChannel, 74 public WebPageOverlay, 75 private WebThread::TaskObserver { 76 public: 77 WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client); 78 virtual ~WebDevToolsAgentImpl(); 79 80 WebDevToolsAgentClient* client() { return m_client; } 81 82 // WebDevToolsAgentPrivate implementation. 83 virtual void didCreateScriptContext(WebLocalFrameImpl*, int worldId) OVERRIDE; 84 virtual bool handleInputEvent(WebCore::Page*, const WebInputEvent&) OVERRIDE; 85 86 // WebDevToolsAgent implementation. 87 virtual void attach() OVERRIDE; 88 virtual void reattach(const WebString& savedState) OVERRIDE; 89 virtual void attach(const WebString& hostId) OVERRIDE; 90 virtual void reattach(const WebString& hostId, const WebString& savedState) OVERRIDE; 91 virtual void detach() OVERRIDE; 92 virtual void didNavigate() OVERRIDE; 93 virtual void didBeginFrame(int frameId) OVERRIDE; 94 virtual void didCancelFrame() OVERRIDE; 95 virtual void willComposite() OVERRIDE; 96 virtual void didComposite() OVERRIDE; 97 virtual void dispatchOnInspectorBackend(const WebString& message) OVERRIDE; 98 virtual void inspectElementAt(const WebPoint&) OVERRIDE; 99 virtual void evaluateInWebInspector(long callId, const WebString& script) OVERRIDE; 100 virtual void setProcessId(long) OVERRIDE; 101 virtual void setLayerTreeId(int) OVERRIDE; 102 virtual void processGPUEvent(const GPUEvent&) OVERRIDE; 103 104 // InspectorClient implementation. 105 virtual void highlight() OVERRIDE; 106 virtual void hideHighlight() OVERRIDE; 107 virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE; 108 virtual void sendMessageToFrontend(PassRefPtr<WebCore::JSONObject> message) OVERRIDE; 109 virtual void flush() OVERRIDE; 110 111 virtual void setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow) OVERRIDE; 112 virtual void clearDeviceMetricsOverride() OVERRIDE; 113 virtual void setTouchEventEmulationEnabled(bool) OVERRIDE; 114 115 virtual void getAllocatedObjects(HashSet<const void*>&) OVERRIDE; 116 virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&) OVERRIDE; 117 virtual void setTraceEventCallback(const WTF::String& categoryFilter, TraceEventCallback) OVERRIDE; 118 virtual void resetTraceEventCallback() OVERRIDE; 119 virtual void enableTracing(const WTF::String& categoryFilter) OVERRIDE; 120 virtual void disableTracing() OVERRIDE; 121 122 virtual void startGPUEventsRecording() OVERRIDE; 123 virtual void stopGPUEventsRecording() OVERRIDE; 124 125 virtual void dispatchKeyEvent(const WebCore::PlatformKeyboardEvent&) OVERRIDE; 126 virtual void dispatchMouseEvent(const WebCore::PlatformMouseEvent&) OVERRIDE; 127 128 // WebPageOverlay 129 virtual void paintPageOverlay(WebCanvas*) OVERRIDE; 130 131 void flushPendingFrontendMessages(); 132 133 private: 134 // WebThread::TaskObserver 135 virtual void willProcessTask() OVERRIDE; 136 virtual void didProcessTask() OVERRIDE; 137 138 void enableViewportEmulation(); 139 void disableViewportEmulation(); 140 void updatePageScaleFactorLimits(); 141 142 WebCore::InspectorController* inspectorController(); 143 WebCore::LocalFrame* mainFrame(); 144 145 int m_debuggerId; 146 int m_layerTreeId; 147 WebDevToolsAgentClient* m_client; 148 WebViewImpl* m_webViewImpl; 149 bool m_attached; 150 bool m_generatingEvent; 151 152 bool m_deviceMetricsEnabled; 153 bool m_emulateViewportEnabled; 154 bool m_originalViewportEnabled; 155 bool m_isOverlayScrollbarsEnabled; 156 157 float m_originalMinimumPageScaleFactor; 158 float m_originalMaximumPageScaleFactor; 159 bool m_pageScaleLimitsOverriden; 160 161 bool m_touchEventEmulationEnabled; 162 OwnPtr<WebCore::IntPoint> m_lastPinchAnchorCss; 163 OwnPtr<WebCore::IntPoint> m_lastPinchAnchorDip; 164 165 typedef Vector<RefPtr<WebCore::JSONObject> > FrontendMessageQueue; 166 FrontendMessageQueue m_frontendMessageQueue; 167 }; 168 169 } // namespace blink 170 171 #endif 172