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 "WebDevToolsAgentPrivate.h" 38 #include "WebPageOverlay.h" 39 #include "public/platform/WebSize.h" 40 #include "public/platform/WebThread.h" 41 #include "wtf/Forward.h" 42 #include "wtf/OwnPtr.h" 43 44 namespace WebCore { 45 class Document; 46 class Frame; 47 class FrameView; 48 class GraphicsContext; 49 class InspectorClient; 50 class InspectorController; 51 class Node; 52 class PlatformKeyboardEvent; 53 } 54 55 namespace blink { 56 57 class WebDevToolsAgentClient; 58 class WebFrame; 59 class WebFrameImpl; 60 class WebString; 61 class WebURLRequest; 62 class WebURLResponse; 63 class WebViewImpl; 64 struct WebMemoryUsageInfo; 65 struct WebURLError; 66 struct WebDevToolsMessageData; 67 68 class WebDevToolsAgentImpl : public WebDevToolsAgentPrivate, 69 public WebCore::InspectorClient, 70 public WebCore::InspectorFrontendChannel, 71 public WebPageOverlay, 72 private WebThread::TaskObserver { 73 public: 74 WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client); 75 virtual ~WebDevToolsAgentImpl(); 76 77 // WebDevToolsAgentPrivate implementation. 78 virtual void didCreateScriptContext(WebFrameImpl*, int worldId); 79 virtual void webViewResized(const WebSize&); 80 virtual bool handleInputEvent(WebCore::Page*, const WebInputEvent&); 81 82 // WebDevToolsAgent implementation. 83 virtual void attach(); 84 virtual void reattach(const WebString& savedState); 85 virtual void detach(); 86 virtual void didNavigate(); 87 virtual void didBeginFrame(int frameId); 88 virtual void didCancelFrame(); 89 virtual void willComposite(); 90 virtual void didComposite(); 91 virtual void dispatchOnInspectorBackend(const WebString& message); 92 virtual void inspectElementAt(const WebPoint& point); 93 virtual void evaluateInWebInspector(long callId, const WebString& script); 94 virtual void setProcessId(long); 95 virtual void setLayerTreeId(int); 96 // FIXME: remove it once the client side stops firing these. 97 virtual void processGPUEvent(double timestamp, int phase, bool foreign) OVERRIDE; 98 virtual void processGPUEvent(const GPUEvent&) OVERRIDE; 99 100 // InspectorClient implementation. 101 virtual void highlight(); 102 virtual void hideHighlight(); 103 virtual void updateInspectorStateCookie(const WTF::String&); 104 virtual bool sendMessageToFrontend(const WTF::String&); 105 106 virtual void clearBrowserCache(); 107 virtual void clearBrowserCookies(); 108 109 virtual void overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow); 110 111 virtual void getAllocatedObjects(HashSet<const void*>&); 112 virtual void dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>&); 113 virtual void setTraceEventCallback(TraceEventCallback); 114 virtual void startGPUEventsRecording() OVERRIDE; 115 virtual void stopGPUEventsRecording() OVERRIDE; 116 117 virtual void dispatchKeyEvent(const WebCore::PlatformKeyboardEvent&); 118 virtual void dispatchMouseEvent(const WebCore::PlatformMouseEvent&); 119 120 // WebPageOverlay 121 virtual void paintPageOverlay(WebCanvas*); 122 123 private: 124 // WebThread::TaskObserver 125 virtual void willProcessTask(); 126 virtual void didProcessTask(); 127 128 void enableViewportEmulation(); 129 void disableViewportEmulation(); 130 131 WebCore::InspectorController* inspectorController(); 132 WebCore::Frame* mainFrame(); 133 134 int m_hostId; 135 WebDevToolsAgentClient* m_client; 136 WebViewImpl* m_webViewImpl; 137 bool m_attached; 138 bool m_generatingEvent; 139 bool m_deviceMetricsEnabled; 140 bool m_emulateViewportEnabled; 141 bool m_originalViewportEnabled; 142 bool m_isOverlayScrollbarsEnabled; 143 }; 144 145 } // namespace blink 146 147 #endif 148