2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef WebDevToolsAgentImpl_h
32 #define WebDevToolsAgentImpl_h
34 #include "core/inspector/InspectorFrontendChannel.h"
35 #include "core/inspector/InspectorRuntimeAgent.h"
36 #include "core/inspector/InspectorStateClient.h"
37 #include "core/inspector/InspectorTracingAgent.h"
38 #include "platform/heap/Handle.h"
39 #include "public/platform/WebSize.h"
40 #include "public/platform/WebThread.h"
41 #include "public/web/WebDevToolsAgent.h"
42 #include "wtf/Forward.h"
43 #include "wtf/OwnPtr.h"
44 #include "wtf/Vector.h"
50 class InspectorInspectorAgent
;
51 class InspectorOverlayImpl
;
52 class InspectorPageAgent
;
53 class InspectorResourceContentLoader
;
56 class PageConsoleAgent
;
57 class PlatformGestureEvent
;
58 class PlatformKeyboardEvent
;
59 class PlatformMouseEvent
;
60 class PlatformTouchEvent
;
61 class WebDevToolsAgentClient
;
62 class WebFrameWidgetImpl
;
64 class WebLayerTreeView
;
65 class WebLocalFrameImpl
;
69 class WebDevToolsAgentImpl final
70 : public NoBaseWillBeGarbageCollectedFinalized
<WebDevToolsAgentImpl
>
71 , public WebDevToolsAgent
72 , public InspectorStateClient
73 , public InspectorTracingAgent::Client
74 , public InspectorRuntimeAgent::Client
75 , public InspectorFrontendChannel
76 , private WebThread::TaskObserver
{
78 static PassOwnPtrWillBeRawPtr
<WebDevToolsAgentImpl
> create(WebLocalFrameImpl
*, WebDevToolsAgentClient
*);
79 ~WebDevToolsAgentImpl() override
;
81 DECLARE_VIRTUAL_TRACE();
83 void willBeDestroyed();
84 WebDevToolsAgentClient
* client() { return m_client
; }
85 InspectorOverlayImpl
* overlay() const { return m_overlay
.get(); }
86 void flushPendingProtocolNotifications();
87 void dispatchMessageFromFrontend(const String
& message
);
88 void registerAgent(PassOwnPtrWillBeRawPtr
<InspectorAgent
>);
89 static void webViewImplClosed(WebViewImpl
*);
90 static void webFrameWidgetImplClosed(WebFrameWidgetImpl
*);
92 // Instrumentation from web/ layer.
93 void didCommitLoadForLocalFrame(LocalFrame
*);
94 bool screencastEnabled();
95 void willAddPageOverlay(const GraphicsLayer
*);
96 void didRemovePageOverlay(const GraphicsLayer
*);
97 void layerTreeViewChanged(WebLayerTreeView
*);
99 // WebDevToolsAgent implementation.
100 void attach(const WebString
& hostId
) override
;
101 void reattach(const WebString
& hostId
, const WebString
& savedState
) override
;
102 void detach() override
;
103 void continueProgram() override
;
104 void dispatchOnInspectorBackend(const WebString
& message
) override
;
105 void inspectElementAt(const WebPoint
&) override
;
106 void evaluateInWebInspector(long callId
, const WebString
& script
) override
;
109 WebDevToolsAgentImpl(WebLocalFrameImpl
*, WebDevToolsAgentClient
*, PassOwnPtrWillBeRawPtr
<InspectorOverlayImpl
>);
111 // InspectorStateClient implementation.
112 void updateInspectorStateCookie(const WTF::String
&) override
;
114 // InspectorTracingAgent::Client implementation.
115 void enableTracing(const WTF::String
& categoryFilter
) override
;
116 void disableTracing() override
;
118 // InspectorRuntimeAgent::Client implementation.
119 void resumeStartup() override
;
121 // InspectorFrontendChannel implementation.
122 void sendProtocolResponse(int callId
, PassRefPtr
<JSONObject
> message
) override
;
123 void sendProtocolNotification(PassRefPtr
<JSONObject
> message
) override
;
124 void flush() override
;
126 // WebThread::TaskObserver implementation.
127 void willProcessTask() override
;
128 void didProcessTask() override
;
130 void initializeDeferredAgents();
132 WebDevToolsAgentClient
* m_client
;
133 RawPtrWillBeMember
<WebLocalFrameImpl
> m_webLocalFrameImpl
;
136 bool m_hasBeenDisposed
;
139 RefPtrWillBeMember
<InstrumentingAgents
> m_instrumentingAgents
;
140 OwnPtrWillBeMember
<InjectedScriptManager
> m_injectedScriptManager
;
141 OwnPtrWillBeMember
<InspectorResourceContentLoader
> m_resourceContentLoader
;
142 OwnPtrWillBeMember
<InspectorCompositeState
> m_state
;
143 OwnPtrWillBeMember
<InspectorOverlayImpl
> m_overlay
;
145 RawPtrWillBeMember
<InspectorInspectorAgent
> m_inspectorAgent
;
146 RawPtrWillBeMember
<InspectorDOMAgent
> m_domAgent
;
147 RawPtrWillBeMember
<InspectorPageAgent
> m_pageAgent
;
148 RawPtrWillBeMember
<InspectorCSSAgent
> m_cssAgent
;
149 RawPtrWillBeMember
<InspectorResourceAgent
> m_resourceAgent
;
150 RawPtrWillBeMember
<InspectorLayerTreeAgent
> m_layerTreeAgent
;
151 RawPtrWillBeMember
<InspectorTracingAgent
> m_tracingAgent
;
152 RawPtrWillBeMember
<PageRuntimeAgent
> m_pageRuntimeAgent
;
153 RawPtrWillBeMember
<PageConsoleAgent
> m_pageConsoleAgent
;
155 RefPtrWillBeMember
<InspectorBackendDispatcher
> m_inspectorBackendDispatcher
;
156 OwnPtr
<InspectorFrontend
> m_inspectorFrontend
;
157 InspectorAgentRegistry m_agents
;
158 OwnPtrWillBeMember
<AsyncCallTracker
> m_asyncCallTracker
;
159 bool m_deferredAgentsInitialized
;
161 typedef Vector
<RefPtr
<JSONObject
>> NotificationQueue
;
162 NotificationQueue m_notificationQueue
;
163 String m_stateCookie
;
165 friend class DebuggerTask
;