Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / WebDevToolsAgentImpl.h
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 blink {
46
47 class LocalFrame;
48 class InspectorClient;
49 class InspectorController;
50 class Page;
51 class PlatformKeyboardEvent;
52 class WebDevToolsAgentClient;
53 class WebLocalFrameImpl;
54 class WebString;
55 class WebViewImpl;
56
57 class WebDevToolsAgentImpl final
58     : public WebDevToolsAgentPrivate
59     , public InspectorClient
60     , public InspectorFrontendChannel
61     , public WebPageOverlay
62     , private WebThread::TaskObserver {
63 public:
64     WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client);
65     virtual ~WebDevToolsAgentImpl();
66
67     WebDevToolsAgentClient* client() { return m_client; }
68
69     // WebDevToolsAgentPrivate implementation.
70     virtual void didCreateScriptContext(WebLocalFrameImpl*, int worldId) override;
71     virtual bool handleInputEvent(Page*, const WebInputEvent&) override;
72     virtual void didLayout() override;
73
74     // WebDevToolsAgent implementation.
75     virtual void attach(const WebString& hostId) override;
76     virtual void reattach(const WebString& hostId, const WebString& savedState) override;
77     virtual void detach() override;
78     virtual void continueProgram() override;
79     virtual void didBeginFrame(int frameId) override;
80     virtual void didCancelFrame() override;
81     virtual void willComposite() override;
82     virtual void didComposite() override;
83     virtual void dispatchOnInspectorBackend(const WebString& message) override;
84     virtual void inspectElementAt(const WebPoint&) override;
85     virtual void evaluateInWebInspector(long callId, const WebString& script) override;
86     virtual void setLayerTreeId(int) override;
87     virtual void processGPUEvent(const GPUEvent&) override;
88
89     // InspectorClient implementation.
90     virtual void highlight() override;
91     virtual void hideHighlight() override;
92     virtual void updateInspectorStateCookie(const WTF::String&) override;
93     virtual void sendMessageToFrontend(PassRefPtr<JSONObject> message) override;
94     virtual void flush() override;
95     virtual void resumeStartup() override;
96
97     virtual void setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool mobile, bool fitWindow, float scale, float offsetX, float offsetY) override;
98     virtual void clearDeviceMetricsOverride() override;
99     virtual void setTouchEventEmulationEnabled(bool) override;
100
101     virtual void setTraceEventCallback(const WTF::String& categoryFilter, TraceEventCallback) override;
102     virtual void resetTraceEventCallback() override;
103     virtual void enableTracing(const WTF::String& categoryFilter) override;
104     virtual void disableTracing() override;
105
106     virtual void startGPUEventsRecording() override;
107     virtual void stopGPUEventsRecording() override;
108
109     virtual void dispatchKeyEvent(const PlatformKeyboardEvent&) override;
110     virtual void dispatchMouseEvent(const PlatformMouseEvent&) override;
111
112     // WebPageOverlay
113     virtual void paintPageOverlay(WebCanvas*) override;
114
115     void flushPendingFrontendMessages();
116
117 private:
118     // WebThread::TaskObserver
119     virtual void willProcessTask() override;
120     virtual void didProcessTask() override;
121
122     void enableMobileEmulation();
123     void disableMobileEmulation();
124     void updatePageScaleFactorLimits();
125
126     InspectorController* inspectorController();
127     LocalFrame* mainFrame();
128
129     int m_debuggerId;
130     int m_layerTreeId;
131     WebDevToolsAgentClient* m_client;
132     WebViewImpl* m_webViewImpl;
133     bool m_attached;
134     bool m_generatingEvent;
135
136     bool m_webViewDidLayoutOnceAfterLoad;
137
138     bool m_deviceMetricsEnabled;
139     bool m_emulateMobileEnabled;
140     bool m_originalViewportEnabled;
141     bool m_isOverlayScrollbarsEnabled;
142
143     float m_originalMinimumPageScaleFactor;
144     float m_originalMaximumPageScaleFactor;
145     bool m_pageScaleLimitsOverriden;
146
147     bool m_touchEventEmulationEnabled;
148     OwnPtr<IntPoint> m_lastPinchAnchorCss;
149     OwnPtr<IntPoint> m_lastPinchAnchorDip;
150
151     typedef Vector<RefPtr<JSONObject> > FrontendMessageQueue;
152     FrontendMessageQueue m_frontendMessageQueue;
153 };
154
155 } // namespace blink
156
157 #endif