db758969abe34a79b2ed26ee0ee78356a30fa29f
[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 "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
87     void willBeDestroyed();
88     void registerModuleAgent(PassOwnPtrWillBeRawPtr<InspectorAgent>);
89
90     void setInspectorFrontendClient(PassOwnPtrWillBeRawPtr<InspectorFrontendClient>);
91     void didClearDocumentOfWindowObject(LocalFrame*);
92     void setInjectedScriptForOrigin(const String& origin, const String& source);
93     void showContextMenu(float x, float y, PassRefPtr<ContextMenuProvider>);
94
95     void dispatchMessageFromFrontend(const String& message);
96
97     void connectFrontend(const String& hostId, InspectorFrontendChannel*);
98     void disconnectFrontend();
99     void reconnectFrontend();
100     void reuseFrontend(const String& hostId, InspectorFrontendChannel*, const String& inspectorStateCookie);
101     void setProcessId(long);
102     void setLayerTreeId(int);
103
104     void inspect(Node*);
105     void drawHighlight(GraphicsContext&) const;
106
107     bool handleGestureEvent(LocalFrame*, const PlatformGestureEvent&);
108     bool handleMouseEvent(LocalFrame*, const PlatformMouseEvent&);
109     bool handleTouchEvent(LocalFrame*, const PlatformTouchEvent&);
110     bool handleKeyboardEvent(LocalFrame*, const PlatformKeyboardEvent&);
111
112     void deviceOrPageScaleFactorChanged();
113     bool deviceEmulationEnabled();
114
115     bool isUnderTest();
116     void evaluateForTestInFrontend(long callId, const String& script);
117
118     void resume();
119
120     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
121
122     void willProcessTask();
123     void didProcessTask();
124     void flushPendingFrontendMessages();
125
126     void didCommitLoadForMainFrame();
127     void didBeginFrame(int frameId);
128     void didCancelFrame();
129     void willComposite();
130     void didComposite();
131
132     void processGPUEvent(double timestamp, int phase, bool foreign, uint64_t usedGPUMemoryBytes, uint64_t limitGPUMemoryBytes);
133
134     void scriptsEnabled(bool);
135
136     void willAddPageOverlay(const GraphicsLayer*);
137     void didRemovePageOverlay(const GraphicsLayer*);
138
139 private:
140     InspectorController(Page*, InspectorClient*);
141
142     void initializeDeferredAgents();
143
144     friend InstrumentingAgents* instrumentationForPage(Page*);
145
146     RefPtrWillBeMember<InstrumentingAgents> m_instrumentingAgents;
147     OwnPtrWillBeMember<InjectedScriptManager> m_injectedScriptManager;
148     OwnPtrWillBeMember<InspectorCompositeState> m_state;
149     OwnPtr<InspectorOverlay> m_overlay;
150
151     RawPtrWillBeMember<InspectorDOMAgent> m_domAgent;
152     RawPtrWillBeMember<InspectorPageAgent> m_pageAgent;
153     RawPtrWillBeMember<InspectorTimelineAgent> m_timelineAgent;
154     RawPtrWillBeMember<InspectorCSSAgent> m_cssAgent;
155     RawPtrWillBeMember<InspectorResourceAgent> m_resourceAgent;
156     RawPtrWillBeMember<InspectorLayerTreeAgent> m_layerTreeAgent;
157     RawPtrWillBeMember<InspectorTracingAgent> m_tracingAgent;
158
159     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
160     OwnPtrWillBeMember<InspectorFrontendClient> m_inspectorFrontendClient;
161     OwnPtr<InspectorFrontend> m_inspectorFrontend;
162     RawPtrWillBeMember<Page> m_page;
163     InspectorClient* m_inspectorClient;
164     InspectorAgentRegistry m_agents;
165     bool m_isUnderTest;
166     bool m_deferredAgentsInitialized;
167     String m_hostId;
168 };
169
170 }
171
172
173 #endif // !defined(InspectorController_h)