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 WebInspector_h 27#define WebInspector_h 28 29#if ENABLE(INSPECTOR) 30 31#include "APIObject.h" 32#include "Connection.h" 33#include <wtf/Noncopyable.h> 34#include <wtf/text/WTFString.h> 35 36namespace WebCore { 37class InspectorFrontendChannel; 38} 39 40namespace WebKit { 41 42class WebInspectorFrontendClient; 43class WebPage; 44struct WebPageCreationParameters; 45 46class WebInspector : public TypedAPIObject<APIObject::TypeBundleInspector> { 47public: 48 static PassRefPtr<WebInspector> create(WebPage*, WebCore::InspectorFrontendChannel*); 49 50 WebPage* page() const { return m_page; } 51 WebPage* inspectorPage() const { return m_inspectorPage; } 52 53 // Implemented in generated WebInspectorMessageReceiver.cpp 54 void didReceiveWebInspectorMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&); 55 56 // Called by WebInspector messages 57 void show(); 58 void close(); 59 60 void didSave(const String& url); 61 void didAppend(const String& url); 62 63 void attachedBottom(); 64 void attachedRight(); 65 void detached(); 66 67 void evaluateScriptForTest(long callID, const String& script); 68 69 void setJavaScriptProfilingEnabled(bool); 70 void startPageProfiling(); 71 void stopPageProfiling(); 72 73#if ENABLE(INSPECTOR_SERVER) 74 bool hasRemoteFrontendConnected() const { return m_remoteFrontendConnected; } 75 void sendMessageToRemoteFrontend(const String& message); 76 void dispatchMessageFromRemoteFrontend(const String& message); 77 void remoteFrontendConnected(); 78 void remoteFrontendDisconnected(); 79#endif 80 81#if PLATFORM(MAC) 82 void setInspectorUsesWebKitUserInterface(bool); 83#endif 84 85private: 86 friend class WebInspectorClient; 87 friend class WebInspectorFrontendClient; 88 89 explicit WebInspector(WebPage*, WebCore::InspectorFrontendChannel*); 90 91 // Called from WebInspectorClient 92 WebPage* createInspectorPage(); 93 void destroyInspectorPage(); 94 95 // Called from WebInspectorFrontendClient 96 void didClose(); 97 void bringToFront(); 98 void inspectedURLChanged(const String&); 99 100 bool canSave() const; 101 void save(const String& filename, const String& content, bool forceSaveAs); 102 void append(const String& filename, const String& content); 103 104 void attachBottom(); 105 void attachRight(); 106 void detach(); 107 108 void setAttachedWindowHeight(unsigned); 109 void setAttachedWindowWidth(unsigned); 110 void setToolbarHeight(unsigned); 111 112 // Implemented in platform WebInspector file 113 String localizedStringsURL() const; 114 115 void showConsole(); 116 117 void showResources(); 118 119 void showMainResourceForFrame(uint64_t frameID); 120 121 void startJavaScriptDebugging(); 122 void stopJavaScriptDebugging(); 123 124 void startJavaScriptProfiling(); 125 void stopJavaScriptProfiling(); 126 127 void updateDockingAvailability(); 128 129 WebPage* m_page; 130 WebPage* m_inspectorPage; 131 WebInspectorFrontendClient* m_frontendClient; 132 WebCore::InspectorFrontendChannel* m_frontendChannel; 133#if PLATFORM(MAC) 134 mutable String m_localizedStringsURL; 135 mutable bool m_hasLocalizedStringsURL; 136 bool m_usesWebKitUserInterface; 137#endif 138#if ENABLE(INSPECTOR_SERVER) 139 bool m_remoteFrontendConnected; 140#endif 141}; 142 143} // namespace WebKit 144 145#endif // ENABLE(INSPECTOR) 146 147#endif // WebInspector_h 148