2 * Copyright (C) 2007 Apple 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
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "WebInspector.h"
32 #include "WebKitDLL.h"
34 #pragma warning(push, 0)
35 #include <WebCore/InspectorController.h>
36 #include <WebCore/Page.h>
38 #include <wtf/Assertions.h>
40 using namespace WebCore
;
42 WebInspector
* WebInspector::createInstance(WebView
* webView
)
44 WebInspector
* inspector
= new WebInspector(webView
);
49 WebInspector::WebInspector(WebView
* webView
)
53 ASSERT_ARG(webView
, webView
);
56 gClassNameCount
.add("WebInspector");
59 WebInspector::~WebInspector()
62 gClassNameCount
.remove("WebInspector");
65 void WebInspector::webViewClosed()
70 HRESULT STDMETHODCALLTYPE
WebInspector::QueryInterface(REFIID riid
, void** ppvObject
)
73 if (IsEqualGUID(riid
, IID_IWebInspector
))
74 *ppvObject
= static_cast<IWebInspector
*>(this);
75 else if (IsEqualGUID(riid
, IID_IWebInspectorPrivate
))
76 *ppvObject
= static_cast<IWebInspectorPrivate
*>(this);
77 else if (IsEqualGUID(riid
, IID_IUnknown
))
78 *ppvObject
= static_cast<IWebInspector
*>(this);
86 ULONG STDMETHODCALLTYPE
WebInspector::AddRef(void)
91 ULONG STDMETHODCALLTYPE
WebInspector::Release(void)
93 ULONG newRef
= --m_refCount
;
100 HRESULT STDMETHODCALLTYPE
WebInspector::show()
103 if (Page
* page
= m_webView
->page())
104 page
->inspectorController()->show();
109 HRESULT STDMETHODCALLTYPE
WebInspector::showConsole()
112 if (Page
* page
= m_webView
->page())
113 page
->inspectorController()->showPanel(InspectorController::ConsolePanel
);
118 HRESULT STDMETHODCALLTYPE
WebInspector::unused1()
123 HRESULT STDMETHODCALLTYPE
WebInspector::close()
126 if (Page
* page
= m_webView
->page())
127 page
->inspectorController()->close();
132 HRESULT STDMETHODCALLTYPE
WebInspector::attach()
135 if (Page
* page
= m_webView
->page())
136 page
->inspectorController()->attachWindow();
141 HRESULT STDMETHODCALLTYPE
WebInspector::detach()
144 if (Page
* page
= m_webView
->page())
145 page
->inspectorController()->detachWindow();
150 HRESULT STDMETHODCALLTYPE
WebInspector::isDebuggingJavaScript(BOOL
* isDebugging
)
155 *isDebugging
= FALSE
;
160 Page
* page
= m_webView
->page();
164 *isDebugging
= page
->inspectorController()->debuggerEnabled();
168 HRESULT STDMETHODCALLTYPE
WebInspector::toggleDebuggingJavaScript()
173 Page
* page
= m_webView
->page();
177 InspectorController
* inspector
= page
->inspectorController();
179 if (inspector
->debuggerEnabled())
180 inspector
->disableDebugger();
182 inspector
->showPanel(InspectorController::ScriptsPanel
);
183 inspector
->enableDebugger();
189 HRESULT STDMETHODCALLTYPE
WebInspector::isProfilingJavaScript(BOOL
* isProfiling
)
194 *isProfiling
= FALSE
;
199 Page
* page
= m_webView
->page();
203 *isProfiling
= page
->inspectorController()->isRecordingUserInitiatedProfile();
207 HRESULT STDMETHODCALLTYPE
WebInspector::toggleProfilingJavaScript()
212 Page
* page
= m_webView
->page();
216 InspectorController
* inspector
= page
->inspectorController();
218 if (inspector
->isRecordingUserInitiatedProfile()) {
219 inspector
->stopUserInitiatedProfiling();
220 inspector
->showPanel(InspectorController::ProfilesPanel
);
222 inspector
->startUserInitiatedProfiling();
227 HRESULT STDMETHODCALLTYPE
WebInspector::isJavaScriptProfilingEnabled(BOOL
* isProfilingEnabled
)
229 if (!isProfilingEnabled
)
232 *isProfilingEnabled
= FALSE
;
237 Page
* page
= m_webView
->page();
241 *isProfilingEnabled
= page
->inspectorController()->profilerEnabled();
245 HRESULT STDMETHODCALLTYPE
WebInspector::setJavaScriptProfilingEnabled(BOOL enabled
)
250 Page
* page
= m_webView
->page();
255 page
->inspectorController()->enableProfiler();
257 page
->inspectorController()->disableProfiler();
262 HRESULT STDMETHODCALLTYPE
WebInspector::evaluateInFrontend(ULONG callId
, BSTR bScript
)
267 Page
* page
= m_webView
->page();
271 String
script(bScript
, SysStringLen(bScript
));
272 page
->inspectorController()->evaluateForTestInFrontend(callId
, script
);
276 HRESULT STDMETHODCALLTYPE
WebInspector::isTimelineProfilingEnabled(BOOL
* isEnabled
)
286 Page
* page
= m_webView
->page();
290 *isEnabled
= page
->inspectorController()->timelineAgent() != 0;
294 HRESULT STDMETHODCALLTYPE
WebInspector::setTimelineProfilingEnabled(BOOL enabled
)
299 Page
* page
= m_webView
->page();
304 page
->inspectorController()->startTimelineProfiler();
306 page
->inspectorController()->stopTimelineProfiler();