blob: 42521e37adb6af95f1c4bee881a0e5a87751f2bf [file] [log] [blame]
Ben Murdoche69819b2013-07-17 14:56:49 +01001/*
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 "InspectorClientImpl.h"
33
34#include "WebDevToolsAgentImpl.h"
35#include "WebViewClient.h"
36#include "WebViewImpl.h"
37#include "core/inspector/InspectorInstrumentation.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010038#include "core/frame/DOMWindow.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010039#include "core/page/Page.h"
Torne (Richard Coles)09380292014-02-21 12:17:33 +000040#include "core/frame/Settings.h"
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000041#include "platform/JSONValues.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010042#include "platform/geometry/FloatRect.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010043#include "public/platform/WebRect.h"
44#include "public/platform/WebURL.h"
45#include "public/platform/WebURLRequest.h"
46#include "wtf/Vector.h"
47
48using namespace WebCore;
49
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000050namespace blink {
Ben Murdoche69819b2013-07-17 14:56:49 +010051
52InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
53 : m_inspectedWebView(webView)
54{
55 ASSERT(m_inspectedWebView);
56}
57
58InspectorClientImpl::~InspectorClientImpl()
59{
60}
61
62void InspectorClientImpl::highlight()
63{
64 if (WebDevToolsAgentImpl* agent = devToolsAgent())
65 agent->highlight();
66}
67
68void InspectorClientImpl::hideHighlight()
69{
70 if (WebDevToolsAgentImpl* agent = devToolsAgent())
71 agent->hideHighlight();
72}
73
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000074void InspectorClientImpl::sendMessageToFrontend(PassRefPtr<WebCore::JSONObject> message)
Ben Murdoche69819b2013-07-17 14:56:49 +010075{
76 if (WebDevToolsAgentImpl* agent = devToolsAgent())
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000077 agent->sendMessageToFrontend(message);
78}
79
80void InspectorClientImpl::flush()
81{
82 if (WebDevToolsAgentImpl* agent = devToolsAgent())
83 agent->flush();
Ben Murdoche69819b2013-07-17 14:56:49 +010084}
85
86void InspectorClientImpl::updateInspectorStateCookie(const WTF::String& inspectorState)
87{
88 if (WebDevToolsAgentImpl* agent = devToolsAgent())
89 agent->updateInspectorStateCookie(inspectorState);
90}
91
92void InspectorClientImpl::clearBrowserCache()
93{
94 if (WebDevToolsAgentImpl* agent = devToolsAgent())
95 agent->clearBrowserCache();
96}
97
98void InspectorClientImpl::clearBrowserCookies()
99{
100 if (WebDevToolsAgentImpl* agent = devToolsAgent())
101 agent->clearBrowserCookies();
102}
103
Torne (Richard Coles)19cde672013-11-06 12:28:04 +0000104void InspectorClientImpl::overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow)
Ben Murdoche69819b2013-07-17 14:56:49 +0100105{
106 if (WebDevToolsAgentImpl* agent = devToolsAgent())
Torne (Richard Coles)19cde672013-11-06 12:28:04 +0000107 agent->overrideDeviceMetrics(width, height, deviceScaleFactor, emulateViewport, fitWindow);
Ben Murdoche69819b2013-07-17 14:56:49 +0100108}
109
110bool InspectorClientImpl::overridesShowPaintRects()
111{
112 return m_inspectedWebView->isAcceleratedCompositingActive();
113}
114
115void InspectorClientImpl::setShowPaintRects(bool show)
116{
117 m_inspectedWebView->setShowPaintRects(show);
118}
119
120void InspectorClientImpl::setShowDebugBorders(bool show)
121{
122 m_inspectedWebView->setShowDebugBorders(show);
123}
124
125void InspectorClientImpl::setShowFPSCounter(bool show)
126{
127 m_inspectedWebView->setShowFPSCounter(show);
128}
129
130void InspectorClientImpl::setContinuousPaintingEnabled(bool enabled)
131{
132 m_inspectedWebView->setContinuousPaintingEnabled(enabled);
133}
134
135void InspectorClientImpl::setShowScrollBottleneckRects(bool show)
136{
137 m_inspectedWebView->setShowScrollBottleneckRects(show);
138}
139
Torne (Richard Coles)19cde672013-11-06 12:28:04 +0000140void InspectorClientImpl::requestPageScaleFactor(float scale, const IntPoint& origin)
141{
142 m_inspectedWebView->setPageScaleFactor(scale, origin);
143}
144
Ben Murdoche69819b2013-07-17 14:56:49 +0100145void InspectorClientImpl::getAllocatedObjects(HashSet<const void*>& set)
146{
147 if (WebDevToolsAgentImpl* agent = devToolsAgent())
148 agent->getAllocatedObjects(set);
149}
150
151void InspectorClientImpl::dumpUncountedAllocatedObjects(const HashMap<const void*, size_t>& map)
152{
153 if (WebDevToolsAgentImpl* agent = devToolsAgent())
154 agent->dumpUncountedAllocatedObjects(map);
155}
156
157void InspectorClientImpl::dispatchKeyEvent(const PlatformKeyboardEvent& event)
158{
159 if (WebDevToolsAgentImpl* agent = devToolsAgent())
160 agent->dispatchKeyEvent(event);
161}
162
163void InspectorClientImpl::dispatchMouseEvent(const PlatformMouseEvent& event)
164{
165 if (WebDevToolsAgentImpl* agent = devToolsAgent())
166 agent->dispatchMouseEvent(event);
167}
168
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000169void InspectorClientImpl::setTraceEventCallback(const String& categoryFilter, TraceEventCallback callback)
Ben Murdoche69819b2013-07-17 14:56:49 +0100170{
171 if (WebDevToolsAgentImpl* agent = devToolsAgent())
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000172 agent->setTraceEventCallback(categoryFilter, callback);
173}
174
175void InspectorClientImpl::resetTraceEventCallback()
176{
177 if (WebDevToolsAgentImpl* agent = devToolsAgent())
178 agent->resetTraceEventCallback();
Ben Murdoche69819b2013-07-17 14:56:49 +0100179}
180
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000181void InspectorClientImpl::startGPUEventsRecording()
182{
183 if (WebDevToolsAgentImpl* agent = devToolsAgent())
184 agent->startGPUEventsRecording();
185}
186
187void InspectorClientImpl::stopGPUEventsRecording()
188{
189 if (WebDevToolsAgentImpl* agent = devToolsAgent())
190 agent->stopGPUEventsRecording();
191}
192
Ben Murdoche69819b2013-07-17 14:56:49 +0100193WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
194{
195 return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
196}
197
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000198} // namespace blink