diff options
Diffstat (limited to 'UICaboodle')
-rw-r--r-- | UICaboodle/BrowserView.h | 4 | ||||
-rw-r--r-- | UICaboodle/BrowserView.m | 82 |
2 files changed, 84 insertions, 2 deletions
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h index eb11d6c..f02e679 100644 --- a/UICaboodle/BrowserView.h +++ b/UICaboodle/BrowserView.h @@ -50,6 +50,7 @@ NSURLRequest *request_; NSNumber *confirm_; + NSNumber *sensitive_; NSString *title_; NSMutableSet *loading_; bool reloading_; @@ -104,4 +105,7 @@ - (id) _rightButtonTitle; +- (bool) promptForSensitive:(NSString *)name; +- (bool) allowSensitiveRequests; + @end diff --git a/UICaboodle/BrowserView.m b/UICaboodle/BrowserView.m index cb3709c..f7cf0f5 100644 --- a/UICaboodle/BrowserView.m +++ b/UICaboodle/BrowserView.m @@ -156,7 +156,7 @@ } + (NSArray *) _attributeKeys { - return [NSArray arrayWithObjects:@"device", nil]; + return [NSArray arrayWithObjects:@"device", @"firewire", @"imei", @"mac", @"serial", nil]; } - (NSArray *) attributeKeys { @@ -171,6 +171,26 @@ return [[UIDevice currentDevice] uniqueIdentifier]; } +- (NSString *) mac { + if (![indirect_ promptForSensitive:@"Mac Address"]) + return nil; +} + +- (NSString *) serial { + if (![indirect_ promptForSensitive:@"Serial #"]) + return nil; +} + +- (NSString *) firewire { + if (![indirect_ promptForSensitive:@"Firewire GUID"]) + return nil; +} + +- (NSString *) imei { + if (![indirect_ promptForSensitive:@"IMEI"]) + return nil; +} + + (NSString *) webScriptNameForSelector:(SEL)selector { if (selector == @selector(close)) return @"close"; @@ -399,6 +419,8 @@ [indicator_ release]; if (confirm_ != nil) [confirm_ release]; + if (sensitive_ != nil) + [sensitive_ release]; if (title_ != nil) [title_ release]; [super dealloc]; @@ -572,6 +594,50 @@ return true; } +- (bool) allowSensitiveRequests { + [self _allowJavaScriptPanel]; +} + +- (void) _promptForSensitive:(NSMutableArray *)array { + NSString *name([array objectAtIndex:0]); + + UIActionSheet *sheet = [[[UIActionSheet alloc] + initWithTitle:nil + buttons:[NSArray arrayWithObjects:CYLocalize("YES"), CYLocalize("NO"), nil] + defaultButtonIndex:0 + delegate:indirect_ + context:@"sensitive" + ] autorelease]; + + NSString *host(@"XXX"); + + [sheet setNumberOfRows:1]; + [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]]; + [sheet popupAlertAnimated:YES]; + + NSRunLoop *loop([NSRunLoop currentRunLoop]); + NSDate *future([NSDate distantFuture]); + + while (sensitive_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]); + + NSNumber *sensitive([sensitive_ autorelease]); + sensitive_ = nil; + + [self autorelease]; + [array replaceObjectAtIndex:0 withObject:sensitive]; +} + +- (bool) promptForSensitive:(NSString *)name { + if (![self allowSensitiveRequests]) + return false; + + NSMutableArray *array([NSMutableArray arrayWithCapacity:1]); + [array addObject:name]; + + [self performSelectorOnMainThread:@selector(_promptForSensitive:) withObject:array waitUntilDone:YES]; + return [[array lastObject] boolValue]; +} + - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { if (![self _allowJavaScriptPanel]) return; @@ -596,7 +662,7 @@ UIActionSheet *sheet = [[[UIActionSheet alloc] initWithTitle:nil - buttons:[NSArray arrayWithObjects:CYLocalize("OK"), CYLocalize("Cancel"), nil] + buttons:[NSArray arrayWithObjects:CYLocalize("OK"), CYLocalize("CANCEL"), nil] defaultButtonIndex:0 delegate:indirect_ context:@"confirm" @@ -866,6 +932,18 @@ } [sheet dismiss]; + } else if ([context isEqualToString:@"sensitive"]) { + switch (button) { + case 1: + sensitive_ = [NSNumber numberWithBool:YES]; + break; + + case 2: + sensitive_ = [NSNumber numberWithBool:NO]; + break; + } + + [sheet dismiss]; } else if ([context isEqualToString:@"challenge"]) { id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]); |