1/*
2 * Copyright (C) 2010 Apple 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
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "WKInspector.h"
28
29#if !PLATFORM(IOS)
30
31#include "WKAPICast.h"
32#include "WebInspectorProxy.h"
33
34using namespace WebKit;
35
36WKTypeID WKInspectorGetTypeID()
37{
38#if ENABLE(INSPECTOR)
39    return toAPI(WebInspectorProxy::APIType);
40#else
41    return 0;
42#endif
43}
44
45WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef)
46{
47#if ENABLE(INSPECTOR)
48    return toAPI(toImpl(inspectorRef)->page());
49#else
50    UNUSED_PARAM(inspectorRef);
51    return 0;
52#endif
53}
54
55bool WKInspectorIsConnected(WKInspectorRef inspectorRef)
56{
57#if ENABLE(INSPECTOR)
58    return toImpl(inspectorRef)->isConnected();
59#else
60    UNUSED_PARAM(inspectorRef);
61    return false;
62#endif
63}
64
65bool WKInspectorIsVisible(WKInspectorRef inspectorRef)
66{
67#if ENABLE(INSPECTOR)
68    return toImpl(inspectorRef)->isVisible();
69#else
70    UNUSED_PARAM(inspectorRef);
71    return false;
72#endif
73}
74
75bool WKInspectorIsFront(WKInspectorRef inspectorRef)
76{
77#if ENABLE(INSPECTOR)
78    return toImpl(inspectorRef)->isFront();
79#else
80    UNUSED_PARAM(inspectorRef);
81    return false;
82#endif
83}
84
85void WKInspectorConnect(WKInspectorRef inspectorRef)
86{
87#if ENABLE(INSPECTOR)
88    toImpl(inspectorRef)->connect();
89#else
90    UNUSED_PARAM(inspectorRef);
91#endif
92}
93
94void WKInspectorShow(WKInspectorRef inspectorRef)
95{
96#if ENABLE(INSPECTOR)
97    toImpl(inspectorRef)->show();
98#else
99    UNUSED_PARAM(inspectorRef);
100#endif
101}
102
103void WKInspectorHide(WKInspectorRef inspectorRef)
104{
105#if ENABLE(INSPECTOR)
106    toImpl(inspectorRef)->hide();
107#else
108    UNUSED_PARAM(inspectorRef);
109#endif
110}
111
112void WKInspectorClose(WKInspectorRef inspectorRef)
113{
114#if ENABLE(INSPECTOR)
115    toImpl(inspectorRef)->close();
116#else
117    UNUSED_PARAM(inspectorRef);
118#endif
119}
120
121void WKInspectorShowConsole(WKInspectorRef inspectorRef)
122{
123#if ENABLE(INSPECTOR)
124    toImpl(inspectorRef)->showConsole();
125#else
126    UNUSED_PARAM(inspectorRef);
127#endif
128}
129
130void WKInspectorShowResources(WKInspectorRef inspectorRef)
131{
132#if ENABLE(INSPECTOR)
133    toImpl(inspectorRef)->showResources();
134#else
135    UNUSED_PARAM(inspectorRef);
136#endif
137}
138
139void WKInspectorShowMainResourceForFrame(WKInspectorRef inspectorRef, WKFrameRef frameRef)
140{
141#if ENABLE(INSPECTOR)
142    toImpl(inspectorRef)->showMainResourceForFrame(toImpl(frameRef));
143#else
144    UNUSED_PARAM(inspectorRef);
145    UNUSED_PARAM(frameRef);
146#endif
147}
148
149bool WKInspectorIsAttached(WKInspectorRef inspectorRef)
150{
151#if ENABLE(INSPECTOR)
152    return toImpl(inspectorRef)->isAttached();
153#else
154    UNUSED_PARAM(inspectorRef);
155    return false;
156#endif
157}
158
159void WKInspectorAttach(WKInspectorRef inspectorRef)
160{
161#if ENABLE(INSPECTOR)
162    toImpl(inspectorRef)->attach();
163#else
164    UNUSED_PARAM(inspectorRef);
165#endif
166}
167
168void WKInspectorDetach(WKInspectorRef inspectorRef)
169{
170#if ENABLE(INSPECTOR)
171    toImpl(inspectorRef)->detach();
172#else
173    UNUSED_PARAM(inspectorRef);
174#endif
175}
176
177bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspectorRef)
178{
179#if ENABLE(INSPECTOR)
180    return toImpl(inspectorRef)->isDebuggingJavaScript();
181#else
182    UNUSED_PARAM(inspectorRef);
183    return false;
184#endif
185}
186
187void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspectorRef)
188{
189#if ENABLE(INSPECTOR)
190    toImpl(inspectorRef)->toggleJavaScriptDebugging();
191#else
192    UNUSED_PARAM(inspectorRef);
193#endif
194}
195
196bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspectorRef)
197{
198#if ENABLE(INSPECTOR)
199    return toImpl(inspectorRef)->isProfilingJavaScript();
200#else
201    UNUSED_PARAM(inspectorRef);
202    return false;
203#endif
204}
205
206void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspectorRef)
207{
208#if ENABLE(INSPECTOR)
209    toImpl(inspectorRef)->toggleJavaScriptProfiling();
210#else
211    UNUSED_PARAM(inspectorRef);
212#endif
213}
214
215bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef)
216{
217#if ENABLE(INSPECTOR)
218    return toImpl(inspectorRef)->isProfilingPage();
219#else
220    UNUSED_PARAM(inspectorRef);
221    return false;
222#endif
223}
224
225void WKInspectorTogglePageProfiling(WKInspectorRef inspectorRef)
226{
227#if ENABLE(INSPECTOR)
228    toImpl(inspectorRef)->togglePageProfiling();
229#else
230    UNUSED_PARAM(inspectorRef);
231#endif
232}
233
234#endif // !PLATFORM(IOS)
235