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/InspectorFrontendChannel.h> 35#include <WebCore/InspectorFrontendClientLocal.h> 36#include <WebCore/WindowMessageListener.h> 37#include <windows.h> 38#include <wtf/Forward.h> 39#include <wtf/HashMap.h> 40#include <wtf/OwnPtr.h> 41#include <wtf/text/StringHash.h> 42#include <wtf/text/WTFString.h> 43 44namespace WebCore { 45 46class Page; 47 48} 49 50class WebInspectorFrontendClient; 51class WebNodeHighlight; 52class WebView; 53 54class WebInspectorClient : public WebCore::InspectorClient, public WebCore::InspectorFrontendChannel { 55public: 56 explicit WebInspectorClient(WebView*); 57 58 // InspectorClient 59 virtual void inspectorDestroyed(); 60 61 virtual WebCore::InspectorFrontendChannel* openInspectorFrontend(WebCore::InspectorController*); 62 virtual void closeInspectorFrontend(); 63 virtual void bringFrontendToFront(); 64 65 virtual void highlight(); 66 virtual void hideHighlight(); 67 68 virtual bool sendMessageToFrontend(const WTF::String&); 69 70 bool inspectorStartsAttached(); 71 void setInspectorStartsAttached(bool); 72 73 bool inspectorAttachDisabled(); 74 void setInspectorAttachDisabled(bool); 75 76 void releaseFrontend(); 77 78 WebInspectorFrontendClient* frontendClient() { return m_frontendClient; } 79 80 void updateHighlight(); 81 82private: 83 virtual ~WebInspectorClient(); 84 WTF::PassOwnPtr<WebCore::InspectorFrontendClientLocal::Settings> createFrontendSettings(); 85 86 WebView* m_inspectedWebView; 87 WebCore::Page* m_frontendPage; 88 WebInspectorFrontendClient* m_frontendClient; 89 HWND m_inspectedWebViewHwnd; 90 HWND m_frontendHwnd; 91 92 OwnPtr<WebNodeHighlight> m_highlight; 93}; 94 95class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal, WebCore::WindowMessageListener { 96public: 97 WebInspectorFrontendClient(WebView* inspectedWebView, HWND inspectedWebViewHwnd, HWND frontendHwnd, const COMPtr<WebView>& frotnendWebView, HWND frontendWebViewHwnd, WebInspectorClient*, WTF::PassOwnPtr<Settings>); 98 virtual ~WebInspectorFrontendClient(); 99 100 virtual void frontendLoaded(); 101 102 virtual WTF::String localizedStringsURL(); 103 104 virtual void bringToFront(); 105 virtual void closeWindow(); 106 107 virtual void attachWindow(DockSide); 108 virtual void detachWindow(); 109 110 virtual void setAttachedWindowHeight(unsigned height); 111 virtual void setAttachedWindowWidth(unsigned); 112 virtual void setToolbarHeight(unsigned) OVERRIDE; 113 114 virtual void inspectedURLChanged(const WTF::String& newURL); 115 116 void destroyInspectorView(bool notifyInspectorController); 117 118private: 119 void closeWindowWithoutNotifications(); 120 void showWindowWithoutNotifications(); 121 122 void updateWindowTitle(); 123 124 LRESULT onGetMinMaxInfo(WPARAM, LPARAM); 125 LRESULT onSize(WPARAM, LPARAM); 126 LRESULT onClose(WPARAM, LPARAM); 127 LRESULT onSetFocus(); 128 129 virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM); 130 131 void onWebViewWindowPosChanging(WPARAM, LPARAM); 132 133 WebView* m_inspectedWebView; 134 HWND m_inspectedWebViewHwnd; 135 HWND m_frontendHwnd; 136 WebInspectorClient* m_inspectorClient; 137 COMPtr<WebView> m_frontendWebView; 138 HWND m_frontendWebViewHwnd; 139 140 bool m_attached; 141 142 WTF::String m_inspectedURL; 143 bool m_destroyingInspectorView; 144 145 static friend LRESULT CALLBACK WebInspectorWndProc(HWND, UINT, WPARAM, LPARAM); 146}; 147 148#endif // !defined(WebInspectorClient_h) 149