-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa5d3ab
commit 61d347a
Showing
9 changed files
with
194 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
FlashlightApp/SpotlightSIMBL/SpotlightSIMBL/_SS_InlineWebViewContainer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// _SS_InlineWebView.h | ||
// SpotlightSIMBL | ||
// | ||
// Created by Nate Parrott on 11/9/14. | ||
// Copyright (c) 2014 Nate Parrott. All rights reserved. | ||
// | ||
|
||
#import <WebKit/WebKit.h> | ||
|
||
@interface _SS_InlineWebViewContainer : NSView | ||
|
||
@property (nonatomic) IBOutlet NSProgressIndicator *loader; | ||
@property (nonatomic) IBOutlet WebView *webView; | ||
|
||
@end |
59 changes: 59 additions & 0 deletions
59
FlashlightApp/SpotlightSIMBL/SpotlightSIMBL/_SS_InlineWebViewContainer.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// _SS_InlineWebView.m | ||
// SpotlightSIMBL | ||
// | ||
// Created by Nate Parrott on 11/9/14. | ||
// Copyright (c) 2014 Nate Parrott. All rights reserved. | ||
// | ||
|
||
#import "_SS_InlineWebViewContainer.h" | ||
|
||
@implementation _SS_InlineWebViewContainer | ||
|
||
- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame { | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
if (frame == sender.mainFrame) { | ||
[self.loader startAnimation:nil]; | ||
} | ||
}); | ||
} | ||
|
||
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
if (frame == sender.mainFrame) { | ||
[self.loader stopAnimation:nil]; | ||
} | ||
}); | ||
} | ||
|
||
- (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id<WebPolicyDecisionListener>)listener { | ||
NSLog(@"Decide window policy: %@", actionInformation); | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[[NSWorkspace sharedWorkspace] openURL:request.URL]; | ||
}); | ||
[listener ignore]; | ||
} | ||
|
||
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id<WebPolicyDecisionListener>)listener { | ||
NSLog(@"Decide policy: %@", actionInformation); | ||
if ([actionInformation[WebActionNavigationTypeKey] isEqualToString:WebNavigationTypeLinkClicked]) { | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[[NSWorkspace sharedWorkspace] openURL:request.URL]; | ||
}); | ||
[listener ignore]; | ||
} else { | ||
[listener use]; | ||
} | ||
} | ||
|
||
- (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener { | ||
[listener use]; | ||
} | ||
|
||
- (void)dealloc { | ||
self.webView.policyDelegate = nil; | ||
self.webView.frameLoadDelegate = nil; | ||
[self.webView stopLoading:nil]; | ||
} | ||
|
||
@end |