Skip to content

Commit

Permalink
[NEW] Implement WebScripting Protocol for YouTube and Flash Block Det…
Browse files Browse the repository at this point in the history
…ector. Bump our Flash version from 10.0 r22 to 10.0 r45.
  • Loading branch information
rentzsch committed Mar 23, 2010
1 parent 918c07c commit aa05310
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Plugin/Info-Plugin.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<string>http://rentzsch.github.com/clicktoflash/release_notes/appcast.xml</string>
<!--<string>http://rentzsch.github.com/clicktoflash/release_notes/appcast_distantfuture.xml</string>-->
<key>WebPluginDescription</key>
<string>Shockwave Flash 10.0 r22</string>
<string>Shockwave Flash 10.0 r45</string>
<key>WebPluginMIMETypes</key>
<dict>
<key>application/x-shockwave-flash</key>
Expand All @@ -45,5 +45,7 @@
</dict>
<key>WebPluginName</key>
<string>Shockwave Flash</string>
<key>CTFFlashVariableVersion</key>
<string>MAC 10,0,45,2</string>
</dict>
</plist>
69 changes: 69 additions & 0 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,75 @@ - (void) _removeTrackingAreaForCTF
}


#pragma mark -
#pragma mark WebScripting Protocol

- (id)objectForWebScript {
//NSLog(@"objectForWebScript => %@", self);
return self;
}

+ (NSString *)webScriptNameForSelector:(SEL)aSelector {
// javascript may call GetVariable("$version") on us

NSString *result = nil;

if (aSelector == @selector(flashGetVariable:))
result = @"GetVariable";

//NSLog(@"webScriptNameForSelector:%@ => %@", NSStringFromSelector(aSelector), result);
return result;
}

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector {
BOOL result = YES;

if (aSelector == @selector(flashGetVariable:))
result = NO;

//NSLog(@"isSelectorExcludedFromWebScript:%@ => %d", NSStringFromSelector(aSelector), result);
return result;
}

- (id)flashGetVariable:(id)flashVar {
static NSString *sFlashVersion = nil;
static NSString *sClickToFlashVersion = nil;

//NSLog(@"flashVar: %p %@", flashVar, flashVar);

if (flashVar && [flashVar isKindOfClass:[NSString class]]) {
if ([flashVar isEqualToString:@"$version"]) {
if (sFlashVersion == nil) {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
if (bundle) {
id version = [bundle objectForInfoDictionaryKey:@"CTFFlashVariableVersion"];
if (version && [version isKindOfClass:[NSString class]]) {
sFlashVersion = [(NSString *)version copy];
}
}
}

return sFlashVersion;
} 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 YouTube H.264 support

Expand Down

0 comments on commit aa05310

Please sign in to comment.