blob: 00d431c009c468204b8e37e496df7e3d4249b277 [file] [log] [blame]
//
// WebViewDelegate.m
// phonegap-mac
//
// Created by shazron on 10-04-30.
// Copyright 2010 Nitobi Software Inc. All rights reserved.
//
#import "WebViewDelegate.h"
#import "Sound.h"
@implementation WebViewDelegate
@synthesize sound;
- (void) webView:(WebView*)webView windowScriptObjectAvailable:(WebScriptObject*)windowScriptObject
{
if (self.sound == nil) { self.sound = [Sound new]; }
[windowScriptObject setValue:self.sound forKey:@"sound"];
}
/* This logs all errors from Javascript, nifty */
- (void) webView:(WebView*)webView addMessageToConsole:(NSDictionary*)message
{
if (![message isKindOfClass:[NSDictionary class]]) {
return;
}
NSLog(@"JavaScript error: %@:%@: %@",
[[message objectForKey:@"sourceURL"] lastPathComponent], // could be nil
[message objectForKey:@"lineNumber"],
[message objectForKey:@"message"]);
}
#pragma mark WebScripting protocol
/* checks whether a selector is acceptable to be called from JavaScript */
+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector
{
return YES;
}
// right now exclude all properties (eg keys)
+ (BOOL) isKeyExcludedFromWebScript:(const char*)name
{
return YES;
}
@end