2 * Copyright (C) 2005, 2006, 2007 Apple 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
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "DumpRenderTree.h"
30 #include "UIDelegate.h"
32 #include "DraggingInfo.h"
33 #include "EventSender.h"
35 #include <WebCore/COMPtr.h>
36 #include <wtf/Platform.h>
37 #include <JavaScriptCore/Assertions.h>
38 #include <JavaScriptCore/JavaScriptCore.h>
39 #include <WebKit/IWebFramePrivate.h>
40 #include <WebKit/IWebViewPrivate.h>
45 UIDelegate::UIDelegate()
54 HRESULT STDMETHODCALLTYPE UIDelegate::QueryInterface(REFIID riid, void** ppvObject)
57 if (IsEqualGUID(riid, IID_IUnknown))
58 *ppvObject = static_cast<IWebUIDelegate*>(this);
59 else if (IsEqualGUID(riid, IID_IWebUIDelegate))
60 *ppvObject = static_cast<IWebUIDelegate*>(this);
61 else if (IsEqualGUID(riid, IID_IWebUIDelegatePrivate))
62 *ppvObject = static_cast<IWebUIDelegatePrivate*>(this);
70 ULONG STDMETHODCALLTYPE UIDelegate::AddRef()
75 ULONG STDMETHODCALLTYPE UIDelegate::Release()
77 ULONG newRef = --m_refCount;
84 HRESULT STDMETHODCALLTYPE UIDelegate::hasCustomMenuImplementation(
85 /* [retval][out] */ BOOL *hasCustomMenus)
87 *hasCustomMenus = TRUE;
92 HRESULT STDMETHODCALLTYPE UIDelegate::trackCustomPopupMenu(
93 /* [in] */ IWebView *sender,
94 /* [in] */ OLE_HANDLE menu,
95 /* [in] */ LPPOINT point)
101 HRESULT STDMETHODCALLTYPE UIDelegate::setFrame(
102 /* [in] */ IWebView* /*sender*/,
103 /* [in] */ RECT* frame)
109 HRESULT STDMETHODCALLTYPE UIDelegate::webViewFrame(
110 /* [in] */ IWebView* /*sender*/,
111 /* [retval][out] */ RECT* frame)
117 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptAlertPanelWithMessage(
118 /* [in] */ IWebView* /*sender*/,
119 /* [in] */ BSTR message)
121 printf("ALERT: %S\n", message ? message : L"");
126 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptConfirmPanelWithMessage(
127 /* [in] */ IWebView* sender,
128 /* [in] */ BSTR message,
129 /* [retval][out] */ BOOL* result)
131 printf("CONFIRM: %S\n", message ? message : L"");
137 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptTextInputPanelWithPrompt(
138 /* [in] */ IWebView *sender,
139 /* [in] */ BSTR message,
140 /* [in] */ BSTR defaultText,
141 /* [retval][out] */ BSTR *result)
143 printf("PROMPT: %S, default text: %S\n", message ? message : L"", defaultText ? defaultText : L"");
144 *result = SysAllocString(defaultText);
149 HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole(
150 /* [in] */ IWebView* sender,
151 /* [in] */ BSTR message,
152 /* [in] */ int lineNumber,
154 /* [in] */ BOOL isError)
158 newMessage = message;
159 int fileProtocol = newMessage.find(L"file://");
161 newMessage = newMessage.substr(0, fileProtocol) + urlSuitableForTestResult(newMessage);
164 printf("CONSOLE MESSAGE: line %d: %S\n", lineNumber, message ? newMessage.c_str() : L"");
168 HRESULT STDMETHODCALLTYPE UIDelegate::doDragDrop(
169 /* [in] */ IWebView* sender,
170 /* [in] */ IDataObject* object,
171 /* [in] */ IDropSource* source,
172 /* [in] */ DWORD okEffect,
173 /* [retval][out] */ DWORD* performedEffect)
175 if (!performedEffect)
178 *performedEffect = 0;
180 draggingInfo = new DraggingInfo(object, source);
185 HRESULT STDMETHODCALLTYPE UIDelegate::webViewGetDlgCode(
186 /* [in] */ IWebView* /*sender*/,
187 /* [in] */ UINT /*keyCode*/,
188 /* [retval][out] */ LONG_PTR *code)