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