1 /* 2 * Copyright (C) 2006, 2007 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 * 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 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef WebInspectorClient_h 30 #define WebInspectorClient_h 31 32 #include <WebCore/COMPtr.h> 33 #include <WebCore/InspectorClient.h> 34 #include <WebCore/InspectorFrontendClientLocal.h> 35 #include <WebCore/PlatformString.h> 36 #include <WebCore/WindowMessageListener.h> 37 #include <wtf/Forward.h> 38 #include <wtf/HashMap.h> 39 #include <wtf/OwnPtr.h> 40 #include <wtf/text/StringHash.h> 41 #include <windows.h> 42 43 namespace WebCore { 44 45 class Page; 46 47 } 48 49 class WebNodeHighlight; 50 class WebView; 51 52 class WebInspectorClient : public WebCore::InspectorClient { 53 public: 54 WebInspectorClient(WebView*); 55 56 // InspectorClient 57 virtual void inspectorDestroyed(); 58 59 virtual void openInspectorFrontend(WebCore::InspectorController*); 60 61 virtual void highlight(WebCore::Node*); 62 virtual void hideHighlight(); 63 64 virtual bool sendMessageToFrontend(const WTF::String&); 65 66 bool inspectorStartsAttached(); 67 void setInspectorStartsAttached(bool); 68 69 void releaseFrontendPage(); 70 71 void updateHighlight(); 72 void frontendClosing() 73 { 74 m_frontendHwnd = 0; 75 releaseFrontendPage(); 76 } 77 78 void saveSessionSetting(const WTF::String& key, const WTF::String& value); 79 void loadSessionSetting(const WTF::String& key, WTF::String* value); 80 81 private: 82 ~WebInspectorClient(); 83 WTF::PassOwnPtr<WebCore::InspectorFrontendClientLocal::Settings> createFrontendSettings(); 84 85 WebView* m_inspectedWebView; 86 WebCore::Page* m_frontendPage; 87 HWND m_inspectedWebViewHwnd; 88 HWND m_frontendHwnd; 89 90 OwnPtr<WebNodeHighlight> m_highlight; 91 92 WTF::HashMap<WTF::String, WTF::String> m_sessionSettings; 93 }; 94 95 class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal, WebCore::WindowMessageListener { 96 public: 97 WebInspectorFrontendClient(WebView* inspectedWebView, HWND inspectedWebViewHwnd, HWND frontendHwnd, const COMPtr<WebView>& frotnendWebView, HWND frontendWebViewHwnd, WebInspectorClient*, WTF::PassOwnPtr<Settings>); 98 99 virtual void frontendLoaded(); 100 101 virtual WTF::String localizedStringsURL(); 102 virtual WTF::String hiddenPanels(); 103 104 virtual void bringToFront(); 105 virtual void closeWindow(); 106 virtual void disconnectFromBackend(); 107 108 virtual void attachWindow(); 109 virtual void detachWindow(); 110 111 virtual void setAttachedWindowHeight(unsigned height); 112 virtual void inspectedURLChanged(const WTF::String& newURL); 113 114 virtual void saveSessionSetting(const WTF::String& key, const WTF::String& value); 115 virtual void loadSessionSetting(const WTF::String& key, WTF::String* value); 116 117 private: 118 ~WebInspectorFrontendClient(); 119 120 void closeWindowWithoutNotifications(); 121 void showWindowWithoutNotifications(); 122 123 void destroyInspectorView(bool notifyInspectorController); 124 125 void updateWindowTitle(); 126 127 LRESULT onGetMinMaxInfo(WPARAM, LPARAM); 128 LRESULT onSize(WPARAM, LPARAM); 129 LRESULT onClose(WPARAM, LPARAM); 130 LRESULT onSetFocus(); 131 132 virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM); 133 134 void onWebViewWindowPosChanging(WPARAM, LPARAM); 135 136 WebView* m_inspectedWebView; 137 HWND m_inspectedWebViewHwnd; 138 HWND m_frontendHwnd; 139 WebInspectorClient* m_inspectorClient; 140 COMPtr<WebView> m_frontendWebView; 141 HWND m_frontendWebViewHwnd; 142 143 bool m_attached; 144 145 WTF::String m_inspectedURL; 146 bool m_destroyingInspectorView; 147 148 static friend LRESULT CALLBACK WebInspectorWndProc(HWND, UINT, WPARAM, LPARAM); 149 }; 150 151 #endif // !defined(WebInspectorClient_h) 152