Home | History | Annotate | Download | only in inspector
      1 /*
      2  * Copyright (C) 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 InspectorBackend_h
     30 #define InspectorBackend_h
     31 
     32 #include "Console.h"
     33 #include "InspectorController.h"
     34 #include "PlatformString.h"
     35 
     36 #include <wtf/RefCounted.h>
     37 
     38 namespace WebCore {
     39 
     40 class CachedResource;
     41 class Database;
     42 class InspectorDOMAgent;
     43 class InspectorFrontend;
     44 class JavaScriptCallFrame;
     45 class Node;
     46 class Storage;
     47 
     48 class InspectorBackend : public RefCounted<InspectorBackend>
     49 {
     50 public:
     51     static PassRefPtr<InspectorBackend> create(InspectorController* inspectorController)
     52     {
     53         return adoptRef(new InspectorBackend(inspectorController));
     54     }
     55 
     56     ~InspectorBackend();
     57 
     58     InspectorController* inspectorController() { return m_inspectorController; }
     59     void disconnectController() { m_inspectorController = 0; }
     60 
     61     void saveFrontendSettings(const String&);
     62 
     63     void storeLastActivePanel(const String& panelName);
     64 
     65     void toggleNodeSearch();
     66     bool searchingForNode();
     67 
     68     void enableResourceTracking(bool always);
     69     void disableResourceTracking(bool always);
     70     bool resourceTrackingEnabled() const;
     71     void getResourceContent(long callId, unsigned long identifier);
     72 
     73     void startTimelineProfiler();
     74     void stopTimelineProfiler();
     75 
     76 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
     77     bool debuggerEnabled() const;
     78     void enableDebugger(bool always);
     79     void disableDebugger(bool always);
     80 
     81     void addBreakpoint(const String& sourceID, unsigned lineNumber, const String& condition);
     82     void updateBreakpoint(const String& sourceID, unsigned lineNumber, const String& condition);
     83     void removeBreakpoint(const String& sourceID, unsigned lineNumber);
     84 
     85     void pauseInDebugger();
     86     void resumeDebugger();
     87 
     88     long pauseOnExceptionsState();
     89     void setPauseOnExceptionsState(long pauseState);
     90 
     91     void stepOverStatementInDebugger();
     92     void stepIntoStatementInDebugger();
     93     void stepOutOfFunctionInDebugger();
     94 
     95     JavaScriptCallFrame* currentCallFrame() const;
     96 #endif
     97 #if ENABLE(JAVASCRIPT_DEBUGGER)
     98     bool profilerEnabled();
     99     void enableProfiler(bool always);
    100     void disableProfiler(bool always);
    101 
    102     void startProfiling();
    103     void stopProfiling();
    104 
    105     void getProfileHeaders(long callId);
    106     void getProfile(long callId, unsigned uid);
    107 #endif
    108 
    109     void setInjectedScriptSource(const String& source);
    110     void dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async);
    111     void getChildNodes(long callId, long nodeId);
    112     void setAttribute(long callId, long elementId, const String& name, const String& value);
    113     void removeAttribute(long callId, long elementId, const String& name);
    114     void setTextNodeValue(long callId, long nodeId, const String& value);
    115     void getEventListenersForNode(long callId, long nodeId);
    116     void copyNode(long nodeId);
    117     void removeNode(long callId, long nodeId);
    118     void highlightDOMNode(long nodeId);
    119     void hideDOMNodeHighlight();
    120 
    121     void getCookies(long callId);
    122     void deleteCookie(const String& cookieName, const String& domain);
    123 
    124     // Generic code called from custom implementations.
    125     void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
    126     void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
    127 
    128 #if ENABLE(DATABASE)
    129     void getDatabaseTableNames(long callId, long databaseId);
    130 #endif
    131 
    132 #if ENABLE(DOM_STORAGE)
    133     void getDOMStorageEntries(long callId, long storageId);
    134     void setDOMStorageItem(long callId, long storageId, const String& key, const String& value);
    135     void removeDOMStorageItem(long callId, long storageId, const String& key);
    136 #endif
    137 
    138 private:
    139     InspectorBackend(InspectorController* inspectorController);
    140     InspectorDOMAgent* inspectorDOMAgent();
    141     InspectorFrontend* inspectorFrontend();
    142     Node* nodeForId(long nodeId);
    143 
    144     InspectorController* m_inspectorController;
    145 };
    146 
    147 } // namespace WebCore
    148 
    149 #endif // !defined(InspectorBackend_h)
    150