summaryrefslogtreecommitdiff
path: root/UICaboodle
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2009-06-12 17:49:26 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-09-30 07:13:15 +0000
commit0dceb29b5b709a6f9cfea52648941a6c2c5ef46b (patch)
tree79f8ae7c482aabc9053a056db7a3bbbc75c17b88 /UICaboodle
parent33872ba1b2aa4ea5b5239f3327049aab3bb363fe (diff)
Checkpoint for LunaCy fork.
Diffstat (limited to 'UICaboodle')
-rw-r--r--UICaboodle/BrowserView.h4
-rw-r--r--UICaboodle/BrowserView.m82
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]);