2 * Copyright (C) 2009 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.
32 #include "web/InspectorClientImpl.h"
34 #include "core/frame/LocalDOMWindow.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"
50 InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
51 : m_inspectedWebView(webView)
53 ASSERT(m_inspectedWebView);
56 InspectorClientImpl::~InspectorClientImpl()
60 void InspectorClientImpl::highlight()
62 if (WebDevToolsAgentImpl* agent = devToolsAgent())
66 void InspectorClientImpl::hideHighlight()
68 if (WebDevToolsAgentImpl* agent = devToolsAgent())
69 agent->hideHighlight();
72 void InspectorClientImpl::sendMessageToFrontend(PassRefPtr<JSONObject> message)
74 if (WebDevToolsAgentImpl* agent = devToolsAgent())
75 agent->sendMessageToFrontend(message);
78 void InspectorClientImpl::flush()
80 if (WebDevToolsAgentImpl* agent = devToolsAgent())
84 void InspectorClientImpl::updateInspectorStateCookie(const WTF::String& inspectorState)
86 if (WebDevToolsAgentImpl* agent = devToolsAgent())
87 agent->updateInspectorStateCookie(inspectorState);
90 void InspectorClientImpl::setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool mobile, bool fitWindow, float scale, float offsetX, float offsetY)
92 if (WebDevToolsAgentImpl* agent = devToolsAgent())
93 agent->setDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, fitWindow, scale, offsetX, offsetY);
96 void InspectorClientImpl::clearDeviceMetricsOverride()
98 if (WebDevToolsAgentImpl* agent = devToolsAgent())
99 agent->clearDeviceMetricsOverride();
102 void InspectorClientImpl::setTouchEventEmulationEnabled(bool enabled)
104 if (WebDevToolsAgentImpl* agent = devToolsAgent())
105 agent->setTouchEventEmulationEnabled(enabled);
108 bool InspectorClientImpl::overridesShowPaintRects()
110 return m_inspectedWebView->isAcceleratedCompositingActive();
113 void InspectorClientImpl::setShowPaintRects(bool show)
115 m_inspectedWebView->setShowPaintRects(show);
118 void InspectorClientImpl::setShowDebugBorders(bool show)
120 m_inspectedWebView->setShowDebugBorders(show);
123 void InspectorClientImpl::setShowFPSCounter(bool show)
125 m_inspectedWebView->setShowFPSCounter(show);
128 void InspectorClientImpl::setContinuousPaintingEnabled(bool enabled)
130 m_inspectedWebView->setContinuousPaintingEnabled(enabled);
133 void InspectorClientImpl::setShowScrollBottleneckRects(bool show)
135 m_inspectedWebView->setShowScrollBottleneckRects(show);
138 void InspectorClientImpl::resetScrollAndPageScaleFactor()
140 m_inspectedWebView->resetScrollAndScaleState();
143 float InspectorClientImpl::minimumPageScaleFactor()
145 return m_inspectedWebView->minimumPageScaleFactor();
148 float InspectorClientImpl::maximumPageScaleFactor()
150 return m_inspectedWebView->maximumPageScaleFactor();
153 void InspectorClientImpl::setPageScaleFactor(float pageScaleFactor)
155 m_inspectedWebView->setPageScaleFactor(pageScaleFactor);
158 void InspectorClientImpl::showContextMenu(float x, float y, PassRefPtr<ContextMenuProvider> menuProvider)
160 m_inspectedWebView->showContextMenuAtPoint(x, y, menuProvider);
163 void InspectorClientImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event)
165 if (WebDevToolsAgentImpl* agent = devToolsAgent())
166 agent->dispatchKeyEvent(event);
169 void InspectorClientImpl::dispatchMouseEvent(const PlatformMouseEvent& event)
171 if (WebDevToolsAgentImpl* agent = devToolsAgent())
172 agent->dispatchMouseEvent(event);
175 void InspectorClientImpl::setTraceEventCallback(const String& categoryFilter, TraceEventCallback callback)
177 if (WebDevToolsAgentImpl* agent = devToolsAgent())
178 agent->setTraceEventCallback(categoryFilter, callback);
181 void InspectorClientImpl::enableTracing(const String& categoryFilter)
183 if (WebDevToolsAgentImpl* agent = devToolsAgent())
184 agent->enableTracing(categoryFilter);
187 void InspectorClientImpl::disableTracing()
189 if (WebDevToolsAgentImpl* agent = devToolsAgent())
190 agent->disableTracing();
193 void InspectorClientImpl::resetTraceEventCallback()
195 if (WebDevToolsAgentImpl* agent = devToolsAgent())
196 agent->resetTraceEventCallback();
199 void InspectorClientImpl::startGPUEventsRecording()
201 if (WebDevToolsAgentImpl* agent = devToolsAgent())
202 agent->startGPUEventsRecording();
205 void InspectorClientImpl::stopGPUEventsRecording()
207 if (WebDevToolsAgentImpl* agent = devToolsAgent())
208 agent->stopGPUEventsRecording();
211 void InspectorClientImpl::resumeStartup()
213 if (WebDevToolsAgentImpl* agent = devToolsAgent())
214 agent->resumeStartup();
217 WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
219 return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());