2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #import "BrowserWindowController.h"
28 #import <WebKit2/WKPagePrivate.h>
29 #import <WebKit2/WKStringCF.h>
30 #import <WebKit2/WKURLCF.h>
31 #import <WebKit2/WKViewPrivate.h>
33 @interface BrowserWindowController ()
34 - (void)didStartProgress;
35 - (void)didChangeProgress:(double)value;
36 - (void)didFinishProgress;
37 - (void)didStartProvisionalLoadForFrame:(WKFrameRef)frame;
38 - (void)didCommitLoadForFrame:(WKFrameRef)frame;
39 - (void)didReceiveServerRedirectForProvisionalLoadForFrame:(WKFrameRef)frame;
40 - (void)didFailProvisionalLoadWithErrorForFrame:(WKFrameRef)frame;
41 - (void)didFailLoadWithErrorForFrame:(WKFrameRef)frame;
42 - (void)didSameDocumentNavigationForFrame:(WKFrameRef)frame;
45 @implementation BrowserWindowController
47 - (id)initWithContext:(WKContextRef)context pageGroup:(WKPageGroupRef)pageGroup
49 if ((self = [super initWithWindowNibName:@"BrowserWindow"])) {
50 _context = WKRetain(context);
51 _pageGroup = WKRetain(pageGroup);
64 - (IBAction)fetch:(id)sender
66 CFURLRef cfURL = CFURLCreateWithString(0, (CFStringRef)[urlText stringValue], 0);
70 WKURLRef url = WKURLCreateWithCFURL(cfURL);
73 WKPageLoadURL(_webView.pageRef, url);
77 - (IBAction)showHideWebView:(id)sender
79 BOOL hidden = ![_webView isHidden];
81 [_webView setHidden:hidden];
84 - (IBAction)removeReinsertWebView:(id)sender
86 if ([_webView window]) {
88 [_webView removeFromSuperview];
90 [containerView addSubview:_webView];
95 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
97 SEL action = [menuItem action];
99 if (action == @selector(zoomIn:))
100 return [self canZoomIn];
101 if (action == @selector(zoomOut:))
102 return [self canZoomOut];
103 if (action == @selector(resetZoom:))
104 return [self canResetZoom];
106 if (action == @selector(showHideWebView:))
107 [menuItem setTitle:[_webView isHidden] ? @"Show Web View" : @"Hide Web View"];
108 else if (action == @selector(removeReinsertWebView:))
109 [menuItem setTitle:[_webView window] ? @"Remove Web View" : @"Insert Web View"];
110 else if (action == @selector(toggleZoomMode:))
111 [menuItem setState:_zoomTextOnly ? NSOnState : NSOffState];
115 - (IBAction)reload:(id)sender
117 WKPageReload(_webView.pageRef);
120 - (IBAction)forceRepaint:(id)sender
122 [_webView setNeedsDisplay:YES];
125 - (IBAction)goBack:(id)sender
127 WKPageGoBack(_webView.pageRef);
130 - (IBAction)goForward:(id)sender
132 WKPageGoForward(_webView.pageRef);
135 - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
137 SEL action = [item action];
139 if (action == @selector(goBack:))
140 return _webView && WKPageCanGoBack(_webView.pageRef);
142 if (action == @selector(goForward:))
143 return _webView && WKPageCanGoForward(_webView.pageRef);
148 - (void)validateToolbar
150 [toolbar validateVisibleItems];
153 - (BOOL)windowShouldClose:(id)sender
155 LOG(@"windowShouldClose");
156 BOOL canCloseImmediately = WKPageTryClose(_webView.pageRef);
157 return canCloseImmediately;
160 - (void)windowWillClose:(NSNotification *)notification
164 WKRelease(_pageGroup);
168 - (void)applicationTerminating
170 WKPageClose(_webView.pageRef);
171 WKRelease(_webView.pageRef);
174 #define DefaultMinimumZoomFactor (.5)
175 #define DefaultMaximumZoomFactor (3.0)
176 #define DefaultZoomFactorRatio (1.2)
178 - (double)currentZoomFactor
180 return _zoomTextOnly ? WKPageGetTextZoomFactor(_webView.pageRef) : WKPageGetPageZoomFactor(_webView.pageRef);
183 - (void)setCurrentZoomFactor:(double)factor
185 _zoomTextOnly ? WKPageSetTextZoomFactor(_webView.pageRef, factor) : WKPageSetPageZoomFactor(_webView.pageRef, factor);
190 return [self currentZoomFactor] * DefaultZoomFactorRatio < DefaultMaximumZoomFactor;
193 - (void)zoomIn:(id)sender
195 if (![self canZoomIn])
198 double factor = [self currentZoomFactor] * DefaultZoomFactorRatio;
199 [self setCurrentZoomFactor:factor];
204 return [self currentZoomFactor] / DefaultZoomFactorRatio > DefaultMinimumZoomFactor;
207 - (void)zoomOut:(id)sender
209 if (![self canZoomIn])
212 double factor = [self currentZoomFactor] / DefaultZoomFactorRatio;
213 [self setCurrentZoomFactor:factor];
218 return _zoomTextOnly ? (WKPageGetTextZoomFactor(_webView.pageRef) != 1) : (WKPageGetPageZoomFactor(_webView.pageRef) != 1);
221 - (void)resetZoom:(id)sender
223 if (![self canResetZoom])
227 WKPageSetTextZoomFactor(_webView.pageRef, 1);
229 WKPageSetPageZoomFactor(_webView.pageRef, 1);
232 - (IBAction)toggleZoomMode:(id)sender
236 double currentTextZoom = WKPageGetTextZoomFactor(_webView.pageRef);
237 WKPageSetPageAndTextZoomFactors(_webView.pageRef, currentTextZoom, 1);
240 double currentPageZoom = WKPageGetPageZoomFactor(_webView.pageRef);
241 WKPageSetPageAndTextZoomFactors(_webView.pageRef, 1, currentPageZoom);
245 - (IBAction)dumpSourceToConsole:(id)sender
247 WKPageGetSourceForFrame_b(_webView.pageRef, WKPageGetMainFrame(_webView.pageRef), ^(WKStringRef result, WKErrorRef error) {
248 CFStringRef cfResult = WKStringCopyCFString(0, result);
249 LOG(@"Main frame source\n \"%@\"", (NSString *)cfResult);
254 // MARK: Loader Client Callbacks
256 static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
258 [(BrowserWindowController *)clientInfo didStartProvisionalLoadForFrame:frame];
261 static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
263 [(BrowserWindowController *)clientInfo didReceiveServerRedirectForProvisionalLoadForFrame:frame];
266 static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo)
268 [(BrowserWindowController *)clientInfo didFailProvisionalLoadWithErrorForFrame:frame];
271 static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
273 [(BrowserWindowController *)clientInfo didCommitLoadForFrame:frame];
276 static void didFinishDocumentLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
278 LOG(@"didFinishDocumentLoadForFrame");
281 static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
283 LOG(@"didFinishLoadForFrame");
286 static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo)
288 [(BrowserWindowController *)clientInfo didFailLoadWithErrorForFrame:frame];
291 static void didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo)
293 [(BrowserWindowController *)clientInfo didSameDocumentNavigationForFrame:frame];
296 static void didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
298 CFStringRef cfTitle = WKStringCopyCFString(0, title);
299 LOG(@"didReceiveTitleForFrame \"%@\"", (NSString *)cfTitle);
303 static void didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
305 LOG(@"didFirstLayoutForFrame");
308 static void didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
310 LOG(@"didFirstVisuallyNonEmptyLayoutForFrame");
313 static void didRemoveFrameFromHierarchy(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
315 LOG(@"didRemoveFrameFromHierarchy");
318 static void didDisplayInsecureContentForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
320 LOG(@"didDisplayInsecureContentForFrame");
323 static void didRunInsecureContentForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
325 LOG(@"didRunInsecureContentForFrame");
328 static void didDetectXSSForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
330 LOG(@"didDetectXSSForFrame");
333 static void didStartProgress(WKPageRef page, const void *clientInfo)
335 [(BrowserWindowController *)clientInfo didStartProgress];
338 static void didChangeProgress(WKPageRef page, const void *clientInfo)
340 [(BrowserWindowController *)clientInfo didChangeProgress:WKPageGetEstimatedProgress(page)];
343 static void didFinishProgress(WKPageRef page, const void *clientInfo)
345 [(BrowserWindowController *)clientInfo didFinishProgress];
348 static void didBecomeUnresponsive(WKPageRef page, const void *clientInfo)
350 LOG(@"didBecomeUnresponsive");
353 static void didBecomeResponsive(WKPageRef page, const void *clientInfo)
355 LOG(@"didBecomeResponsive");
358 static void processDidExit(WKPageRef page, const void *clientInfo)
360 LOG(@"processDidExit");
363 static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo)
365 [(BrowserWindowController *)clientInfo validateToolbar];
368 // MARK: Policy Client Callbacks
370 static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
372 LOG(@"decidePolicyForNavigationAction");
373 WKFramePolicyListenerUse(listener);
376 static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
378 LOG(@"decidePolicyForNewWindowAction");
379 WKFramePolicyListenerUse(listener);
382 static void decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
384 WKFramePolicyListenerUse(listener);
387 // MARK: UI Client Callbacks
389 static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef request, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton button, const void* clientInfo)
391 LOG(@"createNewPage");
392 BrowserWindowController *controller = [[BrowserWindowController alloc] initWithContext:WKPageGetContext(page) pageGroup:WKPageGetPageGroup(page)];
393 [controller loadWindow];
395 return controller->_webView.pageRef;
398 static void showPage(WKPageRef page, const void *clientInfo)
401 [[(BrowserWindowController *)clientInfo window] orderFront:nil];
404 static void closePage(WKPageRef page, const void *clientInfo)
408 [[(BrowserWindowController *)clientInfo window] close];
412 static void runJavaScriptAlert(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
414 NSAlert* alert = [[NSAlert alloc] init];
416 WKURLRef wkURL = WKFrameCopyURL(frame);
417 CFURLRef cfURL = WKURLCopyCFURL(0, wkURL);
420 [alert setMessageText:[NSString stringWithFormat:@"JavaScript alert dialog from %@.", [(NSURL *)cfURL absoluteString]]];
423 CFStringRef cfMessage = WKStringCopyCFString(0, message);
424 [alert setInformativeText:(NSString *)cfMessage];
425 CFRelease(cfMessage);
427 [alert addButtonWithTitle:@"OK"];
433 static bool runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
435 NSAlert* alert = [[NSAlert alloc] init];
437 WKURLRef wkURL = WKFrameCopyURL(frame);
438 CFURLRef cfURL = WKURLCopyCFURL(0, wkURL);
441 [alert setMessageText:[NSString stringWithFormat:@"JavaScript confirm dialog from %@.", [(NSURL *)cfURL absoluteString]]];
444 CFStringRef cfMessage = WKStringCopyCFString(0, message);
445 [alert setInformativeText:(NSString *)cfMessage];
446 CFRelease(cfMessage);
448 [alert addButtonWithTitle:@"OK"];
449 [alert addButtonWithTitle:@"Cancel"];
451 NSInteger button = [alert runModal];
454 return button == NSAlertFirstButtonReturn;
457 static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void* clientInfo)
459 NSAlert* alert = [[NSAlert alloc] init];
461 WKURLRef wkURL = WKFrameCopyURL(frame);
462 CFURLRef cfURL = WKURLCopyCFURL(0, wkURL);
465 [alert setMessageText:[NSString stringWithFormat:@"JavaScript prompt dialog from %@.", [(NSURL *)cfURL absoluteString]]];
468 CFStringRef cfMessage = WKStringCopyCFString(0, message);
469 [alert setInformativeText:(NSString *)cfMessage];
470 CFRelease(cfMessage);
472 [alert addButtonWithTitle:@"OK"];
473 [alert addButtonWithTitle:@"Cancel"];
475 NSTextField* input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
476 CFStringRef cfDefaultValue = WKStringCopyCFString(0, defaultValue);
477 [input setStringValue:(NSString *)cfDefaultValue];
478 CFRelease(cfDefaultValue);
480 [alert setAccessoryView:input];
482 NSInteger button = [alert runModal];
484 NSString* result = nil;
485 if (button == NSAlertFirstButtonReturn) {
486 [input validateEditing];
487 result = [input stringValue];
494 return WKStringCreateWithCFString((CFStringRef)result);
497 static void setStatusText(WKPageRef page, WKStringRef text, const void* clientInfo)
499 LOG(@"setStatusText");
502 static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo)
504 LOG(@"mouseDidMoveOverElement");
507 static WKRect getWindowFrame(WKPageRef page, const void* clientInfo)
509 NSRect rect = [[(BrowserWindowController *)clientInfo window] frame];
511 wkRect.origin.x = rect.origin.x;
512 wkRect.origin.y = rect.origin.y;
513 wkRect.size.width = rect.size.width;
514 wkRect.size.height = rect.size.height;
518 static void setWindowFrame(WKPageRef page, WKRect rect, const void* clientInfo)
520 [[(BrowserWindowController *)clientInfo window] setFrame:NSMakeRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height) display:YES];
523 static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo)
525 NSAlert *alert = [[NSAlert alloc] init];
527 WKURLRef wkURL = WKFrameCopyURL(frame);
528 CFURLRef cfURL = WKURLCopyCFURL(0, wkURL);
531 [alert setMessageText:[NSString stringWithFormat:@"BeforeUnload confirm dialog from %@.", [(NSURL *)cfURL absoluteString]]];
534 CFStringRef cfMessage = WKStringCopyCFString(0, message);
535 [alert setInformativeText:(NSString *)cfMessage];
536 CFRelease(cfMessage);
538 [alert addButtonWithTitle:@"OK"];
539 [alert addButtonWithTitle:@"Cancel"];
541 NSInteger button = [alert runModal];
544 return button == NSAlertFirstButtonReturn;
547 static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
549 NSOpenPanel *openPanel = [NSOpenPanel openPanel];
550 [openPanel setAllowsMultipleSelection:WKOpenPanelParametersGetAllowsMultipleFiles(parameters)];
554 [openPanel beginSheetModalForWindow:[(BrowserWindowController *)clientInfo window] completionHandler:^(NSInteger result) {
555 if (result == NSFileHandlingPanelOKButton) {
556 WKMutableArrayRef fileURLs = WKMutableArrayCreate();
559 for (nsURL in [openPanel URLs]) {
560 WKURLRef wkURL = WKURLCreateWithCFURL((CFURLRef)nsURL);
561 WKArrayAppendItem(fileURLs, wkURL);
565 WKOpenPanelResultListenerChooseFiles(listener, fileURLs);
569 WKOpenPanelResultListenerCancel(listener);
577 _webView = [[WKView alloc] initWithFrame:[containerView frame] contextRef:_context pageGroupRef:_pageGroup];
579 [containerView addSubview:_webView];
580 [_webView setFrame:[containerView frame]];
582 [_webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
584 WKPageLoaderClient loadClient = {
585 kWKPageLoaderClientCurrentVersion,
586 self, /* clientInfo */
587 didStartProvisionalLoadForFrame,
588 didReceiveServerRedirectForProvisionalLoadForFrame,
589 didFailProvisionalLoadWithErrorForFrame,
590 didCommitLoadForFrame,
591 didFinishDocumentLoadForFrame,
592 didFinishLoadForFrame,
593 didFailLoadWithErrorForFrame,
594 didSameDocumentNavigationForFrame,
595 didReceiveTitleForFrame,
596 didFirstLayoutForFrame,
597 didFirstVisuallyNonEmptyLayoutForFrame,
598 didRemoveFrameFromHierarchy,
599 didDisplayInsecureContentForFrame,
600 didRunInsecureContentForFrame,
601 0, // canAuthenticateAgainstProtectionSpaceInFrame
602 0, // didReceiveAuthenticationChallengeInFrame
606 didBecomeUnresponsive,
609 didChangeBackForwardList,
610 0, // shouldGoToBackForwardItem
611 0, // didFailToInitializePlugin
612 didDetectXSSForFrame,
614 WKPageSetPageLoaderClient(_webView.pageRef, &loadClient);
616 WKPagePolicyClient policyClient = {
617 kWKPagePolicyClientCurrentVersion,
618 self, /* clientInfo */
619 decidePolicyForNavigationAction,
620 decidePolicyForNewWindowAction,
621 decidePolicyForResponse,
622 0 /* unableToImplementPolicy */
624 WKPageSetPagePolicyClient(_webView.pageRef, &policyClient);
626 WKPageUIClient uiClient = {
627 kWKPageUIClientCurrentVersion,
628 self, /* clientInfo */
629 0, /* createNewPage_deprecatedForUseWithV0 */
636 runJavaScriptConfirm,
639 0, /* mouseDidMoveOverElement_deprecatedForUseWithV0 */
640 0, /* missingPluginButtonClicked */
641 0, /* didNotHandleKeyEvent */
642 0, /* didNotHandleWheelEvent */
643 0, /* toolbarsAreVisible */
644 0, /* setToolbarsAreVisible */
645 0, /* menuBarIsVisible */
646 0, /* setMenuBarIsVisible */
647 0, /* statusBarIsVisible */
648 0, /* setStatusBarIsVisible */
650 0, /* setIsResizable */
653 runBeforeUnloadConfirmPanel,
655 0, /* pageDidScroll */
656 0, /* exceededDatabaseQuota */
658 0, /* decidePolicyForGeolocationPermissionRequest */
665 0, // didCompleteRubberBandForMainFrame
666 0, // saveDataToFileInDownloadsFolder
667 0, // shouldInterruptJavaScript
669 mouseDidMoveOverElement,
671 WKPageSetPageUIClient(_webView.pageRef, &uiClient);
674 - (void)didStartProgress
676 [progressIndicator setDoubleValue:0.0];
677 [progressIndicator setHidden:NO];
680 - (void)didChangeProgress:(double)value
682 [progressIndicator setDoubleValue:value];
685 - (void)didFinishProgress
687 [progressIndicator setHidden:YES];
688 [progressIndicator setDoubleValue:1.0];
691 - (void)updateProvisionalURLForFrame:(WKFrameRef)frame
693 static WKURLRef emptyURL = 0;
695 emptyURL = WKURLCreateWithUTF8CString("");
697 WKURLRef url = WKFrameCopyProvisionalURL(frame);
702 if (WKURLIsEqual(url, emptyURL)) {
707 CFURLRef cfSourceURL = WKURLCopyCFURL(0, url);
710 [urlText setStringValue:(NSString*)CFURLGetString(cfSourceURL)];
711 CFRelease(cfSourceURL);
714 - (void)didStartProvisionalLoadForFrame:(WKFrameRef)frame
716 if (!WKFrameIsMainFrame(frame))
719 [self updateProvisionalURLForFrame:frame];
722 - (void)didReceiveServerRedirectForProvisionalLoadForFrame:(WKFrameRef)frame
724 if (!WKFrameIsMainFrame(frame))
727 [self updateProvisionalURLForFrame:frame];
730 - (void)didFailProvisionalLoadWithErrorForFrame:(WKFrameRef)frame
732 if (!WKFrameIsMainFrame(frame))
735 [self updateProvisionalURLForFrame:frame];
738 - (void)didFailLoadWithErrorForFrame:(WKFrameRef)frame
740 if (!WKFrameIsMainFrame(frame))
743 [self updateProvisionalURLForFrame:frame];
746 - (void)didSameDocumentNavigationForFrame:(WKFrameRef)frame
750 - (void)didCommitLoadForFrame:(WKFrameRef)frame
754 - (void)loadURLString:(NSString *)urlString
756 // FIXME: We shouldn't have to set the url text here.
757 [urlText setStringValue:urlString];
761 - (IBAction)performFindPanelAction:(id)sender
763 [findPanelWindow makeKeyAndOrderFront:sender];
766 - (IBAction)find:(id)sender
768 WKStringRef string = WKStringCreateWithCFString((CFStringRef)[sender stringValue]);
770 WKPageFindString(_webView.pageRef, string, kWKFindOptionsCaseInsensitive | kWKFindOptionsWrapAround | kWKFindOptionsShowFindIndicator | kWKFindOptionsShowOverlay, 100);