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 "platform/heap/Handle.h"
     36 #include "wtf/Forward.h"
     37 #include "wtf/HashMap.h"
     38 #include "wtf/Noncopyable.h"
     39 #include "wtf/text/WTFString.h"
     40 
     41 namespace blink {
     42 
     43 class ContextMenuProvider;
     44 class DOMWrapperWorld;
     45 class LocalFrame;
     46 class GraphicsContext;
     47 class GraphicsLayer;
     48 class InjectedScriptManager;
     49 class InspectorBackendDispatcher;
     50 class InspectorAgent;
     51 class InspectorClient;
     52 class InspectorCSSAgent;
     53 class InspectorDOMAgent;
     54 class InspectorFrontend;
     55 class InspectorFrontendChannel;
     56 class InspectorFrontendClient;
     57 class InspectorLayerTreeAgent;
     58 class InspectorPageAgent;
     59 class InspectorResourceAgent;
     60 class InspectorTimelineAgent;
     61 class InspectorTracingAgent;
     62 class InspectorOverlay;
     63 class InspectorState;
     64 class InstrumentingAgents;
     65 class IntPoint;
     66 class IntSize;
     67 class Page;
     68 class PlatformGestureEvent;
     69 class PlatformKeyboardEvent;
     70 class PlatformMouseEvent;
     71 class PlatformTouchEvent;
     72 class Node;
     73 
     74 class InspectorController : public NoBaseWillBeGarbageCollectedFinalized<InspectorController> {
     75     WTF_MAKE_NONCOPYABLE(InspectorController);
     76     WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
     77 public:
     78     ~InspectorController();
     79     void trace(Visitor*);
     80 
     81     static PassOwnPtrWillBeRawPtr<InspectorController> create(Page*, InspectorClient*);
     82 
     83     // Settings overrides.
     84     void setTextAutosizingEnabled(bool);
     85     void setDeviceScaleAdjustment(float);
     86     void setPreferCompositingToLCDTextEnabled(bool);
     87 
     88     void willBeDestroyed();
     89     void registerModuleAgent(PassOwnPtrWillBeRawPtr<InspectorAgent>);
     90 
     91     void setInspectorFrontendClient(InspectorFrontendClient*);
     92     void didClearDocumentOfWindowObject(LocalFrame*);
     93     void setInjectedScriptForOrigin(const String& origin, const String& source);
     94     void showContextMenu(float x, float y, PassRefPtr<ContextMenuProvider>);
     95 
     96     void dispatchMessageFromFrontend(const String& message);
     97 
     98     void connectFrontend(const String& hostId, InspectorFrontendChannel*);
     99     void disconnectFrontend();
    100     void reconnectFrontend();
    101     void reuseFrontend(const String& hostId, InspectorFrontendChannel*, const String& inspectorStateCookie);
    102     void setProcessId(long);
    103     void setLayerTreeId(int);
    104 
    105     void inspect(Node*);
    106     void drawHighlight(GraphicsContext&) const;
    107 
    108     bool handleGestureEvent(LocalFrame*, const PlatformGestureEvent&);
    109     bool handleMouseEvent(LocalFrame*, const PlatformMouseEvent&);
    110     bool handleTouchEvent(LocalFrame*, const PlatformTouchEvent&);
    111     bool handleKeyboardEvent(LocalFrame*, const PlatformKeyboardEvent&);
    112 
    113     void deviceOrPageScaleFactorChanged();
    114     bool deviceEmulationEnabled();
    115     bool screencastEnabled();
    116 
    117     bool isUnderTest();
    118     void evaluateForTestInFrontend(long callId, const String& script);
    119 
    120     void resume();
    121 
    122     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
    123 
    124     void willProcessTask();
    125     void didProcessTask();
    126     void flushPendingFrontendMessages();
    127 
    128     void didCommitLoadForMainFrame();
    129     void didBeginFrame(int frameId);
    130     void didCancelFrame();
    131     void willComposite();
    132     void didComposite();
    133 
    134     void processGPUEvent(double timestamp, int phase, bool foreign, uint64_t usedGPUMemoryBytes, uint64_t limitGPUMemoryBytes);
    135 
    136     void scriptsEnabled(bool);
    137 
    138     void willAddPageOverlay(const GraphicsLayer*);
    139     void didRemovePageOverlay(const GraphicsLayer*);
    140 
    141 private:
    142     InspectorController(Page*, InspectorClient*);
    143 
    144     void initializeDeferredAgents();
    145 
    146     friend InstrumentingAgents* instrumentationForPage(Page*);
    147 
    148     RefPtrWillBeMember<InstrumentingAgents> m_instrumentingAgents;
    149     OwnPtrWillBeMember<InjectedScriptManager> m_injectedScriptManager;
    150     OwnPtrWillBeMember<InspectorCompositeState> m_state;
    151     OwnPtr<InspectorOverlay> m_overlay;
    152 
    153     RawPtrWillBeMember<InspectorDOMAgent> m_domAgent;
    154     RawPtrWillBeMember<InspectorPageAgent> m_pageAgent;
    155     RawPtrWillBeMember<InspectorTimelineAgent> m_timelineAgent;
    156     RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent;
    157     RawPtrWillBeMember<InspectorResourceAgent> m_resourceAgent;
    158     RawPtrWillBeMember<InspectorLayerTreeAgent> m_layerTreeAgent;
    159     RawPtrWillBeMember<InspectorTracingAgent> m_tracingAgent;
    160 
    161     RefPtrWillBeMember<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
    162     InspectorFrontendClient* m_inspectorFrontendClient;
    163     OwnPtr<InspectorFrontend> m_inspectorFrontend;
    164     RawPtrWillBeMember<Page> m_page;
    165     InspectorClient* m_inspectorClient;
    166     InspectorAgentRegistry m_agents;
    167     bool m_isUnderTest;
    168     bool m_deferredAgentsInitialized;
    169     String m_hostId;
    170 };
    171 
    172 }
    173 
    174 
    175 #endif // !defined(InspectorController_h)
    176