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>
43 HRESULT STDMETHODCALLTYPE UIDelegate::QueryInterface(REFIID riid, void** ppvObject)
46 if (IsEqualGUID(riid, IID_IUnknown))
47 *ppvObject = static_cast<IWebUIDelegate*>(this);
48 else if (IsEqualGUID(riid, IID_IWebUIDelegate))
49 *ppvObject = static_cast<IWebUIDelegate*>(this);
50 else if (IsEqualGUID(riid, IID_IWebUIDelegatePrivate))
51 *ppvObject = static_cast<IWebUIDelegatePrivate*>(this);
59 ULONG STDMETHODCALLTYPE UIDelegate::AddRef()
64 ULONG STDMETHODCALLTYPE UIDelegate::Release()
66 ULONG newRef = --m_refCount;
73 HRESULT STDMETHODCALLTYPE UIDelegate::hasCustomMenuImplementation(
74 /* [retval][out] */ BOOL *hasCustomMenus)
76 *hasCustomMenus = FALSE;
81 HRESULT STDMETHODCALLTYPE UIDelegate::setFrame(
82 /* [in] */ IWebView* /*sender*/,
83 /* [in] */ RECT* frame)
89 HRESULT STDMETHODCALLTYPE UIDelegate::webViewFrame(
90 /* [in] */ IWebView* /*sender*/,
91 /* [retval][out] */ RECT* frame)
97 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptAlertPanelWithMessage(
98 /* [in] */ IWebView* /*sender*/,
99 /* [in] */ BSTR message)
101 wprintf(L"ALERT: %s\n", message ? message : L"");
106 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptConfirmPanelWithMessage(
107 /* [in] */ IWebView* sender,
108 /* [in] */ BSTR message,
109 /* [retval][out] */ BOOL* result)
111 wprintf(L"CONFIRM: %s\n", message ? message : L"");
117 HRESULT STDMETHODCALLTYPE UIDelegate::runJavaScriptTextInputPanelWithPrompt(
118 /* [in] */ IWebView *sender,
119 /* [in] */ BSTR message,
120 /* [in] */ BSTR defaultText,
121 /* [retval][out] */ BSTR *result)
123 wprintf(L"PROMPT: %s, default text: %s\n", message ? message : L"", defaultText ? defaultText : L"");
124 *result = SysAllocString(defaultText);
129 HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole(
130 /* [in] */ IWebView* sender,
131 /* [in] */ BSTR message,
132 /* [in] */ int lineNumber,
134 /* [in] */ BOOL isError)
136 wprintf(L"CONSOLE MESSAGE: line %d: %s\n", lineNumber, message ? message : L"");
141 HRESULT STDMETHODCALLTYPE UIDelegate::doDragDrop(
142 /* [in] */ IWebView* sender,
143 /* [in] */ IDataObject* object,
144 /* [in] */ IDropSource* source,
145 /* [in] */ DWORD okEffect,
146 /* [retval][out] */ DWORD* performedEffect)
148 if (!performedEffect)
151 *performedEffect = 0;
153 draggingInfo = new DraggingInfo(object, source);
158 HRESULT STDMETHODCALLTYPE UIDelegate::webViewGetDlgCode(
159 /* [in] */ IWebView* /*sender*/,
160 /* [in] */ UINT /*keyCode*/,
161 /* [retval][out] */ LONG_PTR *code)