|
1 /* |
|
2 * Copyright (C) 2010 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 WebDevToolsAgentImpl_h |
|
32 #define WebDevToolsAgentImpl_h |
|
33 |
|
34 #include "InspectorClient.h" |
|
35 |
|
36 #include "APUAgentDelegate.h" |
|
37 #include "DevToolsRPC.h" |
|
38 #include "ToolsAgent.h" |
|
39 #include "WebDevToolsAgentPrivate.h" |
|
40 |
|
41 #include <v8.h> |
|
42 #include <wtf/OwnPtr.h> |
|
43 |
|
44 namespace WebCore { |
|
45 class Document; |
|
46 class InspectorClient; |
|
47 class InspectorController; |
|
48 class Node; |
|
49 class String; |
|
50 } |
|
51 |
|
52 namespace WebKit { |
|
53 |
|
54 class DebuggerAgentDelegateStub; |
|
55 class DebuggerAgentImpl; |
|
56 class WebDevToolsAgentClient; |
|
57 class WebFrame; |
|
58 class WebFrameImpl; |
|
59 class WebString; |
|
60 class WebURLRequest; |
|
61 class WebURLResponse; |
|
62 class WebViewImpl; |
|
63 struct WebURLError; |
|
64 struct WebDevToolsMessageData; |
|
65 |
|
66 class WebDevToolsAgentImpl : public WebDevToolsAgentPrivate, |
|
67 public ToolsAgent, |
|
68 public DevToolsRPC::Delegate, |
|
69 public WebCore::InspectorClient { |
|
70 public: |
|
71 WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client); |
|
72 virtual ~WebDevToolsAgentImpl(); |
|
73 |
|
74 // ToolsAgent implementation. |
|
75 virtual void dispatchOnInspectorController(int callId, const WebCore::String& functionName, const WebCore::String& jsonArgs); |
|
76 virtual void dispatchOnInjectedScript(int callId, int injectedScriptId, const WebCore::String& functionName, const WebCore::String& jsonArgs, bool async); |
|
77 |
|
78 // WebDevToolsAgentPrivate implementation. |
|
79 virtual void didClearWindowObject(WebFrameImpl* frame); |
|
80 |
|
81 // WebDevToolsAgent implementation. |
|
82 virtual void attach(); |
|
83 virtual void detach(); |
|
84 virtual void didNavigate(); |
|
85 virtual void dispatchMessageFromFrontend(const WebDevToolsMessageData& data); |
|
86 virtual void inspectElementAt(const WebPoint& point); |
|
87 virtual void evaluateInWebInspector(long callId, const WebString& script); |
|
88 virtual void setRuntimeFeatureEnabled(const WebString& feature, bool enabled); |
|
89 virtual void setTimelineProfilingEnabled(bool enable); |
|
90 |
|
91 virtual void identifierForInitialRequest(unsigned long, WebFrame*, const WebURLRequest&); |
|
92 virtual void willSendRequest(unsigned long, WebURLRequest&); |
|
93 virtual void didReceiveData(unsigned long, int length); |
|
94 virtual void didReceiveResponse(unsigned long, const WebURLResponse&); |
|
95 virtual void didFinishLoading(unsigned long); |
|
96 virtual void didFailLoading(unsigned long, const WebURLError&); |
|
97 |
|
98 // InspectorClient implementation. |
|
99 virtual void inspectorDestroyed(); |
|
100 virtual void openInspectorFrontend(WebCore::InspectorController*); |
|
101 virtual void highlight(WebCore::Node*); |
|
102 virtual void hideHighlight(); |
|
103 virtual void populateSetting(const WebCore::String& key, WebCore::String* value); |
|
104 virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); |
|
105 virtual void resourceTrackingWasEnabled(); |
|
106 virtual void resourceTrackingWasDisabled(); |
|
107 virtual void timelineProfilerWasStarted(); |
|
108 virtual void timelineProfilerWasStopped(); |
|
109 virtual bool sendMessageToFrontend(const WebCore::String&); |
|
110 |
|
111 // DevToolsRPC::Delegate implementation. |
|
112 virtual void sendRpcMessage(const WebDevToolsMessageData& data); |
|
113 |
|
114 void forceRepaint(); |
|
115 |
|
116 int hostId() { return m_hostId; } |
|
117 |
|
118 private: |
|
119 static v8::Handle<v8::Value> jsDispatchOnClient(const v8::Arguments& args); |
|
120 |
|
121 void disposeUtilityContext(); |
|
122 |
|
123 void compileUtilityScripts(); |
|
124 void initDevToolsAgentHost(); |
|
125 void createInspectorFrontendProxy(); |
|
126 void setInspectorFrontendProxyToInspectorController(); |
|
127 void setApuAgentEnabled(bool enabled); |
|
128 |
|
129 WebCore::InspectorController* inspectorController(); |
|
130 |
|
131 // Creates InspectorBackend v8 wrapper in the utility context so that it's |
|
132 // methods prototype is Function.protoype object from the utility context. |
|
133 // Otherwise some useful methods defined on Function.prototype(such as bind) |
|
134 // are missing for InspectorController native methods. |
|
135 v8::Local<v8::Object> createInspectorBackendV8Wrapper(); |
|
136 |
|
137 int m_hostId; |
|
138 WebDevToolsAgentClient* m_client; |
|
139 WebViewImpl* m_webViewImpl; |
|
140 OwnPtr<DebuggerAgentDelegateStub> m_debuggerAgentDelegateStub; |
|
141 OwnPtr<ToolsAgentDelegateStub> m_toolsAgentDelegateStub; |
|
142 OwnPtr<DebuggerAgentImpl> m_debuggerAgentImpl; |
|
143 OwnPtr<ApuAgentDelegateStub> m_apuAgentDelegateStub; |
|
144 bool m_apuAgentEnabled; |
|
145 bool m_resourceTrackingWasEnabled; |
|
146 bool m_attached; |
|
147 // TODO(pfeldman): This should not be needed once GC styles issue is fixed |
|
148 // for matching rules. |
|
149 v8::Persistent<v8::Context> m_utilityContext; |
|
150 }; |
|
151 |
|
152 } // namespace WebKit |
|
153 |
|
154 #endif |