1 #include <UIKit/UIKit.h>
2 #include "iPhonePrivate.h"
4 #include "UCPlatform.h"
6 #include <UICaboodle/BrowserView.h>
7 #include <UICaboodle/UCLocalize.h>
9 //#include <QuartzCore/CALayer.h>
10 // XXX: fix the minimum requirement
11 extern NSString * const kCAFilterNearest;
13 #include <WebCore/WebCoreThread.h>
15 #include <WebKit/WebPolicyDelegate.h>
16 #include <WebKit/WebPreferences.h>
18 #include <WebKit/DOMCSSPrimitiveValue.h>
19 #include <WebKit/DOMCSSStyleDeclaration.h>
20 #include <WebKit/DOMDocument.h>
21 #include <WebKit/DOMHTMLBodyElement.h>
22 #include <WebKit/DOMRGBColor.h>
24 //#include <WebCore/Page.h>
25 //#include <WebCore/Settings.h>
27 #include "substrate.h"
33 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
34 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
35 static Class $UIFormAssistant;
36 static Class $UIWebBrowserView;
38 /* Indirect Delegate {{{ */
39 @interface IndirectDelegate : NSObject <
42 _transient volatile id delegate_;
45 - (void) setDelegate:(id)delegate;
46 - (id) initWithDelegate:(id)delegate;
49 @implementation IndirectDelegate
51 - (void) setDelegate:(id)delegate {
55 - (id) initWithDelegate:(id)delegate {
60 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
62 return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
65 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
67 return [delegate_ webView:sender didCommitLoadForFrame:frame];
70 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
72 return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
75 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
77 return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
80 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
82 return [delegate_ webView:sender didFinishLoadForFrame:frame];
85 - (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
87 return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
90 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
92 return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
95 - (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
97 return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
100 - (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
101 if (delegate_ != nil)
102 return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
106 - (void) didDismissModalViewController {
107 if (delegate_ != nil)
108 return [delegate_ didDismissModalViewController];
111 - (IMP) methodForSelector:(SEL)sel {
112 if (IMP method = [super methodForSelector:sel])
114 fprintf(stderr, "methodForSelector:[%s] == NULL\n", sel_getName(sel));
118 - (BOOL) respondsToSelector:(SEL)sel {
119 if ([super respondsToSelector:sel])
121 // XXX: WebThreadCreateNSInvocation returns nil
122 //fprintf(stderr, "[%s]R?%s\n", class_getName(self->isa), sel_getName(sel));
123 return delegate_ == nil ? NO : [delegate_ respondsToSelector:sel];
126 - (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
127 if (NSMethodSignature *method = [super methodSignatureForSelector:sel])
129 //fprintf(stderr, "[%s]S?%s\n", class_getName(self->isa), sel_getName(sel));
130 if (delegate_ != nil)
131 if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
133 // XXX: I fucking hate Apple so very very bad
134 return [NSMethodSignature signatureWithObjCTypes:"v@:"];
137 - (void) forwardInvocation:(NSInvocation *)inv {
138 SEL sel = [inv selector];
139 if (delegate_ != nil && [delegate_ respondsToSelector:sel])
140 [inv invokeWithTarget:delegate_];
146 @interface WebView (UICaboodle)
147 + (BOOL) _canHandleRequest:(NSURLRequest *)request;
148 - (void) _setFormDelegate:(id)delegate;
149 - (void) _setLayoutInterval:(float)interval;
150 - (void) setScriptDebugDelegate:(id)delegate;
151 - (void) _setUIKitDelegate:(id)delegate;
152 - (void) _setUsesLoaderCache:(BOOL)uses;
153 - (void) setWebMailDelegate:(id)delegate;
156 @interface WebPreferences (Apple)
157 + (void) _setInitialDefaultTextEncodingToSystemEncoding;
158 - (void) _setLayoutInterval:(NSInteger)interval;
159 - (void) setOfflineWebApplicationCacheEnabled:(BOOL)enabled;
162 @implementation WebScriptObject (UICaboodle)
164 - (NSUInteger) count {
165 id length([self valueForKey:@"length"]);
166 if ([length respondsToSelector:@selector(intValue)])
167 return [length intValue];
172 - (id) objectAtIndex:(unsigned)index {
173 return [self webScriptValueAtIndex:index];
178 @interface BrowserView : UIView {
180 UIWebDocumentView *documentView;
182 @property (nonatomic, retain) UIWebDocumentView *documentView;
185 @implementation BrowserView
187 @synthesize documentView;
190 [documentView release];
194 - (void)layoutSubviews {
195 [super layoutSubviews];
196 if ([documentView respondsToSelector:@selector(setMinimumSize:)])
197 [documentView setMinimumSize:documentView.bounds.size];
202 #define ShowInternals 0
205 #define lprintf(args...) fprintf(stderr, args)
207 @implementation BrowserController
210 #include "UICaboodle/UCInternal.h"
213 + (void) _initialize {
214 //[WebView enableWebThread];
216 WebPreferences *preferences([WebPreferences standardPreferences]);
217 [preferences setCacheModel:WebCacheModelDocumentBrowser];
218 [preferences setOfflineWebApplicationCacheEnabled:YES];
220 [WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
222 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
223 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
224 $UIFormAssistant = objc_getClass("UIFormAssistant");
226 $UIWebBrowserView = objc_getClass("UIWebBrowserView");
227 if ($UIWebBrowserView == nil) {
229 $UIWebBrowserView = objc_getClass("UIWebDocumentView");
237 NSLog(@"[BrowserController dealloc]");
240 if (challenge_ != nil)
241 [challenge_ release];
245 WebView *webview = [document_ webView];
246 [webview setFrameLoadDelegate:nil];
247 [webview setResourceLoadDelegate:nil];
248 [webview setUIDelegate:nil];
249 [webview setScriptDebugDelegate:nil];
250 [webview setPolicyDelegate:nil];
252 /* XXX: these are set by UIWebDocumentView
253 [webview setDownloadDelegate:nil];
254 [webview _setFormDelegate:nil];
255 [webview _setUIKitDelegate:nil];
256 [webview setEditingDelegate:nil];*/
258 /* XXX: no one sets this, ever
259 [webview setWebMailDelegate:nil];*/
261 [document_ setDelegate:nil];
262 [document_ setGestureDelegate:nil];
264 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
265 [document_ setFormEditingDelegate:nil];
267 [document_ setInteractionDelegate:nil];
269 [indirect_ setDelegate:nil];
271 //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
276 [document_ removeFromSuperview];
277 [Documents_ addObject:[document_ autorelease]];
286 [scroller_ setDelegate:nil];
292 if (function_ != nil)
302 [indicator_ release];
305 if (sensitive_ != nil)
306 [sensitive_ release];
309 if (reloaditem_ != nil)
310 [reloaditem_ release];
311 if (loadingitem_ != nil)
312 [loadingitem_ release];
317 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
318 [self loadRequest:[NSURLRequest
321 timeoutInterval:120.0
325 - (void) loadURL:(NSURL *)url {
326 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
329 - (void) loadRequest:(NSURLRequest *)request {
334 [document_ loadRequest:request];
342 if ([request_ HTTPBody] == nil && [request_ HTTPBodyStream] == nil)
343 [self loadRequest:request_];
345 UIAlertView *alert = [[[UIAlertView alloc]
346 initWithTitle:UCLocalize("RESUBMIT_FORM")
349 cancelButtonTitle:UCLocalize("CANCEL")
350 otherButtonTitles:UCLocalize("SUBMIT"), nil
352 [alert setContext:@"submit"];
357 - (WebView *) webView {
358 return [document_ webView];
361 - (UIWebDocumentView *) documentView {
365 /* XXX: WebThreadLock? */
366 - (void) _fixScroller:(CGRect)bounds {
369 if (!editing_ || $UIFormAssistant == nil)
372 UIFormAssistant *assistant([$UIFormAssistant sharedFormAssistant]);
373 CGRect peripheral([assistant peripheralFrame]);
375 NSLog(@"per:%f", peripheral.size.height);
377 extra = peripheral.size.height;
380 CGRect subrect([scroller_ frame]);
381 subrect.size.height -= extra;
383 if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
384 [scroller_ setScrollerIndicatorSubrect:subrect];
386 [document_ setValue:[NSValue valueWithSize:NSMakeSize(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
389 size.height += extra;
390 [scroller_ setContentSize:size];
392 if ([scroller_ respondsToSelector:@selector(releaseRubberBandIfNecessary)])
393 [scroller_ releaseRubberBandIfNecessary];
396 - (void) fixScroller {
397 CGRect bounds([document_ documentBounds]);
399 NSLog(@"_fs:(%f,%f+%f,%f)", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
401 [self _fixScroller:bounds];
404 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
407 NSLog(@"dsf:(%f,%f+%f,%f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
409 [self _fixScroller:frame];
412 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
413 [self view:sender didSetFrame:frame];
416 - (void) pushPage:(CYViewController *)page {
417 [page setDelegate:delegate_];
418 [[self navigationItem] setTitle:title_];
419 [[self navigationController] pushViewController:page animated:YES];
425 // WTR: [self autorelease];
427 [[self navigationController] pushViewController:self animated:YES];
430 - (void) swapPage:(CYViewController *)page {
431 [page setDelegate:delegate_];
432 if (pushed_) [[self navigationController] popViewControllerAnimated:NO];
434 [[self navigationController] pushViewController:page animated:NO];
437 - (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
439 NSLog(@"getSpecial:%@", url);
442 if (CYViewController *page = [delegate_ pageForURL:url hasTag:NULL]) {
444 [self swapPage:page];
446 [self pushPage:page];
453 - (void) formAssistant:(id)sender didBeginEditingFormNode:(id)node {
456 - (void) formAssistant:(id)sender didEndEditingFormNode:(id)node {
460 - (void) webViewShow:(WebView *)sender {
461 /* XXX: this is where I cry myself to sleep */
464 - (bool) _allowJavaScriptPanel {
468 - (bool) allowSensitiveRequests {
469 return [self _allowJavaScriptPanel];
472 - (void) _promptForSensitive:(NSMutableArray *)array {
473 NSString *name([array objectAtIndex:0]);
475 UIAlertView *alert = [[[UIAlertView alloc]
479 cancelButtonTitle:UCLocalize("NO")
480 otherButtonTitles:UCLocalize("YES"), nil
483 NSString *host(@"XXX");
485 [alert setContext:@"sensitive"];
486 [alert setMessage:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
489 NSRunLoop *loop([NSRunLoop currentRunLoop]);
490 NSDate *future([NSDate distantFuture]);
492 while (sensitive_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
494 NSNumber *sensitive([sensitive_ autorelease]);
498 [array replaceObjectAtIndex:0 withObject:sensitive];
501 - (bool) promptForSensitive:(NSString *)name {
502 if (![self allowSensitiveRequests])
505 NSMutableArray *array([NSMutableArray arrayWithCapacity:1]);
506 [array addObject:name];
508 [self performSelectorOnMainThread:@selector(_promptForSensitive:) withObject:array waitUntilDone:YES];
509 return [[array lastObject] boolValue];
512 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
513 if (![self _allowJavaScriptPanel])
517 UIAlertView *alert = [[[UIAlertView alloc]
521 cancelButtonTitle:UCLocalize("OK")
522 otherButtonTitles:nil
524 [alert setContext:@"alert"];
528 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
529 if (![self _allowJavaScriptPanel])
533 UIAlertView *alert = [[[UIAlertView alloc]
537 cancelButtonTitle:UCLocalize("CANCEL")
538 otherButtonTitles:UCLocalize("OK"), nil
541 [alert setContext:@"confirm"];
544 NSRunLoop *loop([NSRunLoop currentRunLoop]);
545 NSDate *future([NSDate distantFuture]);
547 while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
549 NSNumber *confirm([confirm_ autorelease]);
553 return [confirm boolValue];
556 - (void) setAutoPopup:(BOOL)popup {
560 - (void) setSpecial:(id)function {
562 [special_ autorelease];
563 special_ = function == nil ? nil : [function retain];
566 - (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
568 [button_ autorelease];
569 button_ = button == nil ? nil : [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:button]]] retain];
572 [style_ autorelease];
573 style_ = style == nil ? nil : [style retain];
575 if (function_ != nil)
576 [function_ autorelease];
577 function_ = function == nil ? nil : [function retain];
579 [self applyRightButton];
582 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
584 [button_ autorelease];
585 button_ = button == nil ? nil : [button retain];
588 [style_ autorelease];
589 style_ = style == nil ? nil : [style retain];
591 if (function_ != nil)
592 [function_ autorelease];
593 function_ = function == nil ? nil : [function retain];
595 [self applyRightButton];
598 - (void) setFinishHook:(id)function {
600 [finish_ autorelease];
601 finish_ = function == nil ? nil : [function retain];
604 - (void) setPopupHook:(id)function {
606 [closer_ autorelease];
607 closer_ = function == nil ? nil : [function retain];
610 - (void) _openMailToURL:(NSURL *)url {
611 [[UIApplication sharedApplication] openURL:url];// asPanel:YES];
614 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
618 - (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
622 - (void) webViewDidEndEditingFormElements:(WebView *)sender {
627 - (void) webViewClose:(WebView *)sender {
632 [[self navigationController] dismissModalViewControllerAnimated:YES];
635 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
638 - (void) webView:(WebView *)sender unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame {
639 NSLog(@"err:%@", error);
642 - (void) webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {
644 NSLog(@"nwa:%@", name);
647 if (NSURL *url = [request URL]) {
648 if (name == nil) unknown: {
649 if (![self getSpecial:url swap:NO]) {
650 NSString *scheme([[url scheme] lowercaseString]);
651 if ([scheme isEqualToString:@"mailto"])
652 [self _openMailToURL:url];
655 } else if ([name isEqualToString:@"_open"])
656 [delegate_ openURL:url];
657 else if ([name isEqualToString:@"_popup"]) {
658 NSString *scheme([[url scheme] lowercaseString]);
659 if ([scheme isEqualToString:@"mailto"])
660 [self _openMailToURL:url];
662 UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
663 [navigation setHook:indirect_];
665 CYViewController *page([delegate_ pageForURL:url hasTag:NULL]);
667 /* XXX: call createWebViewWithRequest instead? */
669 BrowserController *browser([[[class_ alloc] init] autorelease]);
670 [browser loadURL:url];
674 [navigation setDelegate:delegate_];
675 [page setDelegate:delegate_];
677 [navigation setViewControllers:[NSArray arrayWithObject:page]];
678 UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
679 initWithTitle:UCLocalize("CLOSE")
680 style:UIBarButtonItemStylePlain
682 action:@selector(close)
684 [[page navigationItem] setLeftBarButtonItem:closeItem];
687 [[self navigationController] presentModalViewController:navigation animated:YES];
696 - (void) webView:(WebView *)sender decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
697 if ([WebView canShowMIMEType:type])
700 // XXX: handle more mime types!
703 WebView *webview([document_ webView]);
704 if (frame == [webview mainFrame])
705 [[UIApplication sharedApplication] openURL:[request URL]];
709 - (void) webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
710 if (request == nil) ignore: {
715 NSURL *url([request URL]);
716 NSString *host([url host]);
718 if (url == nil) use: {
719 if (!error_ && [frame parentFrame] == nil) {
721 [request_ autorelease];
722 request_ = [request retain];
724 NSLog(@"dpn:%@", request_);
730 WebView *webview([document_ webView]);
731 if (frame == [webview mainFrame])
736 else NSLog(@"nav:%@:%@", url, [action description]);
739 const NSArray *capability;
741 if ($GSSystemCopyCapability != NULL) {
742 capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(kGSDisplayIdentifiersCapability));
743 capability = [capability autorelease];
744 } else if ($GSSystemGetCapability != NULL) {
745 capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(kGSDisplayIdentifiersCapability));
751 if (capability != nil && (
752 [url isGoogleMapsURL] && [capability containsObject:@"com.apple.Maps"] && (open = [url mapsURL]) != nil||
753 [host hasSuffix:@"youtube.com"] && [capability containsObject:@"com.apple.youtube"] && (open = [url youTubeURL]) != nil ||
754 [url respondsToSelector:@selector(phobosURL)] && (open = [url phobosURL]) != nil
758 [[UIApplication sharedApplication] openURL:url];
762 NSInteger store(_not(NSInteger));
763 if (NSURL *itms = [url itmsURL:&store]) {
765 NSLog(@"itms#%@#%d#%@", url, (int) store, itms);
768 if (capability != nil && (
769 store == 1 && [capability containsObject:@"com.apple.MobileStore"] ||
770 store == 2 && [capability containsObject:@"com.apple.AppStore"]
777 NSString *scheme([[url scheme] lowercaseString]);
779 if ([scheme isEqualToString:@"tel"]) {
784 if ([scheme isEqualToString:@"mailto"]) {
785 [self _openMailToURL:url];
789 if ([self getSpecial:url swap:YES])
791 else if ([WebView _canHandleRequest:request])
793 else if ([url isSpringboardHandledURL])
799 - (void) webView:(WebView *)sender setStatusText:(NSString *)text {
800 //lprintf("Status:%s\n", [text UTF8String]);
803 - (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
804 NSString *context([alert context]);
806 if ([context isEqualToString:@"alert"]) {
808 [alert dismissWithClickedButtonIndex:-1 animated:YES];
809 } else if ([context isEqualToString:@"confirm"]) {
812 confirm_ = [NSNumber numberWithBool:YES];
816 confirm_ = [NSNumber numberWithBool:NO];
820 [alert dismissWithClickedButtonIndex:-1 animated:YES];
821 } else if ([context isEqualToString:@"sensitive"]) {
824 sensitive_ = [NSNumber numberWithBool:YES];
828 sensitive_ = [NSNumber numberWithBool:NO];
832 [alert dismissWithClickedButtonIndex:-1 animated:YES];
833 } else if ([context isEqualToString:@"challenge"]) {
834 id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);
838 NSString *username([[alert textFieldAtIndex:0] text]);
839 NSString *password([[alert textFieldAtIndex:1] text]);
841 NSURLCredential *credential([NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession]);
843 [sender useCredential:credential forAuthenticationChallenge:challenge_];
847 [sender cancelAuthenticationChallenge:challenge_];
853 [challenge_ release];
856 [alert dismissWithClickedButtonIndex:-1 animated:YES];
857 } else if ([context isEqualToString:@"submit"]) {
863 if (request_ != nil) {
865 [document_ loadRequest:request_];
873 [alert dismissWithClickedButtonIndex:-1 animated:YES];
877 - (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
878 challenge_ = [challenge retain];
880 NSURLProtectionSpace *space([challenge protectionSpace]);
881 NSString *realm([space realm]);
885 UIAlertView *alert = [[[UIAlertView alloc]
889 cancelButtonTitle:UCLocalize("CANCEL")
890 otherButtonTitles:UCLocalize("LOGIN"), nil
893 [alert setContext:@"challenge"];
894 [alert setNumberOfRows:1];
896 [alert addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
897 [alert addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
899 UITextField *username([alert textFieldAtIndex:0]); {
900 UITextInputTraits *traits([username textInputTraits]);
901 [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
902 [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
903 [traits setKeyboardType:UIKeyboardTypeASCIICapable];
904 [traits setReturnKeyType:UIReturnKeyNext];
907 UITextField *password([alert textFieldAtIndex:1]); {
908 UITextInputTraits *traits([password textInputTraits]);
909 [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
910 [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
911 [traits setKeyboardType:UIKeyboardTypeASCIICapable];
912 // XXX: UIReturnKeyDone
913 [traits setReturnKeyType:UIReturnKeyNext];
914 [traits setSecureTextEntry:YES];
920 - (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
924 - (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features {
925 //- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request userGesture:(BOOL)gesture {
927 NSLog(@"cwv:%@ (%@): %@", request, title_, features == nil ? @"{}" : [features description]);
928 //NSLog(@"cwv:%@ (%@): %@", request, title_, gesture ? @"Yes" : @"No");
931 NSNumber *value([features objectForKey:@"width"]);
932 float width(value == nil ? 0 : [value floatValue]);
934 UCNavigationController *navigation(!popup_ ? [self navigationController] : [[[UCNavigationController alloc] init] autorelease]);
936 /* XXX: deal with cydia:// pages */
937 BrowserController *browser([[[class_ alloc] initWithWidth:width] autorelease]);
939 if (features != nil && popup_) {
940 [navigation setDelegate:delegate_];
941 [navigation setHook:indirect_];
942 [browser setDelegate:delegate_];
944 [browser loadRequest:request];
946 [navigation setViewControllers:[NSArray arrayWithObject:browser]];
947 UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
948 initWithTitle:UCLocalize("CLOSE")
949 style:UIBarButtonItemStylePlain
951 action:@selector(close)
953 [[browser navigationItem] setLeftBarButtonItem:closeItem];
956 [[self navigationController] presentModalViewController:navigation animated:YES];
957 } /*else if (request == nil) {
958 [[self navigationItem] setTitle:title_];
959 [browser setDelegate:delegate_];
962 [self pushPage:browser];
963 [browser loadRequest:request];
966 return [browser webView];
969 - (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
970 return [self webView:sender createWebViewWithRequest:request windowFeatures:nil];
971 //return [self webView:sender createWebViewWithRequest:request userGesture:YES];
974 - (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
975 if ([frame parentFrame] != nil)
978 title_ = [title retain];
979 [[self navigationItem] setTitle:title_];
982 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
983 /*if ([loading_ count] == 0)
985 [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
987 if ([frame parentFrame] == nil) {
988 [document_ resignFirstResponder];
997 if (button_ != nil) {
1002 if (style_ != nil) {
1007 if (function_ != nil) {
1008 [function_ release];
1012 if (finish_ != nil) {
1017 if (closer_ != nil) {
1022 if (special_ != nil) {
1027 [[self navigationItem] setTitle:title_];
1030 CGRect webrect = [scroller_ bounds];
1031 webrect.size.height = 1;
1032 [document_ setFrame:webrect];
1035 if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
1036 [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
1038 [scroller_ scrollRectToVisible:CGRectZero animated:NO];
1040 if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
1041 [scroller_ setZoomScale:1 duration:0];
1042 else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
1043 [scroller_ _setZoomScale:1 duration:0];
1044 /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
1045 [scroller_ setZoomScale:1 animated:NO];*/
1048 CGRect webrect = [scroller_ bounds];
1049 webrect.size.height = 0;
1050 [document_ setFrame:webrect];
1054 [self _startLoading];
1057 - (UIBarButtonItemStyle) rightButtonStyle {
1058 if (style_ == nil) normal:
1059 return UIBarButtonItemStylePlain;
1060 else if ([style_ isEqualToString:@"Normal"])
1061 return UIBarButtonItemStylePlain;
1062 else if ([style_ isEqualToString:@"Highlighted"])
1063 return UIBarButtonItemStyleDone;
1067 - (UIBarButtonItem *) customButton {
1068 UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
1069 initWithTitle:button_
1070 style:[self rightButtonStyle]
1072 action:@selector(customButtonClicked)
1075 return [customItem autorelease];
1078 - (UIBarButtonItem *) rightButton {
1082 - (void) applyLoadingTitle {
1083 [[self navigationItem] setTitle:UCLocalize("LOADING")];
1086 - (void) applyRightButton {
1087 if ([self isLoading]) {
1088 [[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
1089 [[loadingitem_ view] addSubview:indicator_];
1090 [self applyLoadingTitle];
1091 } else if (button_) {
1092 [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
1094 [[self navigationItem] setRightBarButtonItem:[self rightButton] animated:YES];
1098 - (void) _startLoading {
1099 [self applyRightButton];
1102 - (void) _finishLoading {
1103 size_t count([loading_ count]);
1105 [self autorelease];*/
1106 if (reloading_ || count != 0)
1109 [self callFunction:finish_];
1111 [self applyRightButton];
1112 if (![self isLoading]) [[self navigationItem] setTitle:title_];
1115 - (bool) isLoading {
1116 return [loading_ count] != 0;
1119 - (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
1120 return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
1123 - (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
1124 return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
1127 - (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
1128 return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
1131 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
1133 return [document_ webView:sender didCommitLoadForFrame:frame];
1136 - (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
1137 return [document_ webView:sender didReceiveDocTypeForFrame:frame];
1140 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
1141 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
1142 [self _finishLoading];
1144 if ([frame parentFrame] == nil) {
1145 if (DOMDocument *document = [frame DOMDocument])
1146 if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
1147 for (DOMHTMLBodyElement *body in (id) bodies) {
1148 DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
1150 bool colored(false);
1152 if (DOMCSSPrimitiveValue *color = static_cast<DOMCSSPrimitiveValue *>([style getPropertyCSSValue:@"background-color"])) {
1153 if ([color primitiveType] == DOM_CSS_RGBCOLOR) {
1154 DOMRGBColor *rgb([color getRGBColorValue]);
1156 float red([[rgb red] getFloatValue:DOM_CSS_NUMBER]);
1157 float green([[rgb green] getFloatValue:DOM_CSS_NUMBER]);
1158 float blue([[rgb blue] getFloatValue:DOM_CSS_NUMBER]);
1159 float alpha([[rgb alpha] getFloatValue:DOM_CSS_NUMBER]);
1163 if (red == 0xc7 && green == 0xce && blue == 0xd5)
1164 uic = [UIColor groupTableViewBackgroundColor];
1165 else if (alpha != 0)
1167 colorWithRed:(red / 255)
1175 [scroller_ setBackgroundColor:uic];
1181 [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
1186 return [document_ webView:sender didFinishLoadForFrame:frame];
1189 - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
1191 /*if ([frame parentFrame] == nil)
1192 [self autorelease];*/
1194 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
1195 [self _finishLoading];
1200 if ([frame parentFrame] == nil) {
1201 [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
1202 [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
1203 [[error localizedDescription] stringByAddingPercentEscapes]
1210 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
1211 [self _didFailWithError:error forFrame:frame];
1212 if ([document_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
1213 [document_ webView:sender didFailLoadWithError:error forFrame:frame];
1216 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
1217 [self _didFailWithError:error forFrame:frame];
1220 - (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
1221 #if LogBrowser || ForSaurik
1222 lprintf("Console:%s\n", [[dictionary description] UTF8String]);
1226 - (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
1227 #if LogBrowser || ForSaurik
1228 lprintf("Console:%s\n", [[dictionary description] UTF8String]);
1230 if ([document_ respondsToSelector:@selector(webView:didReceiveMessage:)])
1231 [document_ webView:sender didReceiveMessage:dictionary];
1234 - (void) webView:(id)sender willCloseFrame:(id)frame {
1235 if ([document_ respondsToSelector:@selector(webView:willCloseFrame:)])
1236 [document_ webView:sender willCloseFrame:frame];
1239 - (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
1240 if ([document_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
1241 [document_ webView:sender didFinishDocumentLoadForFrame:frame];
1244 - (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
1245 if ([document_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
1246 [document_ webView:sender didFirstLayoutInFrame:frame];
1249 - (void) webViewFormEditedStatusHasChanged:(id)changed {
1250 if ([document_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
1251 [document_ webViewFormEditedStatusHasChanged:changed];
1254 - (void) webView:(id)sender formStateDidFocusNode:(id)formState {
1255 if ([document_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
1256 [document_ webView:sender formStateDidFocusNode:formState];
1259 - (void) webView:(id)sender formStateDidBlurNode:(id)formState {
1260 if ([document_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
1261 [document_ webView:sender formStateDidBlurNode:formState];
1264 /* XXX: fix this stupid include file
1265 - (void) webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)database {
1266 [origin setQuota:0x500000];
1269 - (void) webViewDidLayout:(id)sender {
1270 [document_ webViewDidLayout:sender];
1273 - (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
1274 [document_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
1277 - (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
1278 [document_ webView:sender saveStateToHistoryItem:item forFrame:frame];
1281 - (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
1282 [document_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
1285 - (void) webView:(id)sender attachRootLayer:(id)layer {
1286 [document_ webView:sender attachRootLayer:layer];
1289 - (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
1290 return [document_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
1293 - (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
1294 [document_ webView:sender willShowFullScreenForPlugInView:view];
1297 - (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
1298 [document_ webView:sender didHideFullScreenForPlugInView:view];
1301 - (void) webView:(id)sender willAddPlugInView:(id)view {
1302 [document_ webView:sender willAddPlugInView:view];
1305 - (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
1306 [document_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
1309 - (void) webViewDidPreventDefaultForEvent:(id)sender {
1310 [document_ webViewDidPreventDefaultForEvent:sender];
1313 - (void) _setTileDrawingEnabled:(BOOL)enabled {
1314 //[document_ setTileDrawingEnabled:enabled];
1317 - (void) setViewportWidth:(float)width {
1318 width_ = width != 0 ? width : [[self class] defaultWidth];
1319 [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
1322 - (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
1323 [self _setTileDrawingEnabled:NO];
1326 - (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
1327 [self _setTileDrawingEnabled:YES];
1328 [document_ redrawScaledDocument];
1331 - (void) scrollerWillStartDragging:(UIScroller *)scroller {
1332 [self _setTileDrawingEnabled:NO];
1335 - (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
1336 [self _setTileDrawingEnabled:YES];
1339 - (void) scrollerDidEndDragging:(UIScroller *)scroller {
1340 [self _setTileDrawingEnabled:YES];
1343 - (id) initWithWidth:(float)width ofClass:(Class)_class {
1344 if ((self = [super init]) != nil) {
1346 loading_ = [[NSMutableSet alloc] initWithCapacity:3];
1349 BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
1350 [self setView:actualView];
1352 struct CGRect bounds = [[self view] bounds];
1354 scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
1355 [[self view] addSubview:scroller_];
1357 [scroller_ setFixedBackgroundPattern:YES];
1358 [scroller_ setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
1360 [scroller_ setScrollingEnabled:YES];
1361 [scroller_ setClipsSubviews:YES];
1364 [scroller_ setAllowsRubberBanding:YES];
1366 [scroller_ setDelegate:self];
1367 [scroller_ setBounces:YES];
1370 [scroller_ setScrollHysteresis:8];
1371 [scroller_ setThumbDetectionEnabled:NO];
1372 [scroller_ setDirectionalScrolling:YES];
1373 //[scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
1374 [scroller_ setEventMode:YES];
1378 UIScrollView *scroller((UIScrollView *)scroller_);
1379 //[scroller setDirectionalLockEnabled:NO];
1380 [scroller setDelaysContentTouches:NO];
1381 //[scroller setScrollsToTop:NO];
1382 //[scroller setCanCancelContentTouches:NO];
1385 [scroller_ setShowBackgroundShadow:NO]; /* YES */
1386 //[scroller_ setAllowsRubberBanding:YES]; /* Vertical */
1389 [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
1391 CGRect webrect = [scroller_ bounds];
1392 webrect.size.height = 0;
1399 document_ = [Documents_ lastObject];
1400 if (document_ != nil) {
1401 document_ = [document_ retain];
1402 webview = [document_ webView];
1403 [Documents_ removeLastObject];
1404 [document_ setFrame:webrect];
1409 document_ = [[$UIWebBrowserView alloc] initWithFrame:webrect];
1410 webview = [document_ webView];
1412 // XXX: this is terribly (too?) expensive
1413 //[document_ setDrawsBackground:NO];
1414 [webview setPreferencesIdentifier:@"Cydia"];
1416 [document_ setTileSize:CGSizeMake(webrect.size.width, 500)];
1418 if ([document_ respondsToSelector:@selector(enableReachability)])
1419 [document_ enableReachability];
1420 if ([document_ respondsToSelector:@selector(setAllowsMessaging:)])
1421 [document_ setAllowsMessaging:YES];
1422 if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
1423 [document_ useSelectionAssistantWithMode:0];
1425 [document_ setTilingEnabled:YES];
1426 [document_ setDrawsGrid:NO];
1427 [document_ setLogsTilingChanges:NO];
1428 [document_ setTileMinificationFilter:kCAFilterNearest];
1430 if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
1431 /* XXX: abstractify */
1432 [document_ setDataDetectorTypes:0x80000000];
1434 [document_ setDetectsPhoneNumbers:NO];
1436 [document_ setAutoresizes:YES];
1438 [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
1439 [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
1440 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
1441 //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
1443 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
1445 [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
1446 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
1447 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
1449 [document_ _setDocumentType:0x4];
1451 if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
1452 [document_ setZoomsFocusedFormControl:YES];
1453 [document_ setContentsPosition:7];
1454 [document_ setEnabledGestures:0xa];
1455 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
1456 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
1458 [document_ setSmoothsFonts:YES];
1459 [document_ setAllowsImageSheet:YES];
1460 [webview _setUsesLoaderCache:YES];
1462 [webview setGroupName:@"CydiaGroup"];
1464 WebPreferences *preferences([webview preferences]);
1466 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
1467 [webview _setLayoutInterval:0];
1469 [preferences _setLayoutInterval:0];
1472 actualView.documentView = document_;
1473 [actualView release];
1475 [self setViewportWidth:width];
1477 [document_ setDelegate:self];
1478 [document_ setGestureDelegate:self];
1480 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
1481 [document_ setFormEditingDelegate:self];
1483 [document_ setInteractionDelegate:self];
1485 [scroller_ addSubview:document_];
1487 //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
1489 indirect_ = [[IndirectDelegate alloc] initWithDelegate:self];
1491 [webview setFrameLoadDelegate:indirect_];
1492 [webview setPolicyDelegate:indirect_];
1493 [webview setResourceLoadDelegate:indirect_];
1494 [webview setUIDelegate:indirect_];
1496 /* XXX: do not turn this on under penalty of extreme pain */
1497 [webview setScriptDebugDelegate:nil];
1501 CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
1502 indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
1503 [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
1504 [indicator_ startAnimation];
1506 reloaditem_ = [[UIBarButtonItem alloc]
1507 initWithTitle:UCLocalize("RELOAD")
1508 style:[self rightButtonStyle]
1510 action:@selector(reloadButtonClicked)
1513 loadingitem_ = [[UIBarButtonItem alloc]
1515 style:UIBarButtonItemStylePlain
1517 action:@selector(reloadButtonClicked)
1519 [[loadingitem_ view] addSubview:indicator_];
1521 [scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
1522 [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
1523 [document_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
1525 /*UIWebView *test([[[UIWebView alloc] initWithFrame:[[self view] bounds]] autorelease]);
1526 [test loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.saurik.com/"]]];
1527 [[self view] addSubview:test];*/
1531 - (id) initWithWidth:(float)width {
1532 return [self initWithWidth:width ofClass:[self class]];
1536 return [self initWithWidth:0];
1539 - (NSString *) stringByEvaluatingJavaScriptFromString:(NSString *)script {
1541 WebView *webview([document_ webView]);
1542 NSString *string([webview stringByEvaluatingJavaScriptFromString:script]);
1547 - (void) callFunction:(WebScriptObject *)function {
1550 WebView *webview([document_ webView]);
1551 WebFrame *frame([webview mainFrame]);
1552 WebPreferences *preferences([webview preferences]);
1554 bool maybe([preferences javaScriptCanOpenWindowsAutomatically]);
1555 [preferences setJavaScriptCanOpenWindowsAutomatically:NO];
1557 /*id _private(MSHookIvar<id>(webview, "_private"));
1558 WebCore::Page *page(_private == nil ? NULL : MSHookIvar<WebCore::Page *>(_private, "page"));
1559 WebCore::Settings *settings(page == NULL ? NULL : page->settings());
1562 if (settings == NULL)
1565 no = settings->JavaScriptCanOpenWindowsAutomatically();
1566 settings->setJavaScriptCanOpenWindowsAutomatically(true);
1569 if (UIWindow *window = [[self view] window])
1570 if (UIResponder *responder = [window firstResponder])
1571 [responder resignFirstResponder];
1573 JSObjectRef object([function JSObject]);
1574 JSGlobalContextRef context([frame globalContext]);
1575 JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
1577 /*if (settings != NULL)
1578 settings->setJavaScriptCanOpenWindowsAutomatically(no);*/
1580 [preferences setJavaScriptCanOpenWindowsAutomatically:maybe];
1585 - (void) didDismissModalViewController {
1587 [self callFunction:closer_];
1590 - (void) reloadButtonClicked {
1595 - (void) _customButtonClicked {
1596 [self reloadButtonClicked];
1599 - (void) customButtonClicked {
1601 if (function_ != nil)
1602 [self callFunction:function_];
1605 [self _customButtonClicked];
1608 - (void) setPageActive:(BOOL)active {
1610 [indicator_ removeFromSuperview];
1612 [[[[self navigationItem] rightBarButtonItem] view] addSubview:indicator_];
1615 - (void) setPushed:(bool)pushed {
1619 + (float) defaultWidth {