1 #include <UICaboodle/BrowserView.h>
2 #include <UICaboodle/UCLocalize.h>
4 #import <QuartzCore/CALayer.h>
5 // XXX: fix the minimum requirement
6 extern NSString * const kCAFilterNearest;
8 #include <WebCore/WebCoreThread.h>
9 #include <WebKit/WebPreferences-WebPrivate.h>
11 #include "substrate.h"
17 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
18 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
19 static Class $UIFormAssistant;
20 static Class $UIWebBrowserView;
22 @interface NSString (UIKit)
23 - (NSString *) stringByAddingPercentEscapes;
26 /* Indirect Delegate {{{ */
27 @interface IndirectDelegate : NSObject {
28 _transient volatile id delegate_;
31 - (void) setDelegate:(id)delegate;
32 - (id) initWithDelegate:(id)delegate;
35 @implementation IndirectDelegate
37 - (void) setDelegate:(id)delegate {
41 - (id) initWithDelegate:(id)delegate {
46 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
48 return [delegate_ webView:sender didClearWindowObject:window forFrame:frame];
51 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
53 return [delegate_ webView:sender didCommitLoadForFrame:frame];
56 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
58 return [delegate_ webView:sender didFailLoadWithError:error forFrame:frame];
61 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
63 return [delegate_ webView:sender didFailProvisionalLoadWithError:error forFrame:frame];
66 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
68 return [delegate_ webView:sender didFinishLoadForFrame:frame];
71 - (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
73 return [delegate_ webView:sender didReceiveTitle:title forFrame:frame];
76 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
78 return [delegate_ webView:sender didStartProvisionalLoadForFrame:frame];
81 - (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
83 return [delegate_ webView:sender resource:identifier didReceiveAuthenticationChallenge:challenge fromDataSource:source];
86 - (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
88 return [delegate_ webView:sender resource:identifier willSendRequest:request redirectResponse:redirectResponse fromDataSource:source];
92 - (IMP) methodForSelector:(SEL)sel {
93 if (IMP method = [super methodForSelector:sel])
95 fprintf(stderr, "methodForSelector:[%s] == NULL\n", sel_getName(sel));
99 - (BOOL) respondsToSelector:(SEL)sel {
100 if ([super respondsToSelector:sel])
102 // XXX: WebThreadCreateNSInvocation returns nil
103 //fprintf(stderr, "[%s]R?%s\n", class_getName(self->isa), sel_getName(sel));
104 return delegate_ == nil ? NO : [delegate_ respondsToSelector:sel];
107 - (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
108 if (NSMethodSignature *method = [super methodSignatureForSelector:sel])
110 //fprintf(stderr, "[%s]S?%s\n", class_getName(self->isa), sel_getName(sel));
111 if (delegate_ != nil)
112 if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
114 // XXX: I fucking hate Apple so very very bad
115 return [NSMethodSignature signatureWithObjCTypes:"v@:"];
118 - (void) forwardInvocation:(NSInvocation *)inv {
119 SEL sel = [inv selector];
120 if (delegate_ != nil && [delegate_ respondsToSelector:sel])
121 [inv invokeWithTarget:delegate_];
127 @interface WebView (UICaboodle)
128 - (void) setScriptDebugDelegate:(id)delegate;
129 - (void) _setFormDelegate:(id)delegate;
130 - (void) _setUIKitDelegate:(id)delegate;
131 - (void) setWebMailDelegate:(id)delegate;
132 - (void) _setLayoutInterval:(float)interval;
135 @implementation WebScriptObject (UICaboodle)
138 id length([self valueForKey:@"length"]);
139 if ([length respondsToSelector:@selector(intValue)])
140 return [length intValue];
145 - (id) objectAtIndex:(unsigned)index {
146 return [self webScriptValueAtIndex:index];
151 @interface BrowserView : UIView {
153 UIWebDocumentView *documentView;
155 @property (nonatomic, retain) UIWebDocumentView *documentView;
158 @implementation BrowserView
160 @synthesize documentView;
163 [documentView release];
167 - (void)layoutSubviews {
168 [super layoutSubviews];
169 if ([documentView respondsToSelector:@selector(setMinimumSize:)])
170 [documentView setMinimumSize:documentView.bounds.size];
175 #define ShowInternals 0
178 #define lprintf(args...) fprintf(stderr, args)
180 @implementation BrowserController
183 #include "UICaboodle/UCInternal.h"
186 + (void) _initialize {
187 //[WebView enableWebThread];
189 WebPreferences *preferences([WebPreferences standardPreferences]);
190 [preferences setCacheModel:WebCacheModelDocumentBrowser];
191 [preferences setOfflineWebApplicationCacheEnabled:YES];
193 [WebPreferences _setInitialDefaultTextEncodingToSystemEncoding];
195 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
196 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
197 $UIFormAssistant = objc_getClass("UIFormAssistant");
199 $UIWebBrowserView = objc_getClass("UIWebBrowserView");
200 if ($UIWebBrowserView == nil) {
202 $UIWebBrowserView = objc_getClass("UIWebDocumentView");
210 NSLog(@"[BrowserController dealloc]");
213 if (challenge_ != nil)
214 [challenge_ release];
218 WebView *webview = [document_ webView];
219 [webview setFrameLoadDelegate:nil];
220 [webview setResourceLoadDelegate:nil];
221 [webview setUIDelegate:nil];
222 [webview setScriptDebugDelegate:nil];
223 [webview setPolicyDelegate:nil];
225 /* XXX: these are set by UIWebDocumentView
226 [webview setDownloadDelegate:nil];
227 [webview _setFormDelegate:nil];
228 [webview _setUIKitDelegate:nil];
229 [webview setEditingDelegate:nil];*/
231 /* XXX: no one sets this, ever
232 [webview setWebMailDelegate:nil];*/
234 [document_ setDelegate:nil];
235 [document_ setGestureDelegate:nil];
237 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
238 [document_ setFormEditingDelegate:nil];
240 [document_ setInteractionDelegate:nil];
242 [indirect_ setDelegate:nil];
244 //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
249 [document_ removeFromSuperview];
250 [Documents_ addObject:[document_ autorelease]];
259 [scroller_ setDelegate:nil];
265 if (function_ != nil)
275 [indicator_ release];
278 if (sensitive_ != nil)
279 [sensitive_ release];
282 if (reloaditem_ != nil)
283 [reloaditem_ release];
284 if (loadingitem_ != nil)
285 [loadingitem_ release];
290 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
291 [self loadRequest:[NSURLRequest
294 timeoutInterval:120.0
298 - (void) loadURL:(NSURL *)url {
299 [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
302 - (void) loadRequest:(NSURLRequest *)request {
307 [document_ loadRequest:request];
315 if ([request_ HTTPBody] == nil && [request_ HTTPBodyStream] == nil)
316 [self loadRequest:request_];
318 UIActionSheet *sheet = [[[UIActionSheet alloc]
319 initWithTitle:UCLocalize("RESUBMIT_FORM")
320 buttons:[NSArray arrayWithObjects:UCLocalize("CANCEL"), UCLocalize("SUBMIT"), nil]
326 [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
328 [sheet setNumberOfRows:1];
329 [sheet popupAlertAnimated:YES];
333 - (WebView *) webView {
334 return [document_ webView];
337 - (UIWebDocumentView *) documentView {
341 /* XXX: WebThreadLock? */
342 - (void) _fixScroller:(CGRect)bounds {
345 if (!editing_ || $UIFormAssistant == nil)
348 UIFormAssistant *assistant([$UIFormAssistant sharedFormAssistant]);
349 CGRect peripheral([assistant peripheralFrame]);
351 NSLog(@"per:%f", peripheral.size.height);
353 extra = peripheral.size.height;
356 CGRect subrect([scroller_ frame]);
357 subrect.size.height -= extra;
359 if ([scroller_ respondsToSelector:@selector(setScrollerIndicatorSubrect:)])
360 [scroller_ setScrollerIndicatorSubrect:subrect];
362 [document_ setValue:[NSValue valueWithSize:NSMakeSize(subrect.size.width, subrect.size.height)] forGestureAttribute:UIGestureAttributeVisibleSize];
365 size.height += extra;
366 [scroller_ setContentSize:size];
368 if ([scroller_ respondsToSelector:@selector(releaseRubberBandIfNecessary)])
369 [scroller_ releaseRubberBandIfNecessary];
372 - (void) fixScroller {
373 CGRect bounds([document_ documentBounds]);
375 NSLog(@"_fs:(%f,%f+%f,%f)", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
377 [self _fixScroller:bounds];
380 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
383 NSLog(@"dsf:(%f,%f+%f,%f)", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
385 [self _fixScroller:frame];
388 - (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
389 [self view:sender didSetFrame:frame];
392 - (void) pushPage:(UCViewController *)page {
393 [page setDelegate:delegate_];
394 [[self navigationItem] setTitle:title_];
395 [[self navigationController] pushViewController:page animated:YES];
401 // WTR: [self autorelease];
403 [[self navigationController] pushViewController:self animated:YES];
406 - (void) swapPage:(UCViewController *)page {
407 [page setDelegate:delegate_];
408 if (pushed_) [[self navigationController] popViewControllerAnimated:NO];
410 [[self navigationController] pushViewController:page animated:NO];
413 - (BOOL) getSpecial:(NSURL *)url swap:(BOOL)swap {
415 NSLog(@"getSpecial:%@", url);
418 if (UCViewController *page = [delegate_ pageForURL:url hasTag:NULL]) {
420 [self swapPage:page];
422 [self pushPage:page];
429 - (void) formAssistant:(id)sender didBeginEditingFormNode:(id)node {
432 - (void) formAssistant:(id)sender didEndEditingFormNode:(id)node {
436 - (void) webViewShow:(WebView *)sender {
437 /* XXX: this is where I cry myself to sleep */
440 - (bool) _allowJavaScriptPanel {
444 - (bool) allowSensitiveRequests {
445 return [self _allowJavaScriptPanel];
448 - (void) _promptForSensitive:(NSMutableArray *)array {
449 NSString *name([array objectAtIndex:0]);
451 UIActionSheet *sheet = [[[UIActionSheet alloc]
453 buttons:[NSArray arrayWithObjects:UCLocalize("YES"), UCLocalize("NO"), nil]
459 [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
461 NSString *host(@"XXX");
463 [sheet setNumberOfRows:1];
464 [sheet setBodyText:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
465 [sheet popupAlertAnimated:YES];
467 NSRunLoop *loop([NSRunLoop currentRunLoop]);
468 NSDate *future([NSDate distantFuture]);
470 while (sensitive_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
472 NSNumber *sensitive([sensitive_ autorelease]);
476 [array replaceObjectAtIndex:0 withObject:sensitive];
479 - (bool) promptForSensitive:(NSString *)name {
480 if (![self allowSensitiveRequests])
483 NSMutableArray *array([NSMutableArray arrayWithCapacity:1]);
484 [array addObject:name];
486 [self performSelectorOnMainThread:@selector(_promptForSensitive:) withObject:array waitUntilDone:YES];
487 return [[array lastObject] boolValue];
490 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
491 if (![self _allowJavaScriptPanel])
495 UIActionSheet *sheet = [[[UIActionSheet alloc]
497 buttons:[NSArray arrayWithObjects:UCLocalize("OK"), nil]
503 [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
505 [sheet setBodyText:message];
506 [sheet popupAlertAnimated:YES];
509 - (BOOL) webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
510 if (![self _allowJavaScriptPanel])
514 UIActionSheet *sheet = [[[UIActionSheet alloc]
516 buttons:[NSArray arrayWithObjects:UCLocalize("OK"), UCLocalize("CANCEL"), nil]
522 [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
524 [sheet setNumberOfRows:1];
525 [sheet setBodyText:message];
526 [sheet popupAlertAnimated:YES];
528 NSRunLoop *loop([NSRunLoop currentRunLoop]);
529 NSDate *future([NSDate distantFuture]);
531 while (confirm_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
533 NSNumber *confirm([confirm_ autorelease]);
537 return [confirm boolValue];
540 - (void) setAutoPopup:(BOOL)popup {
544 - (void) setSpecial:(id)function {
546 [special_ autorelease];
547 special_ = function == nil ? nil : [function retain];
550 - (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
552 [button_ autorelease];
553 button_ = button == nil ? nil : [[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:button]]] retain];
556 [style_ autorelease];
557 style_ = style == nil ? nil : [style retain];
559 if (function_ != nil)
560 [function_ autorelease];
561 function_ = function == nil ? nil : [function retain];
563 [self applyRightButton];
566 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
568 [button_ autorelease];
569 button_ = button == nil ? nil : [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) setFinishHook:(id)function {
584 [finish_ autorelease];
585 finish_ = function == nil ? nil : [function retain];
588 - (void) setPopupHook:(id)function {
590 [closer_ autorelease];
591 closer_ = function == nil ? nil : [function retain];
594 - (void) _openMailToURL:(NSURL *)url {
595 [UIApp openURL:url];// asPanel:YES];
598 - (void) webView:(WebView *)sender willBeginEditingFormElement:(id)element {
602 - (void) webView:(WebView *)sender didBeginEditingFormElement:(id)element {
606 - (void) webViewDidEndEditingFormElements:(WebView *)sender {
611 - (void) webViewClose:(WebView *)sender {
616 [[self navigationController] dismissModalViewControllerAnimated:YES];
619 - (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
622 - (void) webView:(WebView *)sender unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame {
623 NSLog(@"err:%@", error);
626 - (void) webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {
628 NSLog(@"nwa:%@", name);
631 if (NSURL *url = [request URL]) {
632 if (name == nil) unknown: {
633 if (![self getSpecial:url swap:NO]) {
634 NSString *scheme([[url scheme] lowercaseString]);
635 if ([scheme isEqualToString:@"mailto"])
636 [self _openMailToURL:url];
639 } else if ([name isEqualToString:@"_open"])
640 [delegate_ openURL:url];
641 else if ([name isEqualToString:@"_popup"]) {
642 NSString *scheme([[url scheme] lowercaseString]);
643 if ([scheme isEqualToString:@"mailto"])
644 [self _openMailToURL:url];
646 UCNavigationController *navigation([[[UCNavigationController alloc] init] autorelease]);
647 [navigation setHook:indirect_];
649 UCViewController *page([delegate_ pageForURL:url hasTag:NULL]);
651 /* XXX: call createWebViewWithRequest instead? */
653 BrowserController *browser([[[class_ alloc] init] autorelease]);
654 [browser loadURL:url];
658 [navigation setDelegate:delegate_];
659 [page setDelegate:delegate_];
661 [navigation setViewControllers:[NSArray arrayWithObject:page]];
662 UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
663 initWithTitle:UCLocalize("CLOSE")
664 style:UIBarButtonItemStylePlain
666 action:@selector(close)
668 [[page navigationItem] setLeftBarButtonItem:closeItem];
671 [[self navigationController] presentModalViewController:navigation animated:YES];
680 - (void) webView:(WebView *)sender decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
681 if ([WebView canShowMIMEType:type])
684 // XXX: handle more mime types!
687 WebView *webview([document_ webView]);
688 if (frame == [webview mainFrame])
689 [UIApp openURL:[request URL]];
693 - (void) webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
694 if (request == nil) ignore: {
699 NSURL *url([request URL]);
700 NSString *host([url host]);
702 if (url == nil) use: {
703 if (!error_ && [frame parentFrame] == nil) {
705 [request_ autorelease];
706 request_ = [request retain];
708 NSLog(@"dpn:%@", request_);
714 WebView *webview([document_ webView]);
715 if (frame == [webview mainFrame])
720 else NSLog(@"nav:%@:%@", url, [action description]);
723 const NSArray *capability;
725 if ($GSSystemCopyCapability != NULL) {
726 capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(kGSDisplayIdentifiersCapability));
727 capability = [capability autorelease];
728 } else if ($GSSystemGetCapability != NULL) {
729 capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(kGSDisplayIdentifiersCapability));
735 if (capability != nil && (
736 [url isGoogleMapsURL] && [capability containsObject:@"com.apple.Maps"] && (open = [url mapsURL]) != nil||
737 [host hasSuffix:@"youtube.com"] && [capability containsObject:@"com.apple.youtube"] && (open = [url youTubeURL]) != nil ||
738 [url respondsToSelector:@selector(phobosURL)] && (open = [url phobosURL]) != nil
746 int store(_not(int));
747 if (NSURL *itms = [url itmsURL:&store]) {
749 NSLog(@"itms#%@#%u#%@", url, store, itms);
752 if (capability != nil && (
753 store == 1 && [capability containsObject:@"com.apple.MobileStore"] ||
754 store == 2 && [capability containsObject:@"com.apple.AppStore"]
761 NSString *scheme([[url scheme] lowercaseString]);
763 if ([scheme isEqualToString:@"tel"]) {
768 if ([scheme isEqualToString:@"mailto"]) {
769 [self _openMailToURL:url];
773 if ([self getSpecial:url swap:YES])
775 else if ([WebView _canHandleRequest:request])
777 else if ([url isSpringboardHandledURL])
783 - (void) webView:(WebView *)sender setStatusText:(NSString *)text {
784 //lprintf("Status:%s\n", [text UTF8String]);
787 - (void) alertSheet:(UIActionSheet *)sheet buttonClicked:(int)button {
788 NSString *context([sheet context]);
790 if ([context isEqualToString:@"alert"]) {
793 } else if ([context isEqualToString:@"confirm"]) {
796 confirm_ = [NSNumber numberWithBool:YES];
800 confirm_ = [NSNumber numberWithBool:NO];
805 } else if ([context isEqualToString:@"sensitive"]) {
808 sensitive_ = [NSNumber numberWithBool:YES];
812 sensitive_ = [NSNumber numberWithBool:NO];
817 } else if ([context isEqualToString:@"challenge"]) {
818 id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);
822 NSString *username([[sheet textFieldAtIndex:0] text]);
823 NSString *password([[sheet textFieldAtIndex:1] text]);
825 NSURLCredential *credential([NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession]);
827 [sender useCredential:credential forAuthenticationChallenge:challenge_];
831 [sender cancelAuthenticationChallenge:challenge_];
837 [challenge_ release];
841 } else if ([context isEqualToString:@"submit"]) {
847 if (request_ != nil) {
849 [document_ loadRequest:request_];
861 - (void) webView:(WebView *)sender resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)source {
862 challenge_ = [challenge retain];
864 NSURLProtectionSpace *space([challenge protectionSpace]);
865 NSString *realm([space realm]);
869 UIActionSheet *sheet = [[[UIActionSheet alloc]
871 buttons:[NSArray arrayWithObjects:UCLocalize("LOGIN"), UCLocalize("CANCEL"), nil]
877 [sheet setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
879 [sheet setNumberOfRows:1];
881 [sheet addTextFieldWithValue:@"" label:UCLocalize("USERNAME")];
882 [sheet addTextFieldWithValue:@"" label:UCLocalize("PASSWORD")];
884 UITextField *username([sheet textFieldAtIndex:0]); {
885 UITextInputTraits *traits([username textInputTraits]);
886 [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
887 [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
888 [traits setKeyboardType:UIKeyboardTypeASCIICapable];
889 [traits setReturnKeyType:UIReturnKeyNext];
892 UITextField *password([sheet textFieldAtIndex:1]); {
893 UITextInputTraits *traits([password textInputTraits]);
894 [traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
895 [traits setAutocorrectionType:UITextAutocorrectionTypeNo];
896 [traits setKeyboardType:UIKeyboardTypeASCIICapable];
897 // XXX: UIReturnKeyDone
898 [traits setReturnKeyType:UIReturnKeyNext];
899 [traits setSecureTextEntry:YES];
902 [sheet popupAlertAnimated:YES];
905 - (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)source {
909 - (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features {
910 //- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request userGesture:(BOOL)gesture {
912 NSLog(@"cwv:%@ (%@): %@", request, title_, features == nil ? @"{}" : [features description]);
913 //NSLog(@"cwv:%@ (%@): %@", request, title_, gesture ? @"Yes" : @"No");
916 NSNumber *value([features objectForKey:@"width"]);
917 float width(value == nil ? 0 : [value floatValue]);
919 UCNavigationController *navigation(!popup_ ? [self navigationController] : [[[UCNavigationController alloc] init] autorelease]);
921 /* XXX: deal with cydia:// pages */
922 BrowserController *browser([[[class_ alloc] initWithWidth:width] autorelease]);
924 if (features != nil && popup_) {
925 [navigation setDelegate:delegate_];
926 [navigation setHook:indirect_];
927 [browser setDelegate:delegate_];
929 [browser loadRequest:request];
931 [navigation setViewControllers:[NSArray arrayWithObject:browser]];
932 UIBarButtonItem *closeItem = [[UIBarButtonItem alloc]
933 initWithTitle:UCLocalize("CLOSE")
934 style:UIBarButtonItemStylePlain
936 action:@selector(close)
938 [[browser navigationItem] setLeftBarButtonItem:closeItem];
941 [[self navigationController] presentModalViewController:navigation animated:YES];
942 } /*else if (request == nil) {
943 [[self navigationItem] setTitle:title_];
944 [browser setDelegate:delegate_];
947 [self pushPage:browser];
948 [browser loadRequest:request];
951 return [browser webView];
954 - (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
955 return [self webView:sender createWebViewWithRequest:request windowFeatures:nil];
956 //return [self webView:sender createWebViewWithRequest:request userGesture:YES];
959 - (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
960 if ([frame parentFrame] != nil)
963 title_ = [title retain];
964 [[self navigationItem] setTitle:title_];
967 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
968 /*if ([loading_ count] == 0)
970 [loading_ addObject:[NSValue valueWithNonretainedObject:frame]];
972 if ([frame parentFrame] == nil) {
973 [document_ resignFirstResponder];
982 if (button_ != nil) {
992 if (function_ != nil) {
997 if (finish_ != nil) {
1002 if (closer_ != nil) {
1007 if (special_ != nil) {
1012 [[self navigationItem] setTitle:title_];
1015 CGRect webrect = [scroller_ bounds];
1016 webrect.size.height = 1;
1017 [document_ setFrame:webrect];
1020 if ([scroller_ respondsToSelector:@selector(scrollPointVisibleAtTopLeft:)])
1021 [scroller_ scrollPointVisibleAtTopLeft:CGPointZero];
1023 [scroller_ scrollRectToVisible:CGRectZero animated:NO];
1025 if ([scroller_ respondsToSelector:@selector(setZoomScale:duration:)])
1026 [scroller_ setZoomScale:1 duration:0];
1027 else if ([scroller_ respondsToSelector:@selector(_setZoomScale:duration:)])
1028 [scroller_ _setZoomScale:1 duration:0];
1029 /*else if ([scroller_ respondsToSelector:@selector(setZoomScale:animated:)])
1030 [scroller_ setZoomScale:1 animated:NO];*/
1033 CGRect webrect = [scroller_ bounds];
1034 webrect.size.height = 0;
1035 [document_ setFrame:webrect];
1039 [self _startLoading];
1042 - (UINavigationButtonStyle) rightButtonStyle {
1043 if (style_ == nil) normal:
1044 return UINavigationButtonStyleNormal;
1045 else if ([style_ isEqualToString:@"Normal"])
1046 return UINavigationButtonStyleNormal;
1047 else if ([style_ isEqualToString:@"Back"])
1048 return UINavigationButtonStyleBack;
1049 else if ([style_ isEqualToString:@"Highlighted"])
1050 return UINavigationButtonStyleHighlighted;
1051 else if ([style_ isEqualToString:@"Destructive"])
1052 return UINavigationButtonStyleDestructive;
1056 - (UIBarButtonItem *) customButton {
1057 UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
1058 initWithTitle:button_
1059 style:[self rightButtonStyle]
1061 action:@selector(customButtonClicked)
1064 return [customItem autorelease];
1067 - (void) applyLoadingTitle {
1068 [[self navigationItem] setTitle:UCLocalize("LOADING")];
1071 - (void) applyRightButton {
1072 if ([self isLoading]) {
1073 [[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
1074 [self applyLoadingTitle];
1075 } else if (button_) {
1076 [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
1078 [[self navigationItem] setRightBarButtonItem:reloaditem_ animated:YES];
1082 - (void) _startLoading {
1083 [self applyRightButton];
1086 - (void) _finishLoading {
1087 size_t count([loading_ count]);
1089 [self autorelease];*/
1090 if (reloading_ || count != 0)
1093 [self callFunction:finish_];
1095 [self applyRightButton];
1096 if (![self isLoading]) [[self navigationItem] setTitle:title_];
1099 - (bool) isLoading {
1100 return [loading_ count] != 0;
1103 - (BOOL) webView:(WebView *)sender shouldScrollToPoint:(struct CGPoint)point forFrame:(WebFrame *)frame {
1104 return [document_ webView:sender shouldScrollToPoint:point forFrame:frame];
1107 - (void) webView:(WebView *)sender didReceiveViewportArguments:(id)arguments forFrame:(WebFrame *)frame {
1108 return [document_ webView:sender didReceiveViewportArguments:arguments forFrame:frame];
1111 - (void) webView:(WebView *)sender needsScrollNotifications:(id)notifications forFrame:(WebFrame *)frame {
1112 return [document_ webView:sender needsScrollNotifications:notifications forFrame:frame];
1115 - (void) webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame {
1117 return [document_ webView:sender didCommitLoadForFrame:frame];
1120 - (void) webView:(WebView *)sender didReceiveDocTypeForFrame:(WebFrame *)frame {
1121 return [document_ webView:sender didReceiveDocTypeForFrame:frame];
1124 - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
1125 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
1126 [self _finishLoading];
1128 if ([frame parentFrame] == nil) {
1129 if (DOMDocument *document = [frame DOMDocument])
1130 if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
1131 for (DOMHTMLBodyElement *body in bodies) {
1132 DOMCSSStyleDeclaration *style([document getComputedStyle:body pseudoElement:nil]);
1134 bool colored(false);
1136 if (DOMCSSPrimitiveValue *color = static_cast<DOMCSSPrimitiveValue *>([style getPropertyCSSValue:@"background-color"])) {
1137 if ([color primitiveType] == DOM_CSS_RGBCOLOR) {
1138 DOMRGBColor *rgb([color getRGBColorValue]);
1140 float red([[rgb red] getFloatValue:DOM_CSS_NUMBER]);
1141 float green([[rgb green] getFloatValue:DOM_CSS_NUMBER]);
1142 float blue([[rgb blue] getFloatValue:DOM_CSS_NUMBER]);
1143 float alpha([[rgb alpha] getFloatValue:DOM_CSS_NUMBER]);
1147 if (red == 0xc7 && green == 0xce && blue == 0xd5)
1148 uic = [UIColor pinStripeColor];
1149 else if (alpha != 0)
1151 colorWithRed:(red / 255)
1159 [scroller_ setBackgroundColor:uic];
1165 [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
1170 return [document_ webView:sender didFinishLoadForFrame:frame];
1173 - (void) _didFailWithError:(NSError *)error forFrame:(WebFrame *)frame {
1175 /*if ([frame parentFrame] == nil)
1176 [self autorelease];*/
1178 [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
1179 [self _finishLoading];
1184 if ([frame parentFrame] == nil) {
1185 [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
1186 [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
1187 [[error localizedDescription] stringByAddingPercentEscapes]
1194 - (void) webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
1195 [self _didFailWithError:error forFrame:frame];
1196 if ([document_ respondsToSelector:@selector(webView:didFailLoadWithError:forFrame:)])
1197 [document_ webView:sender didFailLoadWithError:error forFrame:frame];
1200 - (void) webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame {
1201 [self _didFailWithError:error forFrame:frame];
1204 - (void) webView:(WebView *)sender addMessageToConsole:(NSDictionary *)dictionary {
1205 #if LogBrowser || ForSaurik
1206 lprintf("Console:%s\n", [[dictionary description] UTF8String]);
1210 - (void) webView:(WebView *)sender didReceiveMessage:(NSDictionary *)dictionary {
1211 #if LogBrowser || ForSaurik
1212 lprintf("Console:%s\n", [[dictionary description] UTF8String]);
1214 if ([document_ respondsToSelector:@selector(webView:didReceiveMessage:)])
1215 [document_ webView:sender didReceiveMessage:dictionary];
1218 - (void) webView:(id)sender willCloseFrame:(id)frame {
1219 if ([document_ respondsToSelector:@selector(webView:willCloseFrame:)])
1220 [document_ webView:sender willCloseFrame:frame];
1223 - (void) webView:(id)sender didFinishDocumentLoadForFrame:(id)frame {
1224 if ([document_ respondsToSelector:@selector(webView:didFinishDocumentLoadForFrame:)])
1225 [document_ webView:sender didFinishDocumentLoadForFrame:frame];
1228 - (void) webView:(id)sender didFirstLayoutInFrame:(id)frame {
1229 if ([document_ respondsToSelector:@selector(webView:didFirstLayoutInFrame:)])
1230 [document_ webView:sender didFirstLayoutInFrame:frame];
1233 - (void) webViewFormEditedStatusHasChanged:(id)changed {
1234 if ([document_ respondsToSelector:@selector(webViewFormEditedStatusHasChanged:)])
1235 [document_ webViewFormEditedStatusHasChanged:changed];
1238 - (void) webView:(id)sender formStateDidFocusNode:(id)formState {
1239 if ([document_ respondsToSelector:@selector(webView:formStateDidFocusNode:)])
1240 [document_ webView:sender formStateDidFocusNode:formState];
1243 - (void) webView:(id)sender formStateDidBlurNode:(id)formState {
1244 if ([document_ respondsToSelector:@selector(webView:formStateDidBlurNode:)])
1245 [document_ webView:sender formStateDidBlurNode:formState];
1248 /* XXX: fix this stupid include file
1249 - (void) webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)database {
1250 [origin setQuota:0x500000];
1253 - (void) webViewDidLayout:(id)sender {
1254 [document_ webViewDidLayout:sender];
1257 - (void) webView:(id)sender didFirstVisuallyNonEmptyLayoutInFrame:(id)frame {
1258 [document_ webView:sender didFirstVisuallyNonEmptyLayoutInFrame:frame];
1261 - (void) webView:(id)sender saveStateToHistoryItem:(id)item forFrame:(id)frame {
1262 [document_ webView:sender saveStateToHistoryItem:item forFrame:frame];
1265 - (void) webView:(id)sender restoreStateFromHistoryItem:(id)item forFrame:(id)frame force:(BOOL)force {
1266 [document_ webView:sender restoreStateFromHistoryItem:item forFrame:frame force:force];
1269 - (void) webView:(id)sender attachRootLayer:(id)layer {
1270 [document_ webView:sender attachRootLayer:layer];
1273 - (id) webView:(id)sender plugInViewWithArguments:(id)arguments fromPlugInPackage:(id)package {
1274 return [document_ webView:sender plugInViewWithArguments:arguments fromPlugInPackage:package];
1277 - (void) webView:(id)sender willShowFullScreenForPlugInView:(id)view {
1278 [document_ webView:sender willShowFullScreenForPlugInView:view];
1281 - (void) webView:(id)sender didHideFullScreenForPlugInView:(id)view {
1282 [document_ webView:sender didHideFullScreenForPlugInView:view];
1285 - (void) webView:(id)sender willAddPlugInView:(id)view {
1286 [document_ webView:sender willAddPlugInView:view];
1289 - (void) webView:(id)sender didObserveDeferredContentChange:(int)change forFrame:(id)frame {
1290 [document_ webView:sender didObserveDeferredContentChange:change forFrame:frame];
1293 - (void) webViewDidPreventDefaultForEvent:(id)sender {
1294 [document_ webViewDidPreventDefaultForEvent:sender];
1297 - (void) _setTileDrawingEnabled:(BOOL)enabled {
1298 //[document_ setTileDrawingEnabled:enabled];
1301 - (void) setViewportWidth:(float)width {
1302 width_ = width != 0 ? width : [[self class] defaultWidth];
1303 [document_ setViewportSize:CGSizeMake(width_, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
1306 - (void) willStartGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
1307 [self _setTileDrawingEnabled:NO];
1310 - (void) didFinishGesturesInView:(UIView *)view forEvent:(GSEventRef)event {
1311 [self _setTileDrawingEnabled:YES];
1312 [document_ redrawScaledDocument];
1315 - (void) scrollerWillStartDragging:(UIScroller *)scroller {
1316 [self _setTileDrawingEnabled:NO];
1319 - (void) scrollerDidEndDragging:(UIScroller *)scroller willSmoothScroll:(BOOL)smooth {
1320 [self _setTileDrawingEnabled:YES];
1323 - (void) scrollerDidEndDragging:(UIScroller *)scroller {
1324 [self _setTileDrawingEnabled:YES];
1327 - (id) initWithWidth:(float)width ofClass:(Class)_class {
1328 if ((self = [super init]) != nil) {
1330 loading_ = [[NSMutableSet alloc] initWithCapacity:3];
1333 BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
1334 [self setView:actualView];
1336 struct CGRect bounds = [[self view] bounds];
1338 scroller_ = [[objc_getClass(Wildcat_ ? "UIScrollView" : "UIScroller") alloc] initWithFrame:bounds];
1339 [[self view] addSubview:scroller_];
1341 [scroller_ setFixedBackgroundPattern:YES];
1342 [scroller_ setBackgroundColor:[UIColor pinStripeColor]];
1344 [scroller_ setScrollingEnabled:YES];
1345 [scroller_ setClipsSubviews:YES];
1348 [scroller_ setAllowsRubberBanding:YES];
1350 [scroller_ setDelegate:self];
1351 [scroller_ setBounces:YES];
1354 [scroller_ setScrollHysteresis:8];
1355 [scroller_ setThumbDetectionEnabled:NO];
1356 [scroller_ setDirectionalScrolling:YES];
1357 //[scroller_ setScrollDecelerationFactor:0.99]; /* 0.989324 */
1358 [scroller_ setEventMode:YES];
1362 UIScrollView *scroller((UIScrollView *)scroller_);
1363 //[scroller setDirectionalLockEnabled:NO];
1364 [scroller setDelaysContentTouches:NO];
1365 //[scroller setScrollsToTop:NO];
1366 //[scroller setCanCancelContentTouches:NO];
1369 [scroller_ setShowBackgroundShadow:NO]; /* YES */
1370 //[scroller_ setAllowsRubberBanding:YES]; /* Vertical */
1373 [scroller_ setAdjustForContentSizeChange:YES]; /* NO */
1375 CGRect webrect = [scroller_ bounds];
1376 webrect.size.height = 0;
1383 document_ = [Documents_ lastObject];
1384 if (document_ != nil) {
1385 document_ = [document_ retain];
1386 webview = [document_ webView];
1387 [Documents_ removeLastObject];
1388 [document_ setFrame:webrect];
1393 document_ = [[$UIWebBrowserView alloc] initWithFrame:webrect];
1394 webview = [document_ webView];
1396 // XXX: this is terribly (too?) expensive
1397 //[document_ setDrawsBackground:NO];
1398 [webview setPreferencesIdentifier:@"Cydia"];
1400 [document_ setTileSize:CGSizeMake(webrect.size.width, 500)];
1402 if ([document_ respondsToSelector:@selector(enableReachability)])
1403 [document_ enableReachability];
1404 if ([document_ respondsToSelector:@selector(setAllowsMessaging:)])
1405 [document_ setAllowsMessaging:YES];
1406 if ([document_ respondsToSelector:@selector(useSelectionAssistantWithMode:)])
1407 [document_ useSelectionAssistantWithMode:0];
1409 [document_ setTilingEnabled:YES];
1410 [document_ setDrawsGrid:NO];
1411 [document_ setLogsTilingChanges:NO];
1412 [document_ setTileMinificationFilter:kCAFilterNearest];
1414 if ([document_ respondsToSelector:@selector(setDataDetectorTypes:)])
1415 /* XXX: abstractify */
1416 [document_ setDataDetectorTypes:0x80000000];
1418 [document_ setDetectsPhoneNumbers:NO];
1420 [document_ setAutoresizes:YES];
1422 [document_ setMinimumScale:0.25f forDocumentTypes:0x10];
1423 [document_ setMaximumScale:5.00f forDocumentTypes:0x10];
1424 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x10];
1425 //[document_ setViewportSize:CGSizeMake(980, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x10];
1427 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x2];
1429 [document_ setMinimumScale:1.00f forDocumentTypes:0x8];
1430 [document_ setInitialScale:UIWebViewScalesToFitScale forDocumentTypes:0x8];
1431 [document_ setViewportSize:CGSizeMake(320, UIWebViewGrowsAndShrinksToFitHeight) forDocumentTypes:0x8];
1433 [document_ _setDocumentType:0x4];
1435 if ([document_ respondsToSelector:@selector(setZoomsFocusedFormControl:)])
1436 [document_ setZoomsFocusedFormControl:YES];
1437 [document_ setContentsPosition:7];
1438 [document_ setEnabledGestures:0xa];
1439 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeIsZoomRubberBandEnabled];
1440 [document_ setValue:[NSNumber numberWithBool:YES] forGestureAttribute:UIGestureAttributeUpdatesScroller];
1442 [document_ setSmoothsFonts:YES];
1443 [document_ setAllowsImageSheet:YES];
1444 [webview _setUsesLoaderCache:YES];
1446 [webview setGroupName:@"CydiaGroup"];
1448 WebPreferences *preferences([webview preferences]);
1450 if ([webview respondsToSelector:@selector(_setLayoutInterval:)])
1451 [webview _setLayoutInterval:0];
1453 [preferences _setLayoutInterval:0];
1456 actualView.documentView = document_;
1457 [actualView release];
1459 [self setViewportWidth:width];
1461 [document_ setDelegate:self];
1462 [document_ setGestureDelegate:self];
1464 if ([document_ respondsToSelector:@selector(setFormEditingDelegate:)])
1465 [document_ setFormEditingDelegate:self];
1467 [document_ setInteractionDelegate:self];
1469 [scroller_ addSubview:document_];
1471 //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
1473 indirect_ = [[IndirectDelegate alloc] initWithDelegate:self];
1475 [webview setFrameLoadDelegate:indirect_];
1476 [webview setPolicyDelegate:indirect_];
1477 [webview setResourceLoadDelegate:indirect_];
1478 [webview setUIDelegate:indirect_];
1480 /* XXX: do not turn this on under penalty of extreme pain */
1481 [webview setScriptDebugDelegate:nil];
1485 CGSize indsize = [UIProgressIndicator defaultSizeForStyle:UIProgressIndicatorStyleMediumWhite];
1486 indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
1487 [indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
1488 [indicator_ startAnimation];
1490 reloaditem_ = [[UIBarButtonItem alloc]
1491 initWithTitle:UCLocalize("RELOAD")
1492 style:[self rightButtonStyle]
1494 action:@selector(reloadButtonClicked)
1497 loadingitem_ = [[UIBarButtonItem alloc]
1499 style:UIBarButtonItemStylePlain
1501 action:@selector(reloadButtonClicked)
1503 [[loadingitem_ view] addSubview:indicator_];
1505 [scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
1506 [indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
1507 [document_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
1509 /*UIWebView *test([[[UIWebView alloc] initWithFrame:[[self view] bounds]] autorelease]);
1510 [test loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.saurik.com/"]]];
1511 [[self view] addSubview:test];*/
1515 - (id) initWithWidth:(float)width {
1516 return [self initWithWidth:width ofClass:[self class]];
1520 return [self initWithWidth:0];
1523 - (NSString *) stringByEvaluatingJavaScriptFromString:(NSString *)script {
1525 WebView *webview([document_ webView]);
1526 NSString *string([webview stringByEvaluatingJavaScriptFromString:script]);
1531 - (void) callFunction:(WebScriptObject *)function {
1534 WebView *webview([document_ webView]);
1535 WebFrame *frame([webview mainFrame]);
1537 id _private(MSHookIvar<id>(webview, "_private"));
1538 WebCore::Page *page(_private == nil ? NULL : MSHookIvar<WebCore::Page *>(_private, "page"));
1539 WebCore::Settings *settings(page == NULL ? NULL : page->settings());
1542 if (settings == NULL)
1545 no = settings->JavaScriptCanOpenWindowsAutomatically();
1546 settings->setJavaScriptCanOpenWindowsAutomatically(true);
1549 if (UIWindow *window = [[self view] window])
1550 if (UIResponder *responder = [window firstResponder])
1551 [responder resignFirstResponder];
1553 JSObjectRef object([function JSObject]);
1554 JSGlobalContextRef context([frame globalContext]);
1555 JSObjectCallAsFunction(context, object, NULL, 0, NULL, NULL);
1557 if (settings != NULL)
1558 settings->setJavaScriptCanOpenWindowsAutomatically(no);
1563 - (void) didDismissModalViewController {
1565 [self callFunction:closer_];
1568 - (void) reloadButtonClicked {
1573 - (void) customButtonClicked {
1575 if (function_ != nil)
1576 [self callFunction:function_];
1579 [self reloadButtonClicked];
1582 - (void) setPageActive:(BOOL)active {
1584 [indicator_ removeFromSuperview];
1586 [[[[self navigationItem] rightBarButtonItem] view] addSubview:indicator_];
1589 - (void) resetViewAnimated:(BOOL)animated {
1592 - (void) setPushed:(bool)pushed {
1596 + (float) defaultWidth {