InspectorFrontend.h revision 643ca7872b450ea4efacab6188849e5aac2ba161
1/* 2 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15 * its contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#ifndef InspectorFrontend_h 31#define InspectorFrontend_h 32 33#include "ScriptArray.h" 34#include "ScriptObject.h" 35#include "ScriptState.h" 36#include <wtf/PassOwnPtr.h> 37 38#if ENABLE(JAVASCRIPT_DEBUGGER) 39namespace JSC { 40 class JSValue; 41 class SourceCode; 42 class UString; 43} 44#endif 45 46namespace WebCore { 47 class ConsoleMessage; 48 class Database; 49 class Frame; 50 class InspectorController; 51 class InspectorResource; 52 class Node; 53 class ScriptFunctionCall; 54 class ScriptString; 55 class Storage; 56 57 class InspectorFrontend { 58 public: 59 InspectorFrontend(InspectorController* inspectorController, ScriptState*, ScriptObject webInspector); 60 ~InspectorFrontend(); 61 62 ScriptArray newScriptArray(); 63 ScriptObject newScriptObject(); 64 65 void didCommitLoad(); 66 void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, const Vector<ScriptValue> wrappedArguments, const String& message); 67 void updateConsoleMessageRepeatCount(const int count); 68 void clearConsoleMessages(); 69 70 bool addResource(unsigned long identifier, const ScriptObject& resourceObj); 71 bool updateResource(unsigned long identifier, const ScriptObject& resourceObj); 72 void removeResource(unsigned long identifier); 73 74 void updateFocusedNode(long nodeId); 75 void setAttachedWindow(bool attached); 76 void showPanel(int panel); 77 void populateInterface(); 78 void reset(); 79 80 void resourceTrackingWasEnabled(); 81 void resourceTrackingWasDisabled(); 82 83#if ENABLE(JAVASCRIPT_DEBUGGER) 84 void attachDebuggerWhenShown(); 85 void debuggerWasEnabled(); 86 void debuggerWasDisabled(); 87 void profilerWasEnabled(); 88 void profilerWasDisabled(); 89 void parsedScriptSource(const JSC::SourceCode&); 90 void failedToParseScriptSource(const JSC::SourceCode&, int errorLine, const JSC::UString& errorMessage); 91 void addProfileHeader(const ScriptValue& profile); 92 void setRecordingProfile(bool isProfiling); 93 void didGetProfileHeaders(int callId, const ScriptArray& headers); 94 void didGetProfile(int callId, const ScriptValue& profile); 95 void pausedScript(const ScriptValue& callFrames); 96 void resumedScript(); 97#endif 98 99#if ENABLE(DATABASE) 100 bool addDatabase(const ScriptObject& dbObj); 101 void selectDatabase(int databaseId); 102 void didGetDatabaseTableNames(int callId, const ScriptArray& tableNames); 103#endif 104 105#if ENABLE(DOM_STORAGE) 106 bool addDOMStorage(const ScriptObject& domStorageObj); 107 void selectDOMStorage(int storageId); 108 void didGetDOMStorageEntries(int callId, const ScriptArray& entries); 109 void didSetDOMStorageItem(int callId, bool success); 110 void didRemoveDOMStorageItem(int callId, bool success); 111 void updateDOMStorage(int storageId); 112#endif 113 114 void setDocument(const ScriptObject& root); 115 void setDetachedRoot(const ScriptObject& root); 116 void setChildNodes(int parentId, const ScriptArray& nodes); 117 void childNodeCountUpdated(int id, int newValue); 118 void childNodeInserted(int parentId, int prevId, const ScriptObject& node); 119 void childNodeRemoved(int parentId, int id); 120 void attributesUpdated(int id, const ScriptArray& attributes); 121 void didGetChildNodes(int callId); 122 void didApplyDomChange(int callId, bool success); 123 void didGetEventListenersForNode(int callId, int nodeId, ScriptArray& listenersArray); 124 void didRemoveNode(int callId, int nodeId); 125 126 void timelineProfilerWasStarted(); 127 void timelineProfilerWasStopped(); 128 void addRecordToTimeline(const ScriptObject&); 129 130 void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString); 131 void didDispatchOnInjectedScript(int callId, const String& result, bool isException); 132 133 void addNodesToSearchResult(const String& nodeIds); 134 135 void contextMenuItemSelected(int itemId); 136 void contextMenuCleared(); 137 138 ScriptState* scriptState() const { return m_scriptState; } 139 140 void evaluateForTestInFrontend(int callId, const String& script); 141 private: 142 void callSimpleFunction(const String& functionName); 143 InspectorController* m_inspectorController; 144 ScriptState* m_scriptState; 145 ScriptObject m_webInspector; 146 }; 147 148} // namespace WebCore 149 150#endif // !defined(InspectorFrontend_h) 151