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) && USE(JSC) 39 namespace JSC { 40 class JSValue; 41 class SourceCode; 42 class UString; 43 } 44 #endif 45 46 namespace WebCore { 47 class ConsoleMessage; 48 class Database; 49 class Frame; 50 class InspectorController; 51 class InspectorResource; 52 class Node; 53 class ScriptString; 54 class SerializedScriptValue; 55 class Storage; 56 57 class InspectorFrontend : public Noncopyable { 58 public: 59 InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector); 60 ~InspectorFrontend(); 61 62 ScriptArray newScriptArray(); 63 ScriptObject newScriptObject(); 64 65 void didCommitLoad(); 66 67 void populateFrontendSettings(const String& settings); 68 69 void updateConsoleMessageExpiredCount(unsigned count); 70 void addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState*, const Vector<ScriptValue> arguments, const String& message); 71 void updateConsoleMessageRepeatCount(unsigned count); 72 void clearConsoleMessages(); 73 74 bool updateResource(unsigned long identifier, const ScriptObject& resourceObj); 75 void removeResource(unsigned long identifier); 76 void didGetResourceContent(int callId, const String& content); 77 78 void updateFocusedNode(long nodeId); 79 void setAttachedWindow(bool attached); 80 void showPanel(int panel); 81 void populateInterface(); 82 void reset(); 83 84 void resourceTrackingWasEnabled(); 85 void resourceTrackingWasDisabled(); 86 87 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) 88 void attachDebuggerWhenShown(); 89 void debuggerWasEnabled(); 90 void debuggerWasDisabled(); 91 void parsedScriptSource(const JSC::SourceCode&); 92 void failedToParseScriptSource(const JSC::SourceCode&, int errorLine, const JSC::UString& errorMessage); 93 void pausedScript(SerializedScriptValue* callFrames); 94 void resumedScript(); 95 #endif 96 #if ENABLE(JAVASCRIPT_DEBUGGER) 97 void profilerWasEnabled(); 98 void profilerWasDisabled(); 99 void addProfileHeader(const ScriptValue& profile); 100 void setRecordingProfile(bool isProfiling); 101 void didGetProfileHeaders(int callId, const ScriptArray& headers); 102 void didGetProfile(int callId, const ScriptValue& profile); 103 #endif 104 105 #if ENABLE(DATABASE) 106 bool addDatabase(const ScriptObject& dbObj); 107 void selectDatabase(int databaseId); 108 void didGetDatabaseTableNames(int callId, const ScriptArray& tableNames); 109 #endif 110 111 #if ENABLE(DOM_STORAGE) 112 bool addDOMStorage(const ScriptObject& domStorageObj); 113 void selectDOMStorage(int storageId); 114 void didGetDOMStorageEntries(int callId, const ScriptArray& entries); 115 void didSetDOMStorageItem(int callId, bool success); 116 void didRemoveDOMStorageItem(int callId, bool success); 117 void updateDOMStorage(int storageId); 118 #endif 119 120 void setDocument(const ScriptObject& root); 121 void setDetachedRoot(const ScriptObject& root); 122 void setChildNodes(int parentId, const ScriptArray& nodes); 123 void childNodeCountUpdated(int id, int newValue); 124 void childNodeInserted(int parentId, int prevId, const ScriptObject& node); 125 void childNodeRemoved(int parentId, int id); 126 void attributesUpdated(int id, const ScriptArray& attributes); 127 void didGetChildNodes(int callId); 128 void didApplyDomChange(int callId, bool success); 129 void didGetEventListenersForNode(int callId, int nodeId, ScriptArray& listenersArray); 130 void didRemoveNode(int callId, int nodeId); 131 132 void timelineProfilerWasStarted(); 133 void timelineProfilerWasStopped(); 134 void addRecordToTimeline(const ScriptObject&); 135 136 void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString); 137 void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException); 138 139 void addNodesToSearchResult(const String& nodeIds); 140 141 void contextMenuItemSelected(int itemId); 142 void contextMenuCleared(); 143 scriptState()144 ScriptState* scriptState() const { return m_webInspector.scriptState(); } 145 146 void evaluateForTestInFrontend(int callId, const String& script); 147 private: 148 void callSimpleFunction(const String& functionName); 149 InspectorController* m_inspectorController; 150 ScriptObject m_webInspector; 151 }; 152 153 } // namespace WebCore 154 155 #endif // !defined(InspectorFrontend_h) 156