2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * 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.
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.
27 #ifndef WebInspectorProxy_h
28 #define WebInspectorProxy_h
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>
40 #include <wtf/RetainPtr.h>
43 OBJC_CLASS WKWebInspectorProxyObjCAdapter;
44 OBJC_CLASS WKWebInspectorWKView;
48 #include <WebCore/WindowMessageListener.h>
52 #include "WebInspectorClientGtk.h"
56 #include <Ecore_Evas.h>
65 struct WebPageCreationParameters;
71 class WebInspectorProxy : public APIObject
73 , public WebCore::WindowMessageListener
77 static const Type APIType = TypeInspector;
79 static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page)
81 return adoptRef(new WebInspectorProxy(page));
89 WebPageProxy* page() const { return m_page; }
91 bool isVisible() const { return m_isVisible; }
98 void createInspectorWindow();
99 void updateInspectorWindowTitle() const;
100 void inspectedViewFrameDidChange();
104 GtkWidget* inspectorView() const { return m_inspectorView; };
105 void initializeInspectorClientGtk(const WKInspectorClientGtk*);
109 void showResources();
110 void showMainResourceForFrame(WebFrameProxy*);
112 bool isAttached() const { return m_isAttached; }
115 void setAttachedWindowHeight(unsigned);
117 bool isDebuggingJavaScript() const { return m_isDebuggingJavaScript; }
118 void toggleJavaScriptDebugging();
120 bool isProfilingJavaScript() const { return m_isProfilingJavaScript; }
121 void toggleJavaScriptProfiling();
123 bool isProfilingPage() const { return m_isProfilingPage; }
124 void togglePageProfiling();
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>&);
132 static bool isInspectorPage(WebPageProxy*);
134 // Implemented the platform WebInspectorProxy file
135 String inspectorPageURL() const;
136 String inspectorBaseURL() const;
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; }
147 WebInspectorProxy(WebPageProxy* page);
149 virtual Type type() const { return APIType; }
151 WebPageProxy* platformCreateInspectorPage();
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);
162 // Called by WebInspectorProxy messages
163 void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
164 void didLoadInspectorPage();
167 void inspectedURLChanged(const String&);
169 #if ENABLE(INSPECTOR_SERVER)
170 void sendMessageToRemoteFrontend(const String& message);
174 bool shouldOpenAttached();
176 static WebPageGroup* inspectorPageGroup();
179 static bool registerInspectorViewWindowClass();
180 static LRESULT CALLBACK InspectorViewWndProc(HWND, UINT, WPARAM, LPARAM);
181 LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
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);
188 void onWebViewWindowPosChangingEvent(WPARAM, LPARAM);
189 virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
193 void createInspectorWindow();
196 static const unsigned minimumWindowWidth = 500;
197 static const unsigned minimumWindowHeight = 400;
199 static const unsigned initialWindowWidth = 750;
200 static const unsigned initialWindowHeight = 650;
202 // Keep this in sync with the value in InspectorFrontendClientLocal.
203 static const unsigned minimumAttachedHeight = 250;
205 WebPageProxy* m_page;
209 bool m_isDebuggingJavaScript;
210 bool m_isProfilingJavaScript;
211 bool m_isProfilingPage;
214 RetainPtr<WKWebInspectorWKView> m_inspectorView;
215 RetainPtr<NSWindow> m_inspectorWindow;
216 RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
219 HWND m_inspectorWindow;
220 RefPtr<WebView> m_inspectorView;
222 WebInspectorClientGtk m_client;
223 GtkWidget* m_inspectorView;
224 GtkWidget* m_inspectorWindow;
226 Evas_Object* m_inspectorView;
227 Ecore_Evas* m_inspectorWindow;
229 #if ENABLE(INSPECTOR_SERVER)
230 int m_remoteInspectionPageId;
234 } // namespace WebKit
236 #endif // ENABLE(INSPECTOR)
238 #endif // WebInspectorProxy_h