1/* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 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 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#import <WebKitLegacy/WebAllowDenyPolicyListener.h> 30#import <WebKitLegacy/WebUIDelegate.h> 31 32#if !defined(ENABLE_DASHBOARD_SUPPORT) 33#if !TARGET_OS_IPHONE 34#define ENABLE_DASHBOARD_SUPPORT 1 35#else 36#define ENABLE_DASHBOARD_SUPPORT 0 37#endif 38#endif 39 40#if !defined(ENABLE_FULLSCREEN_API) 41#if !TARGET_OS_IPHONE 42#define ENABLE_FULLSCREEN_API 1 43#else 44#define ENABLE_FULLSCREEN_API 0 45#endif 46#endif 47 48// Mail on Tiger expects the old value for WebMenuItemTagSearchInGoogle 49#define WebMenuItemTagSearchInGoogle OldWebMenuItemTagSearchWeb 50 51#define WEBMENUITEMTAG_WEBKIT_3_0_SPI_START 2000 52enum { 53 // The next three values were used in WebKit 2.0 for SPI. In WebKit 3.0 these are API, with different values. 54 OldWebMenuItemTagSearchInSpotlight = 1000, 55 OldWebMenuItemTagSearchWeb, 56 OldWebMenuItemTagLookUpInDictionary, 57 // FIXME: These should move to WebUIDelegate.h as part of the WebMenuItemTag enum there, when we're not in API freeze 58 // Note that these values must be kept aligned with values in WebCore/ContextMenuItem.h 59 WebMenuItemTagOpenLink = WEBMENUITEMTAG_WEBKIT_3_0_SPI_START, 60 WebMenuItemTagIgnoreGrammar, 61 WebMenuItemTagSpellingMenu, 62 WebMenuItemTagShowSpellingPanel, 63 WebMenuItemTagCheckSpelling, 64 WebMenuItemTagCheckSpellingWhileTyping, 65 WebMenuItemTagCheckGrammarWithSpelling, 66 WebMenuItemTagFontMenu, 67 WebMenuItemTagShowFonts, 68 WebMenuItemTagBold, 69 WebMenuItemTagItalic, 70 WebMenuItemTagUnderline, 71 WebMenuItemTagOutline, 72 WebMenuItemTagStyles, 73 WebMenuItemTagShowColors, 74 WebMenuItemTagSpeechMenu, 75 WebMenuItemTagStartSpeaking, 76 WebMenuItemTagStopSpeaking, 77 WebMenuItemTagWritingDirectionMenu, 78 WebMenuItemTagDefaultDirection, 79 WebMenuItemTagLeftToRight, 80 WebMenuItemTagRightToLeft, 81 WebMenuItemPDFSinglePageScrolling, 82 WebMenuItemPDFFacingPagesScrolling, 83 WebMenuItemTagInspectElement, 84 WebMenuItemTagTextDirectionMenu, 85 WebMenuItemTagTextDirectionDefault, 86 WebMenuItemTagTextDirectionLeftToRight, 87 WebMenuItemTagTextDirectionRightToLeft, 88 WebMenuItemTagCorrectSpellingAutomatically, 89 WebMenuItemTagSubstitutionsMenu, 90 WebMenuItemTagShowSubstitutions, 91 WebMenuItemTagSmartCopyPaste, 92 WebMenuItemTagSmartQuotes, 93 WebMenuItemTagSmartDashes, 94 WebMenuItemTagSmartLinks, 95 WebMenuItemTagTextReplacement, 96 WebMenuItemTagTransformationsMenu, 97 WebMenuItemTagMakeUpperCase, 98 WebMenuItemTagMakeLowerCase, 99 WebMenuItemTagCapitalize, 100 WebMenuItemTagChangeBack, 101 WebMenuItemTagOpenMediaInNewWindow, 102 WebMenuItemTagCopyMediaLinkToClipboard, 103 WebMenuItemTagToggleMediaControls, 104 WebMenuItemTagToggleMediaLoop, 105 WebMenuItemTagEnterVideoFullscreen, 106 WebMenuItemTagMediaPlayPause, 107 WebMenuItemTagMediaMute, 108 WebMenuItemTagDictationAlternative, 109 WebMenuItemBaseCustomTag = 5000, 110 WebMenuItemCustomTagNoAction = 5998, 111 WebMenuItemLastCustomTag = 5999, 112 WebMenuItemTagBaseApplication = 10000 113}; 114 115// Message Sources. 116extern NSString *WebConsoleMessageXMLMessageSource; 117extern NSString *WebConsoleMessageJSMessageSource; 118extern NSString *WebConsoleMessageNetworkMessageSource; 119extern NSString *WebConsoleMessageConsoleAPIMessageSource; 120extern NSString *WebConsoleMessageStorageMessageSource; 121extern NSString *WebConsoleMessageAppCacheMessageSource; 122extern NSString *WebConsoleMessageRenderingMessageSource; 123extern NSString *WebConsoleMessageCSSMessageSource; 124extern NSString *WebConsoleMessageSecurityMessageSource; 125extern NSString *WebConsoleMessageOtherMessageSource; 126 127// Message Levels. 128extern NSString *WebConsoleMessageDebugMessageLevel; 129extern NSString *WebConsoleMessageLogMessageLevel; 130extern NSString *WebConsoleMessageWarningMessageLevel; 131extern NSString *WebConsoleMessageErrorMessageLevel; 132 133@class DOMElement; 134@class DOMNode; 135@class WebSecurityOrigin; 136 137#if ENABLE_FULLSCREEN_API 138@protocol WebKitFullScreenListener<NSObject> 139- (void)webkitWillEnterFullScreen; 140- (void)webkitDidEnterFullScreen; 141- (void)webkitWillExitFullScreen; 142- (void)webkitDidExitFullScreen; 143@end 144#endif 145 146@interface NSObject (WebUIDelegatePrivate) 147 148- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message; 149 150/*! 151 @method webView:addMessageToConsole:withSource: 152 @param webView The WebView sending the delegate method. 153 @param message A dictionary representation of the console message. 154 @param source Where the message came from. See WebConsoleMessageXMLMessageSource and other source types. 155 @discussion The dictionary contains the following keys: 156 157 <dl> 158 <dt>message</dt> 159 <dd>The message itself.</dd> 160 <dt>lineNumber</dt> 161 <dd>If this came from a file, this is the line number in the file this message originates from.</dd> 162 <dt>sourceURL</dt> 163 <dd>If this came from a file, this is the URL to the file this message originates from.</dd> 164 <dt>MessageSource</dt> 165 <dd> 166 Where the message came from. XML, JavaScript, CSS, etc. 167 See WebConsoleMessageXMLMessageSource and similar constants. 168 </dd> 169 <dt>MessageLevel</dt> 170 <dd> 171 Severity level of the message. Debug, Log, Warning, etc. 172 See WebConsoleMessageDebugMessageLevel and similar constants. 173 </dd> 174 </dl> 175*/ 176- (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)message withSource:(NSString *)source; 177 178- (NSView *)webView:(WebView *)webView plugInViewWithArguments:(NSDictionary *)arguments; 179 180#if ENABLE_DASHBOARD_SUPPORT 181// regions is an dictionary whose keys are regions label and values are arrays of WebDashboardRegions. 182- (void)webView:(WebView *)webView dashboardRegionsChanged:(NSDictionary *)regions; 183#endif 184 185#if !TARGET_OS_IPHONE 186- (void)webView:(WebView *)sender dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag forView:(NSView *)view; 187#endif 188- (void)webView:(WebView *)sender didDrawRect:(NSRect)rect; 189- (void)webView:(WebView *)sender didScrollDocumentInFrameView:(WebFrameView *)frameView; 190// FIXME: If we ever make this method public, it should include a WebFrame parameter. 191- (BOOL)webViewShouldInterruptJavaScript:(WebView *)sender; 192#if !TARGET_OS_IPHONE 193- (void)webView:(WebView *)sender willPopupMenu:(NSMenu *)menu; 194- (void)webView:(WebView *)sender contextMenuItemSelected:(NSMenuItem *)item forElement:(NSDictionary *)element; 195- (void)webView:(WebView *)sender saveFrameView:(WebFrameView *)frameView showingPanel:(BOOL)showingPanel; 196#endif 197- (BOOL)webView:(WebView *)sender didPressMissingPluginButton:(DOMElement *)element; 198/*! 199 @method webView:frame:exceededDatabaseQuotaForSecurityOrigin:database: 200 @param sender The WebView sending the delegate method. 201 @param frame The WebFrame whose JavaScript initiated this call. 202 @param origin The security origin that needs a larger quota. 203 @param databaseIdentifier The identifier of the database involved. 204*/ 205- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier; 206 207/*! 208 @method webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:totalSpaceNeeded: 209 @param sender The WebView sending the delegate method. 210 @param origin The security origin that needs a larger quota. 211 @param totalSpaceNeeded The amount of space needed to store the new manifest and keep all other 212 previously stored caches for this origin. 213 @discussion This method is called when a page attempts to store more in the Application Cache 214 for an origin than was allowed by the quota (or default) set for the origin. This allows the 215 quota to be increased for the security origin. 216*/ 217- (void)webView:(WebView *)sender exceededApplicationCacheOriginQuotaForSecurityOrigin:(WebSecurityOrigin *)origin totalSpaceNeeded:(NSUInteger)totalSpaceNeeded; 218 219- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features; 220 221- (BOOL)webView:(WebView *)sender shouldReplaceUploadFile:(NSString *)path usingGeneratedFilename:(NSString **)filename; 222- (NSString *)webView:(WebView *)sender generateReplacementFile:(NSString *)path; 223 224/*! 225 @method webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener: 226 @abstract 227 @param webView The WebView sending the delegate method. 228 @param origin The security origin that would like to use Geolocation. 229 @param frame The WebFrame whose JavaScript initiated this call. 230 @param listener The object to call when the decision is made 231*/ 232- (void)webView:(WebView *)webView decidePolicyForGeolocationRequestFromOrigin:(WebSecurityOrigin *)origin 233 frame:(WebFrame *)frame 234 listener:(id<WebAllowDenyPolicyListener>)listener; 235- (void)webView:(WebView *)webView decidePolicyForNotificationRequestFromOrigin:(WebSecurityOrigin *)origin listener:(id<WebAllowDenyPolicyListener>)listener; 236 237- (void)webView:(WebView *)webView decidePolicyForUserMediaRequestFromOrigin:(WebSecurityOrigin *)origin listener:(id<WebAllowDenyPolicyListener>)listener; 238 239- (void)webView:(WebView *)sender elementDidFocusNode:(DOMNode *)node; 240- (void)webView:(WebView *)sender elementDidBlurNode:(DOMNode *)node; 241 242/*! 243 @method webView:printFrame: 244 @abstract Informs that a WebFrame needs to be printed 245 @param webView The WebView sending the delegate method 246 @param frameView The WebFrame needing to be printed 247 @discussion This method is called when a script or user requests the page to be printed. 248*/ 249- (void)webView:(WebView *)sender printFrame:(WebFrame *)frame; 250 251#if ENABLE_FULLSCREEN_API 252- (BOOL)webView:(WebView *)sender supportsFullScreenForElement:(DOMElement *)element; 253- (void)webView:(WebView *)sender enterFullScreenForElement:(DOMElement *)element; 254- (void)webView:(WebView *)sender exitFullScreenForElement:(DOMElement *)element; 255#endif 256 257- (void)webView:(WebView *)sender didDrawFrame:(WebFrame *)frame; 258 259#if TARGET_OS_IPHONE 260/*! 261 @method webViewSupportedOrientationsUpdated: 262 @param sender The WebView sending the delegate method 263 @abstract Notify the client that the content has updated the orientations it claims to support. 264 */ 265- (void)webViewSupportedOrientationsUpdated:(WebView *)sender; 266 267- (BOOL)webViewCanCheckGeolocationAuthorizationStatus:(WebView *)sender; 268#endif 269 270- (NSData *)webCryptoMasterKeyForWebView:(WebView *)sender; 271 272@end 273