+- (void) webView:(WebView *)sender willClickElement:(id)element {
+ if (![element respondsToSelector:@selector(href)])
+ return;
+ NSString *href = [element href];
+ if (href == nil)
+ return;
+ if ([href hasPrefix:@"apptapp://package/"])
+ [self getAppTapp:href];
+}
+
+- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
+ if ([[[request URL] scheme] isEqualToString:@"apptapp"]) {
+ [self getAppTapp:[[request URL] absoluteString]];
+ return nil;
+ }
+
+ if (!pushed_) {
+ pushed_ = true;
+ [book_ pushPage:self];
+ }
+
+ return [self _addHeadersToRequest:request];
+}
+
+- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
+ if (request != nil && [[[request URL] scheme] isEqualToString:@"apptapp"])
+ return nil;
+ else {
+ [self setBackButtonTitle:title_];
+
+ BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
+ [browser setDelegate:delegate_];
+
+ if (request != nil) {
+ [browser loadRequest:[self _addHeadersToRequest:request]];
+ [book_ pushPage:browser];
+ }
+
+ return [browser webView];
+ }
+}
+