• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2005, 2006, 2007 Apple 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
6  * are met:
7  *
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.
16  *
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.
27  */
28 
29 #ifndef UIDelegate_h
30 #define UIDelegate_h
31 
32 #include <WebCore/COMPtr.h>
33 #include <WebKit/WebKit.h>
34 #include <wtf/OwnPtr.h>
35 #include <windef.h>
36 
37 class DRTUndoManager;
38 class DRTDesktopNotificationPresenter;
39 
40 class UIDelegate : public IWebUIDelegate2, IWebUIDelegatePrivate {
41 public:
42     UIDelegate();
43 
44     void resetUndoManager();
45 
46     // IUnknown
47     virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
48     virtual ULONG STDMETHODCALLTYPE AddRef(void);
49     virtual ULONG STDMETHODCALLTYPE Release(void);
50 
51     // IWebUIDelegate
52     virtual HRESULT STDMETHODCALLTYPE createWebViewWithRequest(
53         /* [in] */ IWebView *sender,
54         /* [in] */ IWebURLRequest *request,
55         /* [retval][out] */ IWebView **newWebView);
56 
webViewShow(IWebView * sender)57     virtual HRESULT STDMETHODCALLTYPE webViewShow(
58         /* [in] */ IWebView *sender) { return E_NOTIMPL; }
59 
60     virtual HRESULT STDMETHODCALLTYPE webViewClose(
61         /* [in] */ IWebView *sender);
62 
63     virtual HRESULT STDMETHODCALLTYPE webViewFocus(
64         /* [in] */ IWebView *sender);
65 
66     virtual HRESULT STDMETHODCALLTYPE webViewUnfocus(
67         /* [in] */ IWebView *sender);
68 
webViewFirstResponder(IWebView * sender,OLE_HANDLE * responder)69     virtual HRESULT STDMETHODCALLTYPE webViewFirstResponder(
70         /* [in] */ IWebView *sender,
71         /* [retval][out] */ OLE_HANDLE *responder) { return E_NOTIMPL; }
72 
makeFirstResponder(IWebView * sender,OLE_HANDLE responder)73     virtual HRESULT STDMETHODCALLTYPE makeFirstResponder(
74         /* [in] */ IWebView *sender,
75         /* [in] */ OLE_HANDLE responder) { return E_NOTIMPL; }
76 
77     virtual HRESULT STDMETHODCALLTYPE setStatusText(
78         /* [in] */ IWebView *sender,
79         /* [in] */ BSTR text);
80 
webViewStatusText(IWebView * sender,BSTR * text)81     virtual HRESULT STDMETHODCALLTYPE webViewStatusText(
82         /* [in] */ IWebView *sender,
83         /* [retval][out] */ BSTR *text) { return E_NOTIMPL; }
84 
webViewAreToolbarsVisible(IWebView * sender,BOOL * visible)85     virtual HRESULT STDMETHODCALLTYPE webViewAreToolbarsVisible(
86         /* [in] */ IWebView *sender,
87         /* [retval][out] */ BOOL *visible) { return E_NOTIMPL; }
88 
setToolbarsVisible(IWebView * sender,BOOL visible)89     virtual HRESULT STDMETHODCALLTYPE setToolbarsVisible(
90         /* [in] */ IWebView *sender,
91         /* [in] */ BOOL visible) { return E_NOTIMPL; }
92 
webViewIsStatusBarVisible(IWebView * sender,BOOL * visible)93     virtual HRESULT STDMETHODCALLTYPE webViewIsStatusBarVisible(
94         /* [in] */ IWebView *sender,
95         /* [retval][out] */ BOOL *visible) { return E_NOTIMPL; }
96 
setStatusBarVisible(IWebView * sender,BOOL visible)97     virtual HRESULT STDMETHODCALLTYPE setStatusBarVisible(
98         /* [in] */ IWebView *sender,
99         /* [in] */ BOOL visible) { return E_NOTIMPL; }
100 
webViewIsResizable(IWebView * sender,BOOL * resizable)101     virtual HRESULT STDMETHODCALLTYPE webViewIsResizable(
102         /* [in] */ IWebView *sender,
103         /* [retval][out] */ BOOL *resizable) { return E_NOTIMPL; }
104 
setResizable(IWebView * sender,BOOL resizable)105     virtual HRESULT STDMETHODCALLTYPE setResizable(
106         /* [in] */ IWebView *sender,
107         /* [in] */ BOOL resizable) { return E_NOTIMPL; }
108 
109     virtual HRESULT STDMETHODCALLTYPE setFrame(
110         /* [in] */ IWebView *sender,
111         /* [in] */ RECT *frame);
112 
113     virtual HRESULT STDMETHODCALLTYPE webViewFrame(
114         /* [in] */ IWebView *sender,
115         /* [retval][out] */ RECT *frame);
116 
setContentRect(IWebView * sender,RECT * contentRect)117     virtual HRESULT STDMETHODCALLTYPE setContentRect(
118         /* [in] */ IWebView *sender,
119         /* [in] */ RECT *contentRect) { return E_NOTIMPL; }
120 
webViewContentRect(IWebView * sender,RECT * contentRect)121     virtual HRESULT STDMETHODCALLTYPE webViewContentRect(
122         /* [in] */ IWebView *sender,
123         /* [retval][out] */ RECT *contentRect) { return E_NOTIMPL; }
124 
125     virtual HRESULT STDMETHODCALLTYPE runJavaScriptAlertPanelWithMessage(
126         /* [in] */ IWebView *sender,
127         /* [in] */ BSTR message);
128 
129     virtual HRESULT STDMETHODCALLTYPE runJavaScriptConfirmPanelWithMessage(
130         /* [in] */ IWebView *sender,
131         /* [in] */ BSTR message,
132         /* [retval][out] */ BOOL *result);
133 
134     virtual HRESULT STDMETHODCALLTYPE runJavaScriptTextInputPanelWithPrompt(
135         /* [in] */ IWebView *sender,
136         /* [in] */ BSTR message,
137         /* [in] */ BSTR defaultText,
138         /* [retval][out] */ BSTR *result);
139 
140     virtual HRESULT STDMETHODCALLTYPE runBeforeUnloadConfirmPanelWithMessage(
141         /* [in] */ IWebView *sender,
142         /* [in] */ BSTR message,
143         /* [in] */ IWebFrame *initiatedByFrame,
144         /* [retval][out] */ BOOL *result);
145 
runOpenPanelForFileButtonWithResultListener(IWebView * sender,IWebOpenPanelResultListener * resultListener)146     virtual HRESULT STDMETHODCALLTYPE runOpenPanelForFileButtonWithResultListener(
147         /* [in] */ IWebView *sender,
148         /* [in] */ IWebOpenPanelResultListener *resultListener) { return E_NOTIMPL; }
149 
mouseDidMoveOverElement(IWebView * sender,IPropertyBag * elementInformation,UINT modifierFlags)150     virtual HRESULT STDMETHODCALLTYPE mouseDidMoveOverElement(
151         /* [in] */ IWebView *sender,
152         /* [in] */ IPropertyBag *elementInformation,
153         /* [in] */ UINT modifierFlags) { return E_NOTIMPL; }
154 
contextMenuItemsForElement(IWebView * sender,IPropertyBag * element,OLE_HANDLE defaultItems,OLE_HANDLE * resultMenu)155     virtual HRESULT STDMETHODCALLTYPE contextMenuItemsForElement(
156         /* [in] */ IWebView *sender,
157         /* [in] */ IPropertyBag *element,
158         /* [in] */ OLE_HANDLE defaultItems,
159         /* [retval][out] */ OLE_HANDLE *resultMenu) { return E_NOTIMPL; }
160 
validateUserInterfaceItem(IWebView * webView,UINT itemCommandID,BOOL defaultValidation,BOOL * isValid)161     virtual HRESULT STDMETHODCALLTYPE validateUserInterfaceItem(
162         /* [in] */ IWebView *webView,
163         /* [in] */ UINT itemCommandID,
164         /* [in] */ BOOL defaultValidation,
165         /* [retval][out] */ BOOL *isValid) { return E_NOTIMPL; }
166 
shouldPerformAction(IWebView * webView,UINT itemCommandID,UINT sender)167     virtual HRESULT STDMETHODCALLTYPE shouldPerformAction(
168         /* [in] */ IWebView *webView,
169         /* [in] */ UINT itemCommandID,
170         /* [in] */ UINT sender) { return E_NOTIMPL; }
171 
dragDestinationActionMaskForDraggingInfo(IWebView * webView,IDataObject * draggingInfo,WebDragDestinationAction * action)172     virtual HRESULT STDMETHODCALLTYPE dragDestinationActionMaskForDraggingInfo(
173         /* [in] */ IWebView *webView,
174         /* [in] */ IDataObject *draggingInfo,
175         /* [retval][out] */ WebDragDestinationAction *action) { return E_NOTIMPL; }
176 
willPerformDragDestinationAction(IWebView * webView,WebDragDestinationAction action,IDataObject * draggingInfo)177     virtual HRESULT STDMETHODCALLTYPE willPerformDragDestinationAction(
178         /* [in] */ IWebView *webView,
179         /* [in] */ WebDragDestinationAction action,
180         /* [in] */ IDataObject *draggingInfo) { return E_NOTIMPL; }
181 
dragSourceActionMaskForPoint(IWebView * webView,LPPOINT point,WebDragSourceAction * action)182     virtual HRESULT STDMETHODCALLTYPE dragSourceActionMaskForPoint(
183         /* [in] */ IWebView *webView,
184         /* [in] */ LPPOINT point,
185         /* [retval][out] */ WebDragSourceAction *action) { return E_NOTIMPL; }
186 
willPerformDragSourceAction(IWebView * webView,WebDragSourceAction action,LPPOINT point,IDataObject * pasteboard,IDataObject ** newPasteboard)187     virtual HRESULT STDMETHODCALLTYPE willPerformDragSourceAction(
188         /* [in] */ IWebView *webView,
189         /* [in] */ WebDragSourceAction action,
190         /* [in] */ LPPOINT point,
191         /* [in] */ IDataObject *pasteboard,
192         /* [retval][out] */ IDataObject **newPasteboard) { return E_NOTIMPL; }
193 
contextMenuItemSelected(IWebView * sender,void * item,IPropertyBag * element)194     virtual HRESULT STDMETHODCALLTYPE contextMenuItemSelected(
195         /* [in] */ IWebView *sender,
196         /* [in] */ void *item,
197         /* [in] */ IPropertyBag *element) { return E_NOTIMPL; }
198 
199     virtual HRESULT STDMETHODCALLTYPE hasCustomMenuImplementation(
200         /* [retval][out] */ BOOL *hasCustomMenus);
201 
202     virtual HRESULT STDMETHODCALLTYPE trackCustomPopupMenu(
203         /* [in] */ IWebView *sender,
204         /* [in] */ OLE_HANDLE menu,
205         /* [in] */ LPPOINT point);
206 
measureCustomMenuItem(IWebView * sender,void * measureItem)207     virtual HRESULT STDMETHODCALLTYPE measureCustomMenuItem(
208         /* [in] */ IWebView *sender,
209         /* [in] */ void *measureItem) { return E_NOTIMPL; }
210 
drawCustomMenuItem(IWebView * sender,void * drawItem)211     virtual HRESULT STDMETHODCALLTYPE drawCustomMenuItem(
212         /* [in] */ IWebView *sender,
213         /* [in] */ void *drawItem) { return E_NOTIMPL; }
214 
addCustomMenuDrawingData(IWebView * sender,OLE_HANDLE menu)215     virtual HRESULT STDMETHODCALLTYPE addCustomMenuDrawingData(
216         /* [in] */ IWebView *sender,
217         /* [in] */ OLE_HANDLE menu) { return E_NOTIMPL; }
218 
cleanUpCustomMenuDrawingData(IWebView * sender,OLE_HANDLE menu)219     virtual HRESULT STDMETHODCALLTYPE cleanUpCustomMenuDrawingData(
220         /* [in] */ IWebView *sender,
221         /* [in] */ OLE_HANDLE menu) { return E_NOTIMPL; }
222 
canTakeFocus(IWebView * sender,BOOL forward,BOOL * result)223     virtual HRESULT STDMETHODCALLTYPE canTakeFocus(
224         /* [in] */ IWebView *sender,
225         /* [in] */ BOOL forward,
226         /* [out] */ BOOL *result) { return E_NOTIMPL; }
227 
takeFocus(IWebView * sender,BOOL forward)228     virtual HRESULT STDMETHODCALLTYPE takeFocus(
229         /* [in] */ IWebView *sender,
230         /* [in] */ BOOL forward) { return E_NOTIMPL; }
231 
232     virtual HRESULT STDMETHODCALLTYPE registerUndoWithTarget(
233         /* [in] */ IWebUndoTarget *target,
234         /* [in] */ BSTR actionName,
235         /* [in] */ IUnknown *actionArg);
236 
237     virtual HRESULT STDMETHODCALLTYPE removeAllActionsWithTarget(
238         /* [in] */ IWebUndoTarget *target);
239 
240     virtual HRESULT STDMETHODCALLTYPE setActionTitle(
241         /* [in] */ BSTR actionTitle);
242 
243     virtual HRESULT STDMETHODCALLTYPE undo();
244 
245     virtual HRESULT STDMETHODCALLTYPE redo();
246 
247     virtual HRESULT STDMETHODCALLTYPE canUndo(
248         /* [retval][out] */ BOOL *result);
249 
250     virtual HRESULT STDMETHODCALLTYPE canRedo(
251         /* [retval][out] */ BOOL *result);
252 
253     virtual HRESULT STDMETHODCALLTYPE printFrame(
254         /* [in] */ IWebView *webView,
255         /* [in] */ IWebFrame *frame);
256 
257     virtual HRESULT STDMETHODCALLTYPE ftpDirectoryTemplatePath(
258         /* [in] */ IWebView *webView,
259         /* [retval][out] */ BSTR *path);
260 
261     virtual HRESULT STDMETHODCALLTYPE webViewHeaderHeight(
262         /* [in] */ IWebView *webView,
263         /* [retval][out] */ float *result);
264 
265     virtual HRESULT STDMETHODCALLTYPE webViewFooterHeight(
266         /* [in] */ IWebView *webView,
267         /* [retval][out] */ float *result);
268 
269     virtual HRESULT STDMETHODCALLTYPE drawHeaderInRect(
270         /* [in] */ IWebView *webView,
271         /* [in] */ RECT *rect,
272         /* [in] */ OLE_HANDLE drawingContext);
273 
274     virtual HRESULT STDMETHODCALLTYPE drawFooterInRect(
275         /* [in] */ IWebView *webView,
276         /* [in] */ RECT *rect,
277         /* [in] */ OLE_HANDLE drawingContext,
278         /* [in] */ UINT pageIndex,
279         /* [in] */ UINT pageCount);
280 
281     virtual HRESULT STDMETHODCALLTYPE webViewPrintingMarginRect(
282         /* [in] */ IWebView *webView,
283         /* [retval][out] */ RECT *rect);
284 
285     virtual HRESULT STDMETHODCALLTYPE canRunModal(
286         /* [in] */ IWebView *webView,
287         /* [retval][out] */ BOOL *canRunBoolean);
288 
289     virtual HRESULT STDMETHODCALLTYPE createModalDialog(
290         /* [in] */ IWebView *sender,
291         /* [in] */ IWebURLRequest *request,
292         /* [retval][out] */ IWebView **newWebView);
293 
294     virtual HRESULT STDMETHODCALLTYPE runModal(
295         /* [in] */ IWebView *webView);
296 
297     virtual HRESULT STDMETHODCALLTYPE isMenuBarVisible(
298         /* [in] */ IWebView *webView,
299         /* [retval][out] */ BOOL *visible);
300 
301     virtual HRESULT STDMETHODCALLTYPE setMenuBarVisible(
302         /* [in] */ IWebView *webView,
303         /* [in] */ BOOL visible);
304 
305     virtual HRESULT STDMETHODCALLTYPE runDatabaseSizeLimitPrompt(
306         /* [in] */ IWebView *webView,
307         /* [in] */ BSTR displayName,
308         /* [in] */ IWebFrame *initiatedByFrame,
309         /* [retval][out] */ BOOL *allowed);
310 
311     virtual HRESULT STDMETHODCALLTYPE paintCustomScrollbar(
312         /* [in] */ IWebView *webView,
313         /* [in] */ HDC hDC,
314         /* [in] */ RECT rect,
315         /* [in] */ WebScrollBarControlSize size,
316         /* [in] */ WebScrollbarControlState state,
317         /* [in] */ WebScrollbarControlPart pressedPart,
318         /* [in] */ BOOL vertical,
319         /* [in] */ float value,
320         /* [in] */ float proportion,
321         /* [in] */ WebScrollbarControlPartMask parts);
322 
323     virtual HRESULT STDMETHODCALLTYPE paintCustomScrollCorner(
324         /* [in] */ IWebView *webView,
325         /* [in] */ HDC hDC,
326         /* [in] */ RECT rect);
327 
328 protected:
329     // IWebUIDelegatePrivate
330 
unused1()331     virtual HRESULT STDMETHODCALLTYPE unused1() { return E_NOTIMPL; }
332 
unused2()333     virtual HRESULT STDMETHODCALLTYPE unused2() { return E_NOTIMPL; }
334 
unused3()335     virtual HRESULT STDMETHODCALLTYPE unused3() { return E_NOTIMPL; }
336 
webViewScrolled(IWebView * sender)337     virtual HRESULT STDMETHODCALLTYPE webViewScrolled(
338         /* [in] */ IWebView *sender) { return E_NOTIMPL; }
339 
340     virtual HRESULT STDMETHODCALLTYPE webViewAddMessageToConsole(
341         /* [in] */ IWebView *sender,
342         /* [in] */ BSTR message,
343         /* [in] */ int lineNumber,
344         /* [in] */ BSTR url,
345         /* [in] */ BOOL isError);
346 
webViewShouldInterruptJavaScript(IWebView * sender,BOOL * result)347     virtual HRESULT STDMETHODCALLTYPE webViewShouldInterruptJavaScript(
348         /* [in] */ IWebView *sender,
349         /* [retval][out] */ BOOL *result) { return E_NOTIMPL; }
350 
webViewReceivedFocus(IWebView * sender)351     virtual HRESULT STDMETHODCALLTYPE webViewReceivedFocus(
352         /* [in] */ IWebView *sender) { return E_NOTIMPL; }
353 
webViewLostFocus(IWebView * sender,OLE_HANDLE loseFocusTo)354     virtual HRESULT STDMETHODCALLTYPE webViewLostFocus(
355         /* [in] */ IWebView *sender,
356         /* [in] */ OLE_HANDLE loseFocusTo) { return E_NOTIMPL; }
357 
358     virtual HRESULT STDMETHODCALLTYPE doDragDrop(
359         /* [in] */ IWebView *sender,
360         /* [in] */ IDataObject *dataObject,
361         /* [in] */ IDropSource *dropSource,
362         /* [in] */ DWORD okEffect,
363         /* [retval][out] */ DWORD *performedEffect);
364 
365     virtual HRESULT STDMETHODCALLTYPE webViewGetDlgCode(
366         /* [in] */ IWebView *sender,
367         /* [in] */ UINT keyCode,
368         /* [retval][out] */ LONG_PTR *code);
369 
370     virtual HRESULT STDMETHODCALLTYPE webViewPainted(
371         /* [in] */ IWebView *sender);
372 
373     virtual HRESULT STDMETHODCALLTYPE exceededDatabaseQuota(
374         /* [in] */ IWebView *sender,
375         /* [in] */ IWebFrame *frame,
376         /* [in] */ IWebSecurityOrigin *origin,
377         /* [in] */ BSTR databaseIdentifier);
378 
379     virtual HRESULT STDMETHODCALLTYPE embeddedViewWithArguments(
380         /* [in] */ IWebView *sender,
381         /* [in] */ IWebFrame *frame,
382         /* [in] */ IPropertyBag *arguments,
383         /* [retval][out] */ IWebEmbeddedView **view);
384 
385     virtual HRESULT STDMETHODCALLTYPE webViewClosing(
386         /* [in] */ IWebView *sender);
387 
388     virtual HRESULT STDMETHODCALLTYPE webViewSetCursor(
389         /* [in] */ IWebView *sender,
390         /* [in] */ OLE_HANDLE cursor);
391 
392     virtual HRESULT STDMETHODCALLTYPE webViewDidInvalidate(
393         /* [in] */ IWebView *sender);
394 
395     virtual HRESULT STDMETHODCALLTYPE desktopNotificationsDelegate(
396         /* [out] */ IWebDesktopNotificationsDelegate** result);
397 
398     ULONG                   m_refCount;
399 
400 private:
401     RECT m_frame;
402     OwnPtr<DRTUndoManager> m_undoManager;
403 
404     COMPtr<IWebDesktopNotificationsDelegate> m_desktopNotifications;
405 };
406 
407 #endif
408