mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-11 09:28:45 +00:00
Properly handle window.location= links as well.
Reviewed by me.
This commit is contained in:
1 parent
be75e4948d
commit
6384bed9cc
3 files changed
+47
No files matched your search
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// AppController+WebPolicyDelegate.m
|
||||
// NativeHost
|
||||
//
|
||||
// Created by Francisco Tolmasky on 5/11/10.
|
||||
// Copyright 2010 280 North, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSURL+Additions.h"
|
||||
#import "AppController.h"
|
||||
|
||||
|
||||
@implementation AppController (WebPolicyDelegate)
|
||||
|
||||
- (void)webView:(WebView *)aWebView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)aRequest newFrameName:(NSString *)aFrameName decisionListener:(id < WebPolicyDecisionListener >)aListener
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:[actionInformation objectForKey:WebActionOriginalURLKey]];
|
||||
[aListener ignore];
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)aWebView decidePolicyForNavigationAction:(NSDictionary *)aDictionary request:(NSURLRequest *)aRequest frame:(WebFrame *)aWebFrame decisionListener:(id <WebPolicyDecisionListener>)aDecisionListener
|
||||
{
|
||||
NSURL * requestURL = [aRequest URL];
|
||||
|
||||
if([aWebView mainFrame] != aWebFrame ||
|
||||
[[baseURL scheme] isEqualTo:[requestURL scheme]] &&
|
||||
![baseURL host] || [[baseURL host] isEqualTo:[requestURL host]] &&
|
||||
![baseURL port] || [[baseURL port] isEqualTo:[requestURL port]])
|
||||
return [aDecisionListener use];
|
||||
|
||||
[[NSWorkspace sharedWorkspace] openURL:[aDictionary objectForKey:WebActionOriginalURLKey]];
|
||||
[aDecisionListener ignore];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -27,8 +27,12 @@ extern NSString *SERVER_USER;
|
||||
NSFileHandle * stdinFileHandle;
|
||||
|
||||
NSMutableAttributedString * loggedOutput;
|
||||
|
||||
NSURL * baseURL;
|
||||
}
|
||||
|
||||
- (NSURL *)baseURL;
|
||||
|
||||
- (void)startServer;
|
||||
- (void)startCappuccinoApplication;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ int SERVER_PORT = 9191;
|
||||
NSString *SERVER_PASSWORD = nil;
|
||||
NSString *SERVER_USER = nil;
|
||||
|
||||
|
||||
@implementation AppController
|
||||
|
||||
- (id)init
|
||||
@@ -139,6 +140,11 @@ NSString *SERVER_USER = nil;
|
||||
[stdinFileHandle readInBackgroundAndNotify];
|
||||
}
|
||||
|
||||
- (NSURL *)baseURL
|
||||
{
|
||||
return baseURL;
|
||||
}
|
||||
|
||||
- (void)startCappuccinoApplication
|
||||
{
|
||||
NSString *initialURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NHInitialURL"];
|
||||
@@ -152,10 +158,12 @@ NSString *SERVER_USER = nil;
|
||||
initialResource = @"Application/index.html";
|
||||
|
||||
initialURL = [[NSString stringWithFormat:@"file://%@/%@", [[NSBundle mainBundle] resourcePath], initialResource] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
baseURL = [[NSURL alloc] initWithString:@"file:///"];
|
||||
}
|
||||
else if (prependServer)
|
||||
{
|
||||
initialURL = [NSString stringWithFormat:@"http://127.0.0.1:%d/%@", SERVER_PORT, initialURL];
|
||||
baseURL = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", SERVER_PORT]];
|
||||
}
|
||||
|
||||
NHLog(@"STARTUP", [initialURL description]);
|
||||
|
||||
Reference in new issue
Block a user