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