diff options
Diffstat (limited to 'CyteKit')
-rw-r--r-- | CyteKit/WebViewController.h | 1 | ||||
-rw-r--r-- | CyteKit/WebViewController.mm | 30 |
2 files changed, 29 insertions, 2 deletions
diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h index 96186c1..2483224 100644 --- a/CyteKit/WebViewController.h +++ b/CyteKit/WebViewController.h @@ -56,6 +56,7 @@ bool ready_; _transient NSNumber *sensitive_; + _H<NSURL> appstore_; _H<NSString> title_; _H<NSMutableSet> loading_; diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index 7d91177..f1448e1 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -461,10 +461,29 @@ float CYScrollViewDecelerationRateNormal; NSLog(@"decidePolicyForNavigationAction:%@ request:%@ %@ frame:%@", action, request, [request allHTTPHeaderFields], frame); #endif + NSURL *url(request == nil ? nil : [request URL]); + if ([[url scheme] isEqualToString:@"itms-appss"] || [[url absoluteString] hasPrefix:@"https://itunes.apple.com/app/"]) { + appstore_ = url; + + UIAlertView *alert = [[[UIAlertView alloc] + initWithTitle:UCLocalize("APP_STORE_REDIRECT") + message:nil + delegate:self + cancelButtonTitle:UCLocalize("CANCEL") + otherButtonTitles: + UCLocalize("ALLOW"), + nil + ] autorelease]; + + [alert setContext:@"itmsappss"]; + [alert show]; + + [listener ignore]; + return; + } + if ([frame parentFrame] == nil) { if (!error_) { - NSURL *url(request == nil ? nil : [request URL]); - if (request_ != nil && ![[request_ URL] isEqual:url] && ![self allowsNavigationAction]) { if (url != nil) [self pushRequest:request forAction:action asPop:NO]; @@ -735,6 +754,13 @@ float CYScrollViewDecelerationRateNormal; challenge_ = nil; [alert dismissWithClickedButtonIndex:-1 animated:YES]; + } else if ([context isEqualToString:@"itmsappss"]) { + if (button == [alert cancelButtonIndex]) { + } else if (button == [alert firstOtherButtonIndex]) { + [delegate_ openURL:appstore_]; + } + + [alert dismissWithClickedButtonIndex:-1 animated:YES]; } else if ([context isEqualToString:@"submit"]) { if (button == [alert cancelButtonIndex]) { } else if (button == [alert firstOtherButtonIndex]) { |