Upstream version 7.36.149.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 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 InspectorTimelineAgent;
58 class InspectorTracingAgent;
59 class InspectorOverlay;
60 class InspectorState;
61 class InstrumentingAgents;
62 class IntPoint;
63 class IntSize;
64 class Page;
65 class PlatformGestureEvent;
66 class PlatformKeyboardEvent;
67 class PlatformMouseEvent;
68 class PlatformTouchEvent;
69 class Node;
70
71 class InspectorController {
72     WTF_MAKE_NONCOPYABLE(InspectorController);
73     WTF_MAKE_FAST_ALLOCATED;
74 public:
75     ~InspectorController();
76
77     static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
78
79     // Settings overrides.
80     void setTextAutosizingEnabled(bool);
81     void setDeviceScaleAdjustment(float);
82
83     void willBeDestroyed();
84     void registerModuleAgent(PassOwnPtr<InspectorAgent>);
85
86     void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient>);
87     void didClearDocumentOfWindowObject(LocalFrame*);
88     void setInjectedScriptForOrigin(const String& origin, const String& source);
89
90     void dispatchMessageFromFrontend(const String& message);
91
92     void connectFrontend(InspectorFrontendChannel*);
93     void disconnectFrontend();
94     void reconnectFrontend();
95     void reuseFrontend(InspectorFrontendChannel*, const String& inspectorStateCookie);
96     void setProcessId(long);
97     void setLayerTreeId(int);
98     void webViewResized(const IntSize&);
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     InspectorTimelineAgent* m_timelineAgent;
150     InspectorLayerTreeAgent* m_layerTreeAgent;
151     InspectorTracingAgent* m_tracingAgent;
152
153     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
154     OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
155     OwnPtr<InspectorFrontend> m_inspectorFrontend;
156     Page* m_page;
157     InspectorClient* m_inspectorClient;
158     InspectorAgentRegistry m_agents;
159     Vector<InspectorAgent*> m_moduleAgents;
160     bool m_isUnderTest;
161     bool m_deferredAgentsInitialized;
162 };
163
164 }
165
166
167 #endif // !defined(InspectorController_h)