Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / inspector / InspectorController.h
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 Frame;
45 class GraphicsContext;
46 class InjectedScriptManager;
47 class InspectorBackendDispatcher;
48 class InspectorAgent;
49 class InspectorClient;
50 class InspectorDOMAgent;
51 class InspectorFrontend;
52 class InspectorFrontendChannel;
53 class InspectorFrontendClient;
54 class InspectorPageAgent;
55 class InspectorTimelineAgent;
56 class InspectorOverlay;
57 class InspectorState;
58 class InstrumentingAgents;
59 class IntPoint;
60 class IntSize;
61 class Page;
62 class PlatformGestureEvent;
63 class PlatformKeyboardEvent;
64 class PlatformMouseEvent;
65 class PlatformTouchEvent;
66 class Node;
67
68 struct Highlight;
69
70 class InspectorController {
71     WTF_MAKE_NONCOPYABLE(InspectorController);
72     WTF_MAKE_FAST_ALLOCATED;
73 public:
74     ~InspectorController();
75
76     static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
77
78     // Settings overrides.
79     void setTextAutosizingEnabled(bool);
80     void setDeviceScaleAdjustment(float);
81
82     void inspectedPageDestroyed();
83     void registerModuleAgent(PassOwnPtr<InspectorAgent>);
84
85     void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient>);
86     void didClearWindowObjectInMainWorld(Frame*);
87     void setInjectedScriptForOrigin(const String& origin, const String& source);
88
89     void dispatchMessageFromFrontend(const String& message);
90
91     void connectFrontend(InspectorFrontendChannel*);
92     void disconnectFrontend();
93     void reconnectFrontend();
94     void reuseFrontend(InspectorFrontendChannel*, const String& inspectorStateCookie);
95     void setProcessId(long);
96     void setLayerTreeId(int);
97     void webViewResized(const IntSize&);
98
99     void inspect(Node*);
100     void drawHighlight(GraphicsContext&) const;
101     void getHighlight(Highlight*) const;
102     void hideHighlight();
103     Node* highlightedNode() const;
104
105     bool handleGestureEvent(Frame*, const PlatformGestureEvent&);
106     bool handleMouseEvent(Frame*, const PlatformMouseEvent&);
107     bool handleTouchEvent(Frame*, const PlatformTouchEvent&);
108     bool handleKeyboardEvent(Frame*, const PlatformKeyboardEvent&);
109
110     void requestPageScaleFactor(float scale, const IntPoint& origin);
111     bool deviceEmulationEnabled();
112
113     bool isUnderTest();
114     void evaluateForTestInFrontend(long callId, const String& script);
115
116     void resume();
117
118     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
119
120     void willProcessTask();
121     void didProcessTask();
122
123     void didCommitLoadForMainFrame();
124     void didBeginFrame(int frameId);
125     void didCancelFrame();
126     void willComposite();
127     void didComposite();
128
129     void processGPUEvent(double timestamp, int phase, bool foreign, size_t usedGPUMemoryBytes);
130
131     void scriptsEnabled(bool);
132
133 private:
134     InspectorController(Page*, InspectorClient*);
135
136     void initializeDeferredAgents();
137
138     friend InstrumentingAgents* instrumentationForPage(Page*);
139
140     RefPtr<InstrumentingAgents> m_instrumentingAgents;
141     OwnPtr<InjectedScriptManager> m_injectedScriptManager;
142     OwnPtr<InspectorCompositeState> m_state;
143     OwnPtr<InspectorOverlay> m_overlay;
144
145     InspectorDOMAgent* m_domAgent;
146     InspectorPageAgent* m_pageAgent;
147     InspectorTimelineAgent* m_timelineAgent;
148
149     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
150     OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
151     OwnPtr<InspectorFrontend> m_inspectorFrontend;
152     Page* m_page;
153     InspectorClient* m_inspectorClient;
154     InspectorAgentRegistry m_agents;
155     Vector<InspectorAgent*> m_moduleAgents;
156     bool m_isUnderTest;
157     bool m_deferredAgentsInitialized;
158 };
159
160 }
161
162
163 #endif // !defined(InspectorController_h)