2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2006, 2007 Vladimir Olexa (vladimir.olexa@gmail.com)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "ServerConnection.h"
33 #include "DebuggerDocument.h"
35 #include <JavaScriptCore/JSContextRef.h>
36 #include <JavaScriptCore/JSRetainPtr.h>
37 #include <JavaScriptCore/JSStringRefCF.h>
38 #include <JavaScriptCore/RetainPtr.h>
39 #include <WebKit/WebKit.h>
41 // FIXME: Some of the below functionality cannot be implemented until the WebScriptDebug Server works on windows.
42 ServerConnection::ServerConnection()
45 HRESULT serverCreated = CoCreateInstance(CLSID_WebScriptDebugServer, 0, CLSCTX_LOCAL_SERVER, IID_IWebScriptDebugServer, (void**)&m_server);
46 if (!FAILED(serverCreated))
47 m_server->addListener(this);
50 ServerConnection::~ServerConnection()
53 m_server->removeListener(this);
56 JSGlobalContextRelease(m_globalContext);
59 void ServerConnection::setGlobalContext(JSGlobalContextRef globalContextRef)
61 m_globalContext = JSGlobalContextRetain(globalContextRef);
64 void ServerConnection::pause()
70 void ServerConnection::resume()
76 void ServerConnection::stepInto()
82 // Connection Handling
84 void ServerConnection::applicationTerminating()
87 m_server->removeListener(this);
90 void ServerConnection::serverConnectionDidDie()
93 m_server->removeListener(this);
98 WebScriptCallFrame* ServerConnection::currentFrame() const
100 return m_currentFrame;
104 // IUnknown --------------------------------------------------
105 HRESULT STDMETHODCALLTYPE ServerConnection::QueryInterface(REFIID riid, void** ppvObject)
108 if (IsEqualGUID(riid, IID_IUnknown))
110 else if (IsEqualGUID(riid, IID_IWebScriptDebugListener))
111 *ppvObject = static_cast<IWebScriptDebugListener*>(this);
113 return E_NOINTERFACE;
119 ULONG STDMETHODCALLTYPE ServerConnection::AddRef(void)
121 // COM ref-counting isn't useful to us because we're in charge of the lifetime of the WebView.
125 ULONG STDMETHODCALLTYPE ServerConnection::Release(void)
127 // COM ref-counting isn't useful to us because we're in charge of the lifetime of the WebView.
130 // IWebScriptDebugListener -----------------------------------
131 HRESULT STDMETHODCALLTYPE ServerConnection::didLoadMainResourceForDataSource(
132 /* [in] */ IWebView* /*view*/,
133 /* [in] */ IWebDataSource* /*dataSource*/)
138 HRESULT STDMETHODCALLTYPE ServerConnection::didParseSource(
139 /* [in] */ IWebView* /*view*/,
140 /* [in] */ BSTR /*sourceCode*/,
141 /* [in] */ UINT /*baseLineNumber*/,
142 /* [in] */ BSTR /*url*/,
143 /* [in] */ int /*sourceID*/,
144 /* [in] */ IWebFrame* /*forWebFrame*/)
149 HRESULT STDMETHODCALLTYPE ServerConnection::failedToParseSource(
150 /* [in] */ IWebView* /*view*/,
151 /* [in] */ BSTR /*sourceCode*/,
152 /* [in] */ UINT /*baseLineNumber*/,
153 /* [in] */ BSTR /*url*/,
154 /* [in] */ BSTR /*error*/,
155 /* [in] */ IWebFrame* /*forWebFrame*/)
160 HRESULT STDMETHODCALLTYPE ServerConnection::didEnterCallFrame(
161 /* [in] */ IWebView* /*view*/,
162 /* [in] */ IWebScriptCallFrame* /*frame*/,
163 /* [in] */ int /*sourceID*/,
164 /* [in] */ int /*lineNumber*/,
165 /* [in] */ IWebFrame* /*forWebFrame*/)
170 HRESULT STDMETHODCALLTYPE ServerConnection::willExecuteStatement(
171 /* [in] */ IWebView* /*view*/,
172 /* [in] */ IWebScriptCallFrame* /*frame*/,
173 /* [in] */ int /*sourceID*/,
174 /* [in] */ int /*lineNumber*/,
175 /* [in] */ IWebFrame* /*forWebFrame*/)
180 HRESULT STDMETHODCALLTYPE ServerConnection::willLeaveCallFrame(
181 /* [in] */ IWebView* /*view*/,
182 /* [in] */ IWebScriptCallFrame* /*frame*/,
183 /* [in] */ int /*sourceID*/,
184 /* [in] */ int /*lineNumber*/,
185 /* [in] */ IWebFrame* /*forWebFrame*/)
190 HRESULT STDMETHODCALLTYPE ServerConnection::exceptionWasRaised(
191 /* [in] */ IWebView* /*view*/,
192 /* [in] */ IWebScriptCallFrame* /*frame*/,
193 /* [in] */ int /*sourceID*/,
194 /* [in] */ int /*lineNumber*/,
195 /* [in] */ IWebFrame* /*forWebFrame*/)