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 #ifndef WebInspectorProxy_h 27 #define WebInspectorProxy_h 28 29 #if ENABLE(INSPECTOR) 30 31 #include "APIObject.h" 32 #include "Connection.h" 33 #include <wtf/Forward.h> 34 #include <wtf/PassRefPtr.h> 35 #include <wtf/RefPtr.h> 36 37 #if PLATFORM(MAC) 38 #include <wtf/RetainPtr.h> 39 40 OBJC_CLASS NSWindow; 41 OBJC_CLASS WKView; 42 OBJC_CLASS WebInspectorProxyObjCAdapter; 43 #endif 44 45 namespace WebKit { 46 47 class WebPageGroup; 48 class WebPageProxy; 49 struct WebPageCreationParameters; 50 51 #if PLATFORM(WIN) 52 class WebView; 53 #endif 54 55 class WebInspectorProxy : public APIObject { 56 public: 57 static const Type APIType = TypeInspector; 58 59 static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page) 60 { 61 return adoptRef(new WebInspectorProxy(page)); 62 } 63 64 ~WebInspectorProxy(); 65 66 void invalidate(); 67 68 // Public APIs 69 WebPageProxy* page() { return m_page; } 70 71 bool isVisible() const { return m_isVisible; } 72 void show(); 73 void close(); 74 75 void showConsole(); 76 77 bool isAttached() const { return m_isAttached; } 78 void attach(); 79 void detach(); 80 81 bool isDebuggingJavaScript() const { return m_isDebuggingJavaScript; } 82 void toggleJavaScriptDebugging(); 83 84 bool isProfilingJavaScript() const { return m_isProfilingJavaScript; } 85 void toggleJavaScriptProfiling(); 86 87 bool isProfilingPage() const { return m_isProfilingPage; } 88 void togglePageProfiling(); 89 90 #if ENABLE(INSPECTOR) 91 // Implemented in generated WebInspectorProxyMessageReceiver.cpp 92 void didReceiveWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 93 CoreIPC::SyncReplyMode didReceiveSyncWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); 94 #endif 95 96 static bool isInspectorPage(WebPageProxy*); 97 98 private: 99 WebInspectorProxy(WebPageProxy* page); 100 101 virtual Type type() const { return APIType; } 102 103 WebPageProxy* platformCreateInspectorPage(); 104 void platformOpen(); 105 void platformClose(); 106 void platformInspectedURLChanged(const String&); 107 108 // Implemented the platform WebInspectorProxy file 109 String inspectorPageURL() const; 110 111 // Called by WebInspectorProxy messages 112 void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&); 113 void didLoadInspectorPage(); 114 void didClose(); 115 void inspectedURLChanged(const String&); 116 117 static WebPageGroup* inspectorPageGroup(); 118 119 #if PLATFORM(WIN) 120 static bool registerInspectorViewWindowClass(); 121 static LRESULT CALLBACK InspectorViewWndProc(HWND, UINT, WPARAM, LPARAM); 122 LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 123 124 LRESULT onSizeEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); 125 LRESULT onMinMaxInfoEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); 126 LRESULT onSetFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); 127 LRESULT onCloseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); 128 #endif 129 130 static const unsigned minimumWindowWidth = 500; 131 static const unsigned minimumWindowHeight = 400; 132 133 static const unsigned initialWindowWidth = 750; 134 static const unsigned initialWindowHeight = 650; 135 136 WebPageProxy* m_page; 137 138 bool m_isVisible; 139 bool m_isAttached; 140 bool m_isDebuggingJavaScript; 141 bool m_isProfilingJavaScript; 142 bool m_isProfilingPage; 143 144 #if PLATFORM(MAC) 145 RetainPtr<WKView> m_inspectorView; 146 RetainPtr<NSWindow> m_inspectorWindow; 147 RetainPtr<WebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter; 148 #elif PLATFORM(WIN) 149 HWND m_inspectorWindow; 150 RefPtr<WebView> m_inspectorView; 151 #endif 152 }; 153 154 } // namespace WebKit 155 156 #endif // ENABLE(INSPECTOR) 157 158 #endif // WebInspectorProxy_h 159