Merge "Use EwkView's variables instead of drawingScaleFactor and drawingScrollPositio...
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / WebInspectorProxy.h
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #ifndef WebInspectorProxy_h
28 #define WebInspectorProxy_h
29
30 #if ENABLE(INSPECTOR)
31
32 #include "APIObject.h"
33 #include "Connection.h"
34 #include <wtf/Forward.h>
35 #include <wtf/PassRefPtr.h>
36 #include <wtf/RefPtr.h>
37 #include <wtf/text/WTFString.h>
38
39 #if PLATFORM(MAC)
40 #include <wtf/RetainPtr.h>
41
42 OBJC_CLASS NSWindow;
43 OBJC_CLASS WKWebInspectorProxyObjCAdapter;
44 OBJC_CLASS WKWebInspectorWKView;
45 #endif
46
47 #if PLATFORM(WIN)
48 #include <WebCore/WindowMessageListener.h>
49 #endif
50
51 #if PLATFORM(GTK)
52 #include "WebInspectorClientGtk.h"
53 #endif
54
55 #if PLATFORM(EFL)
56 #include <Ecore_Evas.h>
57 #include <Evas.h>
58 #endif
59
60 namespace WebKit {
61
62 class WebFrameProxy;
63 class WebPageGroup;
64 class WebPageProxy;
65 struct WebPageCreationParameters;
66
67 #if PLATFORM(WIN)
68 class WebView;
69 #endif
70
71 class WebInspectorProxy : public APIObject
72 #if PLATFORM(WIN)
73     , public WebCore::WindowMessageListener
74 #endif
75 {
76 public:
77     static const Type APIType = TypeInspector;
78
79     static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page)
80     {
81         return adoptRef(new WebInspectorProxy(page));
82     }
83
84     ~WebInspectorProxy();
85
86     void invalidate();
87
88     // Public APIs
89     WebPageProxy* page() const { return m_page; }
90
91     bool isVisible() const { return m_isVisible; }
92     bool isFront();
93
94     void show();
95     void close();
96     
97 #if PLATFORM(MAC)
98     void createInspectorWindow();
99     void updateInspectorWindowTitle() const;
100     void inspectedViewFrameDidChange();
101 #endif
102
103 #if PLATFORM(GTK)
104     GtkWidget* inspectorView() const { return m_inspectorView; };
105     void initializeInspectorClientGtk(const WKInspectorClientGtk*);
106 #endif
107
108     void showConsole();
109     void showResources();
110     void showMainResourceForFrame(WebFrameProxy*);
111
112     bool isAttached() const { return m_isAttached; }
113     void attach();
114     void detach();
115     void setAttachedWindowHeight(unsigned);
116
117     bool isDebuggingJavaScript() const { return m_isDebuggingJavaScript; }
118     void toggleJavaScriptDebugging();
119
120     bool isProfilingJavaScript() const { return m_isProfilingJavaScript; }
121     void toggleJavaScriptProfiling();
122
123     bool isProfilingPage() const { return m_isProfilingPage; }
124     void togglePageProfiling();
125
126 #if ENABLE(INSPECTOR)
127     // Implemented in generated WebInspectorProxyMessageReceiver.cpp
128     void didReceiveWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
129     void didReceiveSyncWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
130 #endif
131
132     static bool isInspectorPage(WebPageProxy*);
133
134     // Implemented the platform WebInspectorProxy file
135     String inspectorPageURL() const;
136     String inspectorBaseURL() const;
137
138 #if ENABLE(INSPECTOR_SERVER)
139     void enableRemoteInspection();
140     void remoteFrontendConnected();
141     void remoteFrontendDisconnected();
142     void dispatchMessageFromRemoteFrontend(const String& message);
143     int remoteInspectionPageID() const { return m_remoteInspectionPageId; }
144 #endif
145
146 private:
147     WebInspectorProxy(WebPageProxy* page);
148
149     virtual Type type() const { return APIType; }
150
151     WebPageProxy* platformCreateInspectorPage();
152     void platformOpen();
153     void platformDidClose();
154     void platformBringToFront();
155     bool platformIsFront();
156     void platformInspectedURLChanged(const String&);
157     unsigned platformInspectedWindowHeight();
158     void platformAttach();
159     void platformDetach();
160     void platformSetAttachedWindowHeight(unsigned);
161
162     // Called by WebInspectorProxy messages
163     void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
164     void didLoadInspectorPage();
165     void didClose();
166     void bringToFront();
167     void inspectedURLChanged(const String&);
168
169 #if ENABLE(INSPECTOR_SERVER)
170     void sendMessageToRemoteFrontend(const String& message);
171 #endif
172
173     bool canAttach();
174     bool shouldOpenAttached();
175
176     static WebPageGroup* inspectorPageGroup();
177
178 #if PLATFORM(WIN)
179     static bool registerInspectorViewWindowClass();
180     static LRESULT CALLBACK InspectorViewWndProc(HWND, UINT, WPARAM, LPARAM);
181     LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
182
183     LRESULT onSizeEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
184     LRESULT onMinMaxInfoEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
185     LRESULT onSetFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
186     LRESULT onCloseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
187
188     void onWebViewWindowPosChangingEvent(WPARAM, LPARAM);
189     virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
190 #endif
191
192 #if PLATFORM(GTK)
193     void createInspectorWindow();
194 #endif
195
196     static const unsigned minimumWindowWidth = 500;
197     static const unsigned minimumWindowHeight = 400;
198
199     static const unsigned initialWindowWidth = 750;
200     static const unsigned initialWindowHeight = 650;
201
202     // Keep this in sync with the value in InspectorFrontendClientLocal.
203     static const unsigned minimumAttachedHeight = 250;
204
205     WebPageProxy* m_page;
206
207     bool m_isVisible;
208     bool m_isAttached;
209     bool m_isDebuggingJavaScript;
210     bool m_isProfilingJavaScript;
211     bool m_isProfilingPage;
212
213 #if PLATFORM(MAC)
214     RetainPtr<WKWebInspectorWKView> m_inspectorView;
215     RetainPtr<NSWindow> m_inspectorWindow;
216     RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
217     String m_urlString;
218 #elif PLATFORM(WIN)
219     HWND m_inspectorWindow;
220     RefPtr<WebView> m_inspectorView;
221 #elif PLATFORM(GTK)
222     WebInspectorClientGtk m_client;
223     GtkWidget* m_inspectorView;
224     GtkWidget* m_inspectorWindow;
225 #elif PLATFORM(EFL)
226     Evas_Object* m_inspectorView;
227     Ecore_Evas* m_inspectorWindow;
228 #endif
229 #if ENABLE(INSPECTOR_SERVER)
230     int m_remoteInspectionPageId;
231 #endif
232 };
233
234 } // namespace WebKit
235
236 #endif // ENABLE(INSPECTOR)
237
238 #endif // WebInspectorProxy_h