1 | /* |
2 | * Copyright (C) 2010, 2016 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_FAMILY) |
30 | |
31 | #include "WKAPICast.h" |
32 | #include "WebInspectorProxy.h" |
33 | #include "WebPageProxy.h" |
34 | |
35 | using namespace WebKit; |
36 | |
37 | WKTypeID WKInspectorGetTypeID() |
38 | { |
39 | return toAPI(WebInspectorProxy::APIType); |
40 | } |
41 | |
42 | WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef) |
43 | { |
44 | return toAPI(toImpl(inspectorRef)->inspectedPage()); |
45 | } |
46 | |
47 | bool WKInspectorIsConnected(WKInspectorRef inspectorRef) |
48 | { |
49 | return toImpl(inspectorRef)->isConnected(); |
50 | } |
51 | |
52 | bool WKInspectorIsVisible(WKInspectorRef inspectorRef) |
53 | { |
54 | return toImpl(inspectorRef)->isVisible(); |
55 | } |
56 | |
57 | bool WKInspectorIsFront(WKInspectorRef inspectorRef) |
58 | { |
59 | return toImpl(inspectorRef)->isFront(); |
60 | } |
61 | |
62 | void WKInspectorConnect(WKInspectorRef inspectorRef) |
63 | { |
64 | toImpl(inspectorRef)->connect(); |
65 | } |
66 | |
67 | void WKInspectorShow(WKInspectorRef inspectorRef) |
68 | { |
69 | toImpl(inspectorRef)->show(); |
70 | } |
71 | |
72 | void WKInspectorHide(WKInspectorRef inspectorRef) |
73 | { |
74 | toImpl(inspectorRef)->hide(); |
75 | } |
76 | |
77 | void WKInspectorClose(WKInspectorRef inspectorRef) |
78 | { |
79 | toImpl(inspectorRef)->close(); |
80 | } |
81 | |
82 | void WKInspectorShowConsole(WKInspectorRef inspectorRef) |
83 | { |
84 | toImpl(inspectorRef)->showConsole(); |
85 | } |
86 | |
87 | void WKInspectorShowResources(WKInspectorRef inspectorRef) |
88 | { |
89 | toImpl(inspectorRef)->showResources(); |
90 | } |
91 | |
92 | void WKInspectorShowMainResourceForFrame(WKInspectorRef inspectorRef, WKFrameRef frameRef) |
93 | { |
94 | toImpl(inspectorRef)->showMainResourceForFrame(toImpl(frameRef)); |
95 | } |
96 | |
97 | bool WKInspectorIsAttached(WKInspectorRef inspectorRef) |
98 | { |
99 | return toImpl(inspectorRef)->isAttached(); |
100 | } |
101 | |
102 | void WKInspectorAttach(WKInspectorRef inspectorRef) |
103 | { |
104 | auto inspector = toImpl(inspectorRef); |
105 | inspector->attach(inspector->attachmentSide()); |
106 | } |
107 | |
108 | void WKInspectorDetach(WKInspectorRef inspectorRef) |
109 | { |
110 | toImpl(inspectorRef)->detach(); |
111 | } |
112 | |
113 | bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef) |
114 | { |
115 | return toImpl(inspectorRef)->isProfilingPage(); |
116 | } |
117 | |
118 | void WKInspectorTogglePageProfiling(WKInspectorRef inspectorRef) |
119 | { |
120 | toImpl(inspectorRef)->showTimelines(); |
121 | toImpl(inspectorRef)->togglePageProfiling(); |
122 | } |
123 | |
124 | bool WKInspectorIsElementSelectionActive(WKInspectorRef inspectorRef) |
125 | { |
126 | return toImpl(inspectorRef)->isElementSelectionActive(); |
127 | } |
128 | |
129 | void WKInspectorToggleElementSelection(WKInspectorRef inspectorRef) |
130 | { |
131 | toImpl(inspectorRef)->toggleElementSelection(); |
132 | } |
133 | |
134 | #endif // !PLATFORM(IOS_FAMILY) |
135 | |