Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / InspectorClientImpl.cpp
1 /*
2  * Copyright (C) 2009 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 #include "config.h"
32 #include "web/InspectorClientImpl.h"
33
34 #include "core/frame/DOMWindow.h"
35 #include "core/frame/LocalFrame.h"
36 #include "core/frame/Settings.h"
37 #include "core/inspector/InspectorInstrumentation.h"
38 #include "core/page/Page.h"
39 #include "platform/JSONValues.h"
40 #include "platform/geometry/FloatRect.h"
41 #include "public/platform/WebRect.h"
42 #include "public/platform/WebURL.h"
43 #include "public/platform/WebURLRequest.h"
44 #include "public/web/WebViewClient.h"
45 #include "web/WebDevToolsAgentImpl.h"
46 #include "web/WebViewImpl.h"
47 #include "wtf/Vector.h"
48
49 using namespace WebCore;
50
51 namespace blink {
52
53 InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
54     : m_inspectedWebView(webView)
55 {
56     ASSERT(m_inspectedWebView);
57 }
58
59 InspectorClientImpl::~InspectorClientImpl()
60 {
61 }
62
63 void InspectorClientImpl::highlight()
64 {
65     if (WebDevToolsAgentImpl* agent = devToolsAgent())
66         agent->highlight();
67 }
68
69 void InspectorClientImpl::hideHighlight()
70 {
71     if (WebDevToolsAgentImpl* agent = devToolsAgent())
72         agent->hideHighlight();
73 }
74
75 void InspectorClientImpl::sendMessageToFrontend(PassRefPtr<WebCore::JSONObject> message)
76 {
77     if (WebDevToolsAgentImpl* agent = devToolsAgent())
78         agent->sendMessageToFrontend(message);
79 }
80
81 void InspectorClientImpl::flush()
82 {
83     if (WebDevToolsAgentImpl* agent = devToolsAgent())
84         agent->flush();
85 }
86
87 void InspectorClientImpl::updateInspectorStateCookie(const WTF::String& inspectorState)
88 {
89     if (WebDevToolsAgentImpl* agent = devToolsAgent())
90         agent->updateInspectorStateCookie(inspectorState);
91 }
92
93 void InspectorClientImpl::overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow)
94 {
95     if (WebDevToolsAgentImpl* agent = devToolsAgent())
96         agent->overrideDeviceMetrics(width, height, deviceScaleFactor, emulateViewport, fitWindow);
97 }
98
99 void InspectorClientImpl::setTouchEventEmulationEnabled(bool enabled)
100 {
101     if (WebDevToolsAgentImpl* agent = devToolsAgent())
102         agent->setTouchEventEmulationEnabled(enabled);
103 }
104
105 bool InspectorClientImpl::overridesShowPaintRects()
106 {
107     return m_inspectedWebView->isAcceleratedCompositingActive();
108 }
109
110 void InspectorClientImpl::setShowPaintRects(bool show)
111 {
112     m_inspectedWebView->setShowPaintRects(show);
113 }
114
115 void InspectorClientImpl::setShowDebugBorders(bool show)
116 {
117     m_inspectedWebView->setShowDebugBorders(show);
118 }
119
120 void InspectorClientImpl::setShowFPSCounter(bool show)
121 {
122     m_inspectedWebView->setShowFPSCounter(show);
123 }
124
125 void InspectorClientImpl::setContinuousPaintingEnabled(bool enabled)
126 {
127     m_inspectedWebView->setContinuousPaintingEnabled(enabled);
128 }
129
130 void InspectorClientImpl::setShowScrollBottleneckRects(bool show)
131 {
132     m_inspectedWebView->setShowScrollBottleneckRects(show);
133 }
134
135 void InspectorClientImpl::requestPageScaleFactor(float scale, const IntPoint& origin)
136 {
137     m_inspectedWebView->setPageScaleFactor(scale);
138     m_inspectedWebView->setMainFrameScrollOffset(origin);
139 }
140
141 void InspectorClientImpl::getAllocatedObjects(HashSet<const void*>& set)
142 {
143     if (WebDevToolsAgentImpl* agent = devToolsAgent())
144         agent->getAllocatedObjects(set);
145 }
146
147 void InspectorClientImpl::dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>& map)
148 {
149     if (WebDevToolsAgentImpl* agent = devToolsAgent())
150         agent->dumpUncountedAllocatedObjects(map);
151 }
152
153 void InspectorClientImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event)
154 {
155     if (WebDevToolsAgentImpl* agent = devToolsAgent())
156         agent->dispatchKeyEvent(event);
157 }
158
159 void InspectorClientImpl::dispatchMouseEvent(const PlatformMouseEvent& event)
160 {
161     if (WebDevToolsAgentImpl* agent = devToolsAgent())
162         agent->dispatchMouseEvent(event);
163 }
164
165 void InspectorClientImpl::setTraceEventCallback(const String& categoryFilter, TraceEventCallback callback)
166 {
167     if (WebDevToolsAgentImpl* agent = devToolsAgent())
168         agent->setTraceEventCallback(categoryFilter, callback);
169 }
170
171 void InspectorClientImpl::enableTracing(const String& categoryFilter)
172 {
173     if (WebDevToolsAgentImpl* agent = devToolsAgent())
174         agent->enableTracing(categoryFilter);
175 }
176
177 void InspectorClientImpl::disableTracing()
178 {
179     if (WebDevToolsAgentImpl* agent = devToolsAgent())
180         agent->disableTracing();
181 }
182
183 void InspectorClientImpl::resetTraceEventCallback()
184 {
185     if (WebDevToolsAgentImpl* agent = devToolsAgent())
186         agent->resetTraceEventCallback();
187 }
188
189 void InspectorClientImpl::startGPUEventsRecording()
190 {
191     if (WebDevToolsAgentImpl* agent = devToolsAgent())
192         agent->startGPUEventsRecording();
193 }
194
195 void InspectorClientImpl::stopGPUEventsRecording()
196 {
197     if (WebDevToolsAgentImpl* agent = devToolsAgent())
198         agent->stopGPUEventsRecording();
199 }
200
201 WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
202 {
203     return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
204 }
205
206 } // namespace blink