Permalink
Browse files

[NEW] GetVariable('$ClickToFlashVersion') support for @diveintomark's…

… flashblockdetector.
  • Loading branch information...
1 parent e354dcd commit e90cf1194a29df2e9e4a82c5edf1fdd10f727e7b @rentzsch committed Mar 13, 2010
Showing with 42 additions and 29 deletions.
  1. +2 −2 ClickToFlash.xcodeproj/project.pbxproj
  2. +40 −27 Plugin/Plugin.m
@@ -738,7 +738,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_SIGN_COMPARE = YES;
- PRODUCT_VERSION = 1.6b7;
+ PRODUCT_VERSION = 1.6b8;
WARNING_CFLAGS = "-Wall";
};
name = Debug;
@@ -753,7 +753,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_SIGN_COMPARE = YES;
- PRODUCT_VERSION = 1.6b7;
+ PRODUCT_VERSION = 1.6b8;
WARNING_CFLAGS = "-Wall";
};
name = Release;
View
@@ -757,59 +757,72 @@ - (void) revertToOriginalOpacityAttributes
#pragma mark -
#pragma mark WebScripting Protocol
-- (id)objectForWebScript
-{
+- (id)objectForWebScript {
+ //NSLog(@"objectForWebScript => %@", self);
return self;
}
-+ (NSString *)webScriptNameForSelector:(SEL)aSelector
-{
++ (NSString *)webScriptNameForSelector:(SEL)aSelector {
// javascript may call GetVariable("$version") on us
+
+ NSString *result = nil;
+
if (aSelector == @selector(flashGetVariable:))
- return @"GetVariable";
- return nil;
+ result = @"GetVariable";
+
+ //NSLog(@"webScriptNameForSelector:%@ => %@", NSStringFromSelector(aSelector), result);
+ return result;
}
-+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
-{
++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector {
+ BOOL result = YES;
+
if (aSelector == @selector(flashGetVariable:))
- return NO;
- return YES;
+ result = NO;
+
+ //NSLog(@"isSelectorExcludedFromWebScript:%@ => %d", NSStringFromSelector(aSelector), result);
+ return result;
}
-- (id)flashGetVariable:(id)flashVar
-{
+- (id)flashGetVariable:(id)flashVar {
static NSString *sFlashVersion = nil;
+ static NSString *sClickToFlashVersion = nil;
+
+ //NSLog(@"flashVar: %p %@", flashVar, flashVar);
- if (flashVar && [flashVar isKindOfClass:[NSString class]])
- {
- if ([(NSString *)flashVar isEqualToString:@"$version"])
- {
- if (sFlashVersion == nil)
- {
+ if (flashVar && [flashVar isKindOfClass:[NSString class]]) {
+ if ([flashVar isEqualToString:@"$version"]) {
+ if (sFlashVersion == nil) {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
- if (bundle)
- {
+ if (bundle) {
id version = [bundle objectForInfoDictionaryKey:@"CTFFlashVariableVersion"];
- if (version && [version isKindOfClass:[NSString class]])
- {
+ if (version && [version isKindOfClass:[NSString class]]) {
sFlashVersion = [(NSString *)version copy];
}
}
}
return sFlashVersion;
- }
- else
- {
- return [self flashvarWithName:(NSString *)flashVar];
+ } else if ([flashVar isEqualToString:@"$ClickToFlashVersion"]) {
+ if (sClickToFlashVersion == nil) {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ if (bundle) {
+ id version = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
+ if (version && [version isKindOfClass:[NSString class]]) {
+ sClickToFlashVersion = [(NSString *)version copy];
+ }
+ }
+ }
+
+ return sClickToFlashVersion;
+ } else {
+ return [self flashvarWithName:flashVar];
}
}
return nil;
}
-
#pragma mark -
#pragma mark Accessibility

0 comments on commit e90cf11

Please sign in to comment.