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/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"
49 using namespace WebCore;
53 InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
54 : m_inspectedWebView(webView)
56 ASSERT(m_inspectedWebView);
59 InspectorClientImpl::~InspectorClientImpl()
63 void InspectorClientImpl::highlight()
65 if (WebDevToolsAgentImpl* agent = devToolsAgent())
69 void InspectorClientImpl::hideHighlight()
71 if (WebDevToolsAgentImpl* agent = devToolsAgent())
72 agent->hideHighlight();
75 void InspectorClientImpl::sendMessageToFrontend(PassRefPtr<WebCore::JSONObject> message)
77 if (WebDevToolsAgentImpl* agent = devToolsAgent())
78 agent->sendMessageToFrontend(message);
81 void InspectorClientImpl::flush()
83 if (WebDevToolsAgentImpl* agent = devToolsAgent())
87 void InspectorClientImpl::updateInspectorStateCookie(const WTF::String& inspectorState)
89 if (WebDevToolsAgentImpl* agent = devToolsAgent())
90 agent->updateInspectorStateCookie(inspectorState);
93 void InspectorClientImpl::overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow)
95 if (WebDevToolsAgentImpl* agent = devToolsAgent())
96 agent->overrideDeviceMetrics(width, height, deviceScaleFactor, emulateViewport, fitWindow);
99 void InspectorClientImpl::setTouchEventEmulationEnabled(bool enabled)
101 if (WebDevToolsAgentImpl* agent = devToolsAgent())
102 agent->setTouchEventEmulationEnabled(enabled);
105 bool InspectorClientImpl::overridesShowPaintRects()
107 return m_inspectedWebView->isAcceleratedCompositingActive();
110 void InspectorClientImpl::setShowPaintRects(bool show)
112 m_inspectedWebView->setShowPaintRects(show);
115 void InspectorClientImpl::setShowDebugBorders(bool show)
117 m_inspectedWebView->setShowDebugBorders(show);
120 void InspectorClientImpl::setShowFPSCounter(bool show)
122 m_inspectedWebView->setShowFPSCounter(show);
125 void InspectorClientImpl::setContinuousPaintingEnabled(bool enabled)
127 m_inspectedWebView->setContinuousPaintingEnabled(enabled);
130 void InspectorClientImpl::setShowScrollBottleneckRects(bool show)
132 m_inspectedWebView->setShowScrollBottleneckRects(show);
135 void InspectorClientImpl::requestPageScaleFactor(float scale, const IntPoint& origin)
137 m_inspectedWebView->setPageScaleFactor(scale);
138 m_inspectedWebView->setMainFrameScrollOffset(origin);
141 void InspectorClientImpl::getAllocatedObjects(HashSet<const void*>& set)
143 if (WebDevToolsAgentImpl* agent = devToolsAgent())
144 agent->getAllocatedObjects(set);
147 void InspectorClientImpl::dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>& map)
149 if (WebDevToolsAgentImpl* agent = devToolsAgent())
150 agent->dumpUncountedAllocatedObjects(map);
153 void InspectorClientImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event)
155 if (WebDevToolsAgentImpl* agent = devToolsAgent())
156 agent->dispatchKeyEvent(event);
159 void InspectorClientImpl::dispatchMouseEvent(const PlatformMouseEvent& event)
161 if (WebDevToolsAgentImpl* agent = devToolsAgent())
162 agent->dispatchMouseEvent(event);
165 void InspectorClientImpl::setTraceEventCallback(const String& categoryFilter, TraceEventCallback callback)
167 if (WebDevToolsAgentImpl* agent = devToolsAgent())
168 agent->setTraceEventCallback(categoryFilter, callback);
171 void InspectorClientImpl::enableTracing(const String& categoryFilter)
173 if (WebDevToolsAgentImpl* agent = devToolsAgent())
174 agent->enableTracing(categoryFilter);
177 void InspectorClientImpl::disableTracing()
179 if (WebDevToolsAgentImpl* agent = devToolsAgent())
180 agent->disableTracing();
183 void InspectorClientImpl::resetTraceEventCallback()
185 if (WebDevToolsAgentImpl* agent = devToolsAgent())
186 agent->resetTraceEventCallback();
189 void InspectorClientImpl::startGPUEventsRecording()
191 if (WebDevToolsAgentImpl* agent = devToolsAgent())
192 agent->startGPUEventsRecording();
195 void InspectorClientImpl::stopGPUEventsRecording()
197 if (WebDevToolsAgentImpl* agent = devToolsAgent())
198 agent->stopGPUEventsRecording();
201 WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
203 return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());