Permalink
Browse files

Merge pull request #2 from sc68cal/feature/open_links_in_default_browser

Create a PolicyDelegate for NavigationAction.
  • Loading branch information...
2 parents bc13d12 + 366b2ab commit a74c9919eefacc09e51c5f88be8b7003a4e19e2c @algesten committed Jan 1, 2013
Showing with 17 additions and 0 deletions.
  1. +2 −0 ViewDown/Document.h
  2. +15 −0 ViewDown/Document.m
View
2 ViewDown/Document.h
@@ -52,6 +52,8 @@
-(void)webView:(WebView *)webView willPerformDragDestinationAction:(WebDragDestinationAction)action forDraggingInfo:(id <NSDraggingInfo>)draggingInfo;
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
+
+-(void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener;
/////////////////////////////////////////////////
@end
View
15 ViewDown/Document.m
@@ -121,6 +121,8 @@ -(void)awakeFromNib
[self setCurrent:NULL];
}
+ [web setPolicyDelegate:self];
+
}
@@ -573,6 +575,19 @@ -(NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings er
}
+- (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation
+ request:(NSURLRequest *)request frame:(WebFrame *)frame
+ decisionListener:(id <WebPolicyDecisionListener>)listener
+{
+ NSURL *url = [request URL];
+ if(url.isFileURL)
+ [listener use];
+ else{
+ [listener ignore];
+ [[NSWorkspace sharedWorkspace] openURL:url];
+ }
+}
+
+ (BOOL)autosavesInPlace
{
return YES;

0 comments on commit a74c991

Please sign in to comment.