Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Create a PolicyDelegate for NavigationAction #2

Merged
merged 1 commit into from

2 participants

@sc68cal

Have links clicked by the user be opened in the user's default
browser.

@sc68cal sc68cal Create a PolicyDelegate for NavigationAction
Have links clicked by the user be opened in the user's default
browser.
366b2ab
@algesten algesten merged commit a74c991 into from
@algesten
Owner

Thanks much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 31, 2012
  1. @sc68cal

    Create a PolicyDelegate for NavigationAction

    sc68cal authored
    Have links clicked by the user be opened in the user's default
    browser.
This page is out of date. Refresh to see the latest.
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;
Something went wrong with that request. Please try again.