Home | History | Annotate | Download | only in inspector
      1 /*
      2  * Copyright (C) 2011 Google 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 are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef InspectorController_h
     32 #define InspectorController_h
     33 
     34 #include "core/inspector/InspectorBaseAgent.h"
     35 #include "wtf/Forward.h"
     36 #include "wtf/HashMap.h"
     37 #include "wtf/Noncopyable.h"
     38 #include "wtf/Vector.h"
     39 #include "wtf/text/WTFString.h"
     40 
     41 namespace WebCore {
     42 
     43 class DOMWrapperWorld;
     44 class LocalFrame;
     45 class GraphicsContext;
     46 class GraphicsLayer;
     47 class InjectedScriptManager;
     48 class InspectorBackendDispatcher;
     49 class InspectorAgent;
     50 class InspectorClient;
     51 class InspectorDOMAgent;
     52 class InspectorFrontend;
     53 class InspectorFrontendChannel;
     54 class InspectorFrontendClient;
     55 class InspectorLayerTreeAgent;
     56 class InspectorPageAgent;
     57 class InspectorResourceAgent;
     58 class InspectorTimelineAgent;
     59 class InspectorTracingAgent;
     60 class InspectorOverlay;
     61 class InspectorState;
     62 class InstrumentingAgents;
     63 class IntPoint;
     64 class IntSize;
     65 class Page;
     66 class PlatformGestureEvent;
     67 class PlatformKeyboardEvent;
     68 class PlatformMouseEvent;
     69 class PlatformTouchEvent;
     70 class Node;
     71 
     72 class InspectorController {
     73     WTF_MAKE_NONCOPYABLE(InspectorController);
     74     WTF_MAKE_FAST_ALLOCATED;
     75 public:
     76     ~InspectorController();
     77 
     78     static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
     79 
     80     // Settings overrides.
     81     void setTextAutosizingEnabled(bool);
     82     void setDeviceScaleAdjustment(float);
     83 
     84     void willBeDestroyed();
     85     void registerModuleAgent(PassOwnPtr<InspectorAgent>);
     86 
     87     void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient>);
     88     void didClearDocumentOfWindowObject(LocalFrame*);
     89     void setInjectedScriptForOrigin(const String& origin, const String& source);
     90 
     91     void dispatchMessageFromFrontend(const String& message);
     92 
     93     void connectFrontend(const String& hostId, InspectorFrontendChannel*);
     94     void disconnectFrontend();
     95     void reconnectFrontend();
     96     void reuseFrontend(const String& hostId, InspectorFrontendChannel*, const String& inspectorStateCookie);
     97     void setProcessId(long);
     98     void setLayerTreeId(int);
     99 
    100     void inspect(Node*);
    101     void drawHighlight(GraphicsContext&) const;
    102 
    103     bool handleGestureEvent(LocalFrame*, const PlatformGestureEvent&);
    104     bool handleMouseEvent(LocalFrame*, const PlatformMouseEvent&);
    105     bool handleTouchEvent(LocalFrame*, const PlatformTouchEvent&);
    106     bool handleKeyboardEvent(LocalFrame*, const PlatformKeyboardEvent&);
    107 
    108     void requestPageScaleFactor(float scale, const IntPoint& origin);
    109     bool deviceEmulationEnabled();
    110 
    111     bool isUnderTest();
    112     void evaluateForTestInFrontend(long callId, const String& script);
    113 
    114     void resume();
    115 
    116     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
    117 
    118     void willProcessTask();
    119     void didProcessTask();
    120     void flushPendingFrontendMessages();
    121 
    122     void didCommitLoadForMainFrame();
    123     void didBeginFrame(int frameId);
    124     void didCancelFrame();
    125     void willComposite();
    126     void didComposite();
    127 
    128     void processGPUEvent(double timestamp, int phase, bool foreign, uint64_t usedGPUMemoryBytes, uint64_t limitGPUMemoryBytes);
    129 
    130     void scriptsEnabled(bool);
    131 
    132     void willAddPageOverlay(const GraphicsLayer*);
    133     void didRemovePageOverlay(const GraphicsLayer*);
    134 
    135 private:
    136     InspectorController(Page*, InspectorClient*);
    137 
    138     void initializeDeferredAgents();
    139 
    140     friend InstrumentingAgents* instrumentationForPage(Page*);
    141 
    142     RefPtr<InstrumentingAgents> m_instrumentingAgents;
    143     OwnPtr<InjectedScriptManager> m_injectedScriptManager;
    144     OwnPtr<InspectorCompositeState> m_state;
    145     OwnPtr<InspectorOverlay> m_overlay;
    146 
    147     InspectorDOMAgent* m_domAgent;
    148     InspectorPageAgent* m_pageAgent;
    149     InspectorResourceAgent* m_resourceAgent;
    150     InspectorTimelineAgent* m_timelineAgent;
    151     InspectorLayerTreeAgent* m_layerTreeAgent;
    152     InspectorTracingAgent* m_tracingAgent;
    153 
    154     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
    155     OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
    156     OwnPtr<InspectorFrontend> m_inspectorFrontend;
    157     Page* m_page;
    158     InspectorClient* m_inspectorClient;
    159     InspectorAgentRegistry m_agents;
    160     Vector<InspectorAgent*> m_moduleAgents;
    161     bool m_isUnderTest;
    162     bool m_deferredAgentsInitialized;
    163     String m_hostId;
    164 };
    165 
    166 }
    167 
    168 
    169 #endif // !defined(InspectorController_h)
    170