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