1563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark/*
2563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * Copyright (C) 2006. 2007 Apple Inc. All rights reserved.
3563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *
4563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * Redistribution and use in source and binary forms, with or without
5563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * modification, are permitted provided that the following conditions
6563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * are met:
7563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *
8563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * 1.  Redistributions of source code must retain the above copyright
9563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     notice, this list of conditions and the following disclaimer.
10563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * 2.  Redistributions in binary form must reproduce the above copyright
11563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     notice, this list of conditions and the following disclaimer in the
12563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     documentation and/or other materials provided with the distribution.
13563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     its contributors may be used to endorse or promote products derived
15563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *     from this software without specific prior written permission.
16563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark *
17563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark */
28563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
290bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch#import "config.h"
30563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import "UIDelegate.h"
31563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
320bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch#import "DumpRenderTree.h"
33563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import "DumpRenderTreeDraggingInfo.h"
34563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import "EventSendingController.h"
35563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import "LayoutTestController.h"
36dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch#import <WebKit/WebApplicationCache.h>
37563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import <WebKit/WebFramePrivate.h>
38563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import <WebKit/WebHTMLViewPrivate.h>
39dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch#import <WebKit/WebQuotaManager.h>
40563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import <WebKit/WebSecurityOriginPrivate.h>
41643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#import <WebKit/WebUIDelegatePrivate.h>
420bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch#import <WebKit/WebView.h>
435e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block#import <WebKit/WebViewPrivate.h>
44563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark#import <wtf/Assertions.h>
45563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
46563af33bc48281d19dce701398dbb88cb54fd7ecCary ClarkDumpRenderTreeDraggingInfo *draggingInfo = nil;
47563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
48563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark@implementation UIDelegate
49563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
50563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webView:(WebView *)sender setFrame:(NSRect)frame
51563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
52563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    m_frame = frame;
53563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
54563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
55563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (NSRect)webViewFrame:(WebView *)sender
56563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
57563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    return m_frame;
58563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
59563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
6081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch- (void)webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary withSource:(NSString *)source
61563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
62563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    NSString *message = [dictionary objectForKey:@"message"];
63563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    NSNumber *lineNumber = [dictionary objectForKey:@"lineNumber"];
64563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
65563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    NSRange range = [message rangeOfString:@"file://"];
66563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (range.location != NSNotFound)
67563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        message = [[message substringToIndex:range.location] stringByAppendingString:[[message substringFromIndex:NSMaxRange(range)] lastPathComponent]];
68563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
69563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    printf ("CONSOLE MESSAGE: line %d: %s\n", [lineNumber intValue], [message UTF8String]);
70563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
71563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
7206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen- (void)modalWindowWillClose:(NSNotification *)notification
7306ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen{
7406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:nil];
7506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    [NSApp abortModal];
7606ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen}
7706ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen
7806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen- (void)webViewRunModal:(WebView *)sender
7906ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen{
8006ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    gLayoutTestController->setWindowIsKey(false);
8106ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modalWindowWillClose:) name:NSWindowWillCloseNotification object:nil];
8206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    [NSApp runModalForWindow:[sender window]];
8306ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    gLayoutTestController->setWindowIsKey(true);
8406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen}
8506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen
86563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
87563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
88563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (!done)
89563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        printf("ALERT: %s\n", [message UTF8String]);
90563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
91563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
92563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
93563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
94563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (!done)
95563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        printf("CONFIRM: %s\n", [message UTF8String]);
96563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    return YES;
97563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
98563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
99563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame
100563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
101563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (!done)
102563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        printf("PROMPT: %s, default text: %s\n", [prompt UTF8String], [defaultText UTF8String]);
103563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    return defaultText;
104563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
105563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
106563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (BOOL)webView:(WebView *)c runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
107563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
108563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (!done)
109563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        printf("CONFIRM NAVIGATION: %s\n", [message UTF8String]);
110563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    return YES;
111563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
112563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
113563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
114563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (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
115563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
116563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark     assert(!draggingInfo);
117563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark     draggingInfo = [[DumpRenderTreeDraggingInfo alloc] initWithImage:anImage offset:initialOffset pasteboard:pboard source:sourceObj];
1180bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch     [sender draggingUpdated:draggingInfo];
119563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark     [EventSendingController replaySavedEvents];
120563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
121563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
122563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webViewFocus:(WebView *)webView
123563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
124563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    gLayoutTestController->setWindowIsKey(true);
125563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
126563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
127563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webViewUnfocus:(WebView *)webView
128563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
129563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    gLayoutTestController->setWindowIsKey(false);
130563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
131563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
132563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
133563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
134563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (!gLayoutTestController->canOpenWindows())
135563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        return nil;
136563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
137563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    // Make sure that waitUntilDone has been called.
138563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    ASSERT(gLayoutTestController->waitToDump());
139563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
140563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    WebView *webView = createWebViewAndOffscreenWindow();
141563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
1425e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block    if (gLayoutTestController->newWindowsCopyBackForwardList())
1435e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block        [webView _loadBackForwardListFromOtherView:sender];
1445e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block
145563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    return [webView autorelease];
146563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
147563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
148563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webViewClose:(WebView *)sender
149563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
150563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    NSWindow* window = [sender window];
151563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
152563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (gLayoutTestController->callCloseOnWebViews())
153563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        [sender close];
154563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
155563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    [window close];
156563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
157563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
158563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier
159563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
160dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    if (!done && gLayoutTestController->dumpDatabaseCallbacks()) {
161563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%s\n", [[origin protocol] UTF8String], [[origin host] UTF8String],
162563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark            [origin port], [databaseIdentifier UTF8String]);
163dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    }
164563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
165563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
166dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    [[origin databaseQuotaManager] setQuota:defaultQuota];
167dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch}
168dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch
169dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch- (void)webView:(WebView *)sender exceededApplicationCacheOriginQuotaForSecurityOrigin:(WebSecurityOrigin *)origin
170dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch{
171dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    if (!done && gLayoutTestController->dumpApplicationCacheDelegateCallbacks()) {
172dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        printf("UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{%s, %s, %i}\n",
173dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            [[origin protocol] UTF8String], [[origin host] UTF8String], [origin port]);
174dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    }
175dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch
176dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    static const unsigned long long defaultOriginQuota = [WebApplicationCache defaultOriginQuota];
177dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    [[origin applicationCacheQuotaManager] setQuota:defaultOriginQuota];
178563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
179563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
180563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)webView:(WebView *)sender setStatusText:(NSString *)text
181563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
182563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    if (gLayoutTestController->dumpStatusCallbacks())
183563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark        printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", [text UTF8String]);
184563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
185563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
186643ca7872b450ea4efacab6188849e5aac2ba161Steve Block- (void)webView:(WebView *)webView decidePolicyForGeolocationRequestFromOrigin:(WebSecurityOrigin *)origin frame:(WebFrame *)frame listener:(id<WebGeolocationPolicyListener>)listener
187231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{
188dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    if (!gLayoutTestController->isGeolocationPermissionSet()) {
189dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        if (!m_pendingGeolocationPermissionListeners)
190dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            m_pendingGeolocationPermissionListeners = [[NSMutableSet set] retain];
191dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        [m_pendingGeolocationPermissionListeners addObject:listener];
192dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        return;
193dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    }
194dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch
195dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    if (gLayoutTestController->geolocationPermission())
196545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        [listener allow];
197545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    else
198545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        [listener deny];
199231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block}
200231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block
201dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch- (void)didSetMockGeolocationPermission
202dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch{
203dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    ASSERT(gLayoutTestController->isGeolocationPermissionSet());
204dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    if (m_pendingGeolocationPermissionListeners && !m_timer)
205dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        m_timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(timerFired) userInfo:0 repeats:NO];
206dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch}
207dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch
2082bde8e466a4451c7319e3a072d118917957d6554Steve Block- (int)numberOfPendingGeolocationPermissionRequests
2092bde8e466a4451c7319e3a072d118917957d6554Steve Block{
2102bde8e466a4451c7319e3a072d118917957d6554Steve Block    if (!m_pendingGeolocationPermissionListeners)
2112bde8e466a4451c7319e3a072d118917957d6554Steve Block        return 0;
2122bde8e466a4451c7319e3a072d118917957d6554Steve Block    return [m_pendingGeolocationPermissionListeners count];
2132bde8e466a4451c7319e3a072d118917957d6554Steve Block}
2142bde8e466a4451c7319e3a072d118917957d6554Steve Block
2152bde8e466a4451c7319e3a072d118917957d6554Steve Block
216dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch- (void)timerFired
217dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch{
218dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    ASSERT(gLayoutTestController->isGeolocationPermissionSet());
219dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    m_timer = 0;
220dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    NSEnumerator* enumerator = [m_pendingGeolocationPermissionListeners objectEnumerator];
221dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    id<WebGeolocationPolicyListener> listener;
222dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    while ((listener = [enumerator nextObject])) {
223dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        if (gLayoutTestController->geolocationPermission())
224dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            [listener allow];
225dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        else
226dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            [listener deny];
227dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    }
228dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    [m_pendingGeolocationPermissionListeners removeAllObjects];
229dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    [m_pendingGeolocationPermissionListeners release];
230dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    m_pendingGeolocationPermissionListeners = nil;
231dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch}
232dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch
233cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block- (BOOL)webView:(WebView *)sender shouldHaltPlugin:(DOMNode *)pluginNode
234cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{
235cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block    return NO;
236cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block}
237cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block
2382bde8e466a4451c7319e3a072d118917957d6554Steve Block- (BOOL)webView:(WebView *)webView supportsFullScreenForElement:(DOMElement*)element withKeyboard:(BOOL)withKeyboard
2395ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen{
2405ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    return YES;
2415ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen}
2425ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen
2435ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen- (void)webView:(WebView *)webView enterFullScreenForElement:(DOMElement*)element listener:(NSObject<WebKitFullScreenListener>*)listener
2445ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen{
2455ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    [listener webkitWillEnterFullScreen];
2465ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    [listener webkitDidEnterFullScreen];
2475ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen}
2485ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen
2495ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen- (void)webView:(WebView *)webView exitFullScreenForElement:(DOMElement*)element listener:(NSObject<WebKitFullScreenListener>*)listener
2505ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen{
2515ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    [listener webkitWillExitFullScreen];
2525ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen    [listener webkitDidExitFullScreen];
2535ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen}
2545ddde30071f639962dd557c453f2ad01f8f0fd00Kristian Monsen
255e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke- (BOOL)webView:(WebView *)webView didPressMissingPluginButton:(DOMElement *)element
256e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke{
257e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke    printf("MISSING PLUGIN BUTTON PRESSED\n");
258e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke    return TRUE;
259e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke}
260e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke
261563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark- (void)dealloc
262563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark{
263563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    [draggingInfo release];
264563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    draggingInfo = nil;
265dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    [m_pendingGeolocationPermissionListeners release];
266dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    m_pendingGeolocationPermissionListeners = nil;
267563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
268563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark    [super dealloc];
269563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark}
270563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark
271563af33bc48281d19dce701398dbb88cb54fd7ecCary Clark@end
272