2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef WebDevToolsAgentImpl_h
32 #define WebDevToolsAgentImpl_h
34 #include "core/inspector/InspectorClient.h"
35 #include "core/inspector/InspectorFrontendChannel.h"
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"
50 class GraphicsContext;
51 class InspectorClient;
52 class InspectorController;
55 class PlatformKeyboardEvent;
56 class WebDevToolsAgentClient;
58 class WebLocalFrameImpl;
63 struct WebMemoryUsageInfo;
65 struct WebDevToolsMessageData;
67 class WebDevToolsAgentImpl FINAL
68 : public WebDevToolsAgentPrivate
69 , public InspectorClient
70 , public InspectorFrontendChannel
71 , public WebPageOverlay
72 , private WebThread::TaskObserver {
74 WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client);
75 virtual ~WebDevToolsAgentImpl();
77 WebDevToolsAgentClient* client() { return m_client; }
79 // WebDevToolsAgentPrivate implementation.
80 virtual void didCreateScriptContext(WebLocalFrameImpl*, int worldId) OVERRIDE;
81 virtual bool handleInputEvent(Page*, const WebInputEvent&) OVERRIDE;
82 virtual void didLayout() OVERRIDE;
84 // WebDevToolsAgent implementation.
85 virtual void attach(const WebString& hostId) OVERRIDE;
86 virtual void reattach(const WebString& hostId, const WebString& savedState) OVERRIDE;
87 virtual void detach() OVERRIDE;
88 virtual void continueProgram() OVERRIDE;
89 virtual void didBeginFrame(int frameId) OVERRIDE;
90 virtual void didCancelFrame() OVERRIDE;
91 virtual void willComposite() OVERRIDE;
92 virtual void didComposite() OVERRIDE;
93 virtual void dispatchOnInspectorBackend(const WebString& message) OVERRIDE;
94 virtual void inspectElementAt(const WebPoint&) OVERRIDE;
95 virtual void evaluateInWebInspector(long callId, const WebString& script) OVERRIDE;
96 virtual void setLayerTreeId(int) OVERRIDE;
97 virtual void processGPUEvent(const GPUEvent&) OVERRIDE;
99 // InspectorClient implementation.
100 virtual void highlight() OVERRIDE;
101 virtual void hideHighlight() OVERRIDE;
102 virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE;
103 virtual void sendMessageToFrontend(PassRefPtr<JSONObject> message) OVERRIDE;
104 virtual void flush() OVERRIDE;
105 virtual void resumeStartup() OVERRIDE;
107 virtual void setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool mobile, bool fitWindow, float scale, float offsetX, float offsetY) OVERRIDE;
108 virtual void clearDeviceMetricsOverride() OVERRIDE;
109 virtual void setTouchEventEmulationEnabled(bool) OVERRIDE;
111 virtual void setTraceEventCallback(const WTF::String& categoryFilter, TraceEventCallback) OVERRIDE;
112 virtual void resetTraceEventCallback() OVERRIDE;
113 virtual void enableTracing(const WTF::String& categoryFilter) OVERRIDE;
114 virtual void disableTracing() OVERRIDE;
116 virtual void startGPUEventsRecording() OVERRIDE;
117 virtual void stopGPUEventsRecording() OVERRIDE;
119 virtual void dispatchKeyEvent(const PlatformKeyboardEvent&) OVERRIDE;
120 virtual void dispatchMouseEvent(const PlatformMouseEvent&) OVERRIDE;
123 virtual void paintPageOverlay(WebCanvas*) OVERRIDE;
125 void flushPendingFrontendMessages();
128 // WebThread::TaskObserver
129 virtual void willProcessTask() OVERRIDE;
130 virtual void didProcessTask() OVERRIDE;
132 void enableMobileEmulation();
133 void disableMobileEmulation();
134 void updatePageScaleFactorLimits();
136 InspectorController* inspectorController();
137 LocalFrame* mainFrame();
141 WebDevToolsAgentClient* m_client;
142 WebViewImpl* m_webViewImpl;
144 bool m_generatingEvent;
146 bool m_webViewDidLayoutOnceAfterLoad;
148 bool m_deviceMetricsEnabled;
149 bool m_emulateMobileEnabled;
150 bool m_originalViewportEnabled;
151 bool m_isOverlayScrollbarsEnabled;
153 float m_originalMinimumPageScaleFactor;
154 float m_originalMaximumPageScaleFactor;
155 bool m_pageScaleLimitsOverriden;
157 bool m_touchEventEmulationEnabled;
158 OwnPtr<IntPoint> m_lastPinchAnchorCss;
159 OwnPtr<IntPoint> m_lastPinchAnchorDip;
161 typedef Vector<RefPtr<JSONObject> > FrontendMessageQueue;
162 FrontendMessageQueue m_frontendMessageQueue;