webengine/osswebengine/WebKit/DefaultDelegates/WebDefaultUIDelegate.m
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2005 Apple Computer, 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 <Cocoa/Cocoa.h>
       
    30 
       
    31 #import <Foundation/NSURLRequest.h>
       
    32 
       
    33 #import <WebKit/WebDefaultUIDelegate.h>
       
    34 #import <WebKit/WebJavaScriptTextInputPanel.h>
       
    35 #import <WebKit/WebView.h>
       
    36 #import <WebKit/WebUIDelegatePrivate.h>
       
    37 #import <WebKit/DOM.h>
       
    38 
       
    39 @interface NSApplication (DeclarationStolenFromAppKit)
       
    40 - (void)_cycleWindowsReversed:(BOOL)reversed;
       
    41 @end
       
    42 
       
    43 @implementation WebDefaultUIDelegate
       
    44 
       
    45 static WebDefaultUIDelegate *sharedDelegate = nil;
       
    46 
       
    47 // Return a object with vanilla implementations of the protocol's methods
       
    48 // Note this feature relies on our default delegate being stateless.  This
       
    49 // is probably an invalid assumption for the WebUIDelegate.
       
    50 // If we add any real functionality to this default delegate we probably
       
    51 // won't be able to use a singleton.
       
    52 + (WebDefaultUIDelegate *)sharedUIDelegate
       
    53 {
       
    54     if (!sharedDelegate) {
       
    55         sharedDelegate = [[WebDefaultUIDelegate alloc] init];
       
    56     }
       
    57     return sharedDelegate;
       
    58 }
       
    59 
       
    60 - (WebView *)webView: (WebView *)wv createWebViewWithRequest:(NSURLRequest *)request
       
    61 {
       
    62     return nil;
       
    63 }
       
    64 
       
    65 - (void)webViewShow: (WebView *)wv
       
    66 {
       
    67 }
       
    68 
       
    69 - (void)webViewClose: (WebView *)wv
       
    70 {
       
    71     [[wv window] close];
       
    72 }
       
    73 
       
    74 - (void)webViewFocus: (WebView *)wv
       
    75 {
       
    76     [[wv window] makeKeyAndOrderFront:wv];
       
    77 }
       
    78 
       
    79 - (void)webViewUnfocus: (WebView *)wv
       
    80 {
       
    81     if ([[wv window] isKeyWindow] || [[[wv window] attachedSheet] isKeyWindow]) {
       
    82         [NSApp _cycleWindowsReversed:FALSE];
       
    83     }
       
    84 }
       
    85 
       
    86 - (NSResponder *)webViewFirstResponder: (WebView *)wv;
       
    87 {
       
    88     return [[wv window] firstResponder];
       
    89 }
       
    90 
       
    91 - (void)webView: (WebView *)wv makeFirstResponder:(NSResponder *)responder
       
    92 {
       
    93     [[wv window] makeFirstResponder:responder];
       
    94 }
       
    95 
       
    96 - (void)webView: (WebView *)wv setStatusText:(NSString *)text
       
    97 {
       
    98 }
       
    99 
       
   100 - (NSString *)webViewStatusText: (WebView *)wv
       
   101 {
       
   102     return nil;
       
   103 }
       
   104 
       
   105 - (void)webView: (WebView *)wv mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(unsigned int)modifierFlags
       
   106 {
       
   107 }
       
   108 
       
   109 - (BOOL)webViewAreToolbarsVisible: (WebView *)wv
       
   110 {
       
   111     return NO;
       
   112 }
       
   113 
       
   114 - (void)webView: (WebView *)wv setToolbarsVisible:(BOOL)visible
       
   115 {
       
   116 }
       
   117 
       
   118 - (BOOL)webViewIsStatusBarVisible: (WebView *)wv
       
   119 {
       
   120     return NO;
       
   121 }
       
   122 
       
   123 - (void)webView: (WebView *)wv setStatusBarVisible:(BOOL)visible
       
   124 {
       
   125 }
       
   126 
       
   127 - (BOOL)webViewIsResizable: (WebView *)wv
       
   128 {
       
   129     return [[wv window] showsResizeIndicator];
       
   130 }
       
   131 
       
   132 - (void)webView: (WebView *)wv setResizable:(BOOL)resizable;
       
   133 {
       
   134     // FIXME: This doesn't actually change the resizability of the window,
       
   135     // only visibility of the indicator.
       
   136     [[wv window] setShowsResizeIndicator:resizable];
       
   137 }
       
   138 
       
   139 - (void)webView: (WebView *)wv setFrame:(NSRect)frame
       
   140 {
       
   141     [[wv window] setFrame:frame display:YES];
       
   142 }
       
   143 
       
   144 - (NSRect)webViewFrame: (WebView *)wv
       
   145 {
       
   146     NSWindow *window = [wv window];
       
   147     return window == nil ? NSZeroRect : [window frame];
       
   148 }
       
   149 
       
   150 - (void)webView: (WebView *)wv runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
       
   151 {
       
   152     // FIXME: We want a default here, but that would add localized strings.
       
   153 }
       
   154 
       
   155 - (BOOL)webView: (WebView *)wv runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
       
   156 {
       
   157     // FIXME: We want a default here, but that would add localized strings.
       
   158     return NO;
       
   159 }
       
   160 
       
   161 - (NSString *)webView: (WebView *)wv runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame
       
   162 {
       
   163     WebJavaScriptTextInputPanel *panel = [[WebJavaScriptTextInputPanel alloc] initWithPrompt:prompt text:defaultText];
       
   164     [panel showWindow:nil];
       
   165     NSString *result;
       
   166     if ([NSApp runModalForWindow:[panel window]]) {
       
   167         result = [panel text];
       
   168     } else {
       
   169         result = nil;
       
   170     }
       
   171     [[panel window] close];
       
   172     [panel release];
       
   173     return result;
       
   174 }
       
   175 
       
   176 - (void)webView: (WebView *)wv runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListener>)resultListener
       
   177 {
       
   178     // FIXME: We want a default here, but that would add localized strings.
       
   179 }
       
   180 
       
   181 - (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView
       
   182 {
       
   183 }
       
   184 
       
   185 
       
   186 - (BOOL)webView:(WebView *)webView shouldBeginDragForElement:(NSDictionary *)element dragImage:(NSImage *)dragImage mouseDownEvent:(NSEvent *)mouseDownEvent mouseDraggedEvent:(NSEvent *)mouseDraggedEvent
       
   187 {
       
   188     return YES;
       
   189 }
       
   190 
       
   191 - (unsigned)webView:(WebView *)webView dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
       
   192 {
       
   193     return WebDragDestinationActionAny;
       
   194 }
       
   195 
       
   196 - (void)webView:(WebView *)webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id <NSDraggingInfo>)draggingInfo
       
   197 {
       
   198 }
       
   199 
       
   200 - (unsigned)webView:(WebView *)webView dragSourceActionMaskForPoint:(NSPoint)point;
       
   201 {
       
   202     return WebDragSourceActionAny;
       
   203 }
       
   204 
       
   205 - (void)webView:(WebView *)webView willPerformDragSourceAction:(WebDragSourceAction)action fromPoint:(NSPoint)point withPasteboard:(NSPasteboard *)pasteboard;
       
   206 {
       
   207 }
       
   208 
       
   209 - (void)webView:(WebView *)sender didDrawRect:(NSRect)rect
       
   210 {
       
   211 }
       
   212 
       
   213 - (void)webView:(WebView *)sender didScrollDocumentInFrameView:(WebFrameView *)frameView
       
   214 {
       
   215 }
       
   216 
       
   217 - (void)webView:(WebView *)sender willPopupMenu:(NSMenu *)menu
       
   218 {
       
   219 }
       
   220 
       
   221 - (void)webView:(WebView *)sender contextMenuItemSelected:(NSMenuItem *)item forElement:(NSDictionary *)element
       
   222 {
       
   223 }
       
   224 
       
   225 @end