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/text/WTFString.h"
     39 
     40 namespace WebCore {
     41 
     42 class DOMWrapperWorld;
     43 class Frame;
     44 class GraphicsContext;
     45 class InjectedScriptManager;
     46 class InspectorBackendDispatcher;
     47 class InspectorClient;
     48 class InspectorFrontend;
     49 class InspectorFrontendChannel;
     50 class InspectorFrontendClient;
     51 class InspectorMemoryAgent;
     52 class InspectorTimelineAgent;
     53 class InspectorOverlay;
     54 class InspectorState;
     55 class InstrumentingAgents;
     56 class IntPoint;
     57 class IntSize;
     58 class Page;
     59 class PlatformGestureEvent;
     60 class PlatformKeyboardEvent;
     61 class PlatformMouseEvent;
     62 class PlatformTouchEvent;
     63 class PostWorkerNotificationToFrontendTask;
     64 class Node;
     65 
     66 struct Highlight;
     67 
     68 class InspectorController {
     69     WTF_MAKE_NONCOPYABLE(InspectorController);
     70     WTF_MAKE_FAST_ALLOCATED;
     71 public:
     72     ~InspectorController();
     73 
     74     static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
     75     void inspectedPageDestroyed();
     76 
     77     void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient>);
     78     void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
     79     void setInjectedScriptForOrigin(const String& origin, const String& source);
     80 
     81     void dispatchMessageFromFrontend(const String& message);
     82 
     83     void connectFrontend(InspectorFrontendChannel*);
     84     void disconnectFrontend();
     85     void reconnectFrontend();
     86     void reuseFrontend(InspectorFrontendChannel*, const String& inspectorStateCookie);
     87     void setProcessId(long);
     88     void setLayerTreeId(int);
     89     void webViewResized(const IntSize&);
     90 
     91     void inspect(Node*);
     92     void drawHighlight(GraphicsContext&) const;
     93     void getHighlight(Highlight*) const;
     94     void hideHighlight();
     95     Node* highlightedNode() const;
     96 
     97     bool handleGestureEvent(Frame*, const PlatformGestureEvent&);
     98     bool handleMouseEvent(Frame*, const PlatformMouseEvent&);
     99     bool handleTouchEvent(Frame*, const PlatformTouchEvent&);
    100     bool handleKeyboardEvent(Frame*, const PlatformKeyboardEvent&);
    101 
    102     void requestPageScaleFactor(float scale, const IntPoint& origin);
    103     bool deviceEmulationEnabled();
    104 
    105     bool isUnderTest();
    106     void evaluateForTestInFrontend(long callId, const String& script);
    107 
    108     void resume();
    109 
    110     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
    111 
    112     void willProcessTask();
    113     void didProcessTask();
    114 
    115     void didBeginFrame(int frameId);
    116     void didCancelFrame();
    117     void willComposite();
    118     void didComposite();
    119 
    120     void processGPUEvent(double timestamp, int phase, bool foreign, size_t usedGPUMemoryBytes);
    121 
    122 private:
    123     InspectorController(Page*, InspectorClient*);
    124 
    125     friend class PostWorkerNotificationToFrontendTask;
    126     friend InstrumentingAgents* instrumentationForPage(Page*);
    127 
    128     RefPtr<InstrumentingAgents> m_instrumentingAgents;
    129     OwnPtr<InjectedScriptManager> m_injectedScriptManager;
    130     OwnPtr<InspectorCompositeState> m_state;
    131     OwnPtr<InspectorOverlay> m_overlay;
    132 
    133     InspectorMemoryAgent* m_memoryAgent;
    134     InspectorTimelineAgent* m_timelineAgent;
    135 
    136     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
    137     OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
    138     OwnPtr<InspectorFrontend> m_inspectorFrontend;
    139     Page* m_page;
    140     InspectorClient* m_inspectorClient;
    141     InspectorAgentRegistry m_agents;
    142     bool m_isUnderTest;
    143 };
    144 
    145 }
    146 
    147 
    148 #endif // !defined(InspectorController_h)
    149