Browse files

changed whitelist logic a bit: there is now a default internal list o…

…f bundle IDs, and the prefs file is only for user-defined bundle IDs; app developers can now also opt out of ClickToFlash by including a 'ClickToFlashOptOut' key in their app's Info.plist file and setting it to YES
  • Loading branch information...
1 parent 1052b17 commit 7afbf03f62dd77eac1377d6bf4a38f4efd780771 Simone Manganelli committed Jun 30, 2009
Showing with 28 additions and 14 deletions.
  1. +3 −1 Plugin/Plugin.h
  2. +25 −13 Plugin/Plugin.m
View
4 Plugin/Plugin.h
@@ -29,6 +29,8 @@ THE SOFTWARE.
#import <WebKit/WebKit.h>
@interface CTFClickToFlashPlugin : NSView <WebPlugInViewFactory> {
+ NSArray *defaultWhitelist;
+
DOMElement *_container;
NSString *_host;
NSDictionary* _flashVars;
@@ -55,7 +57,7 @@ THE SOFTWARE.
- (id) initWithArguments:(NSDictionary *)arguments;
- (void)_migratePrefsToExternalFile;
-- (void) _addApplicationWhitelistToPrefsFile;
+- (void) _addApplicationWhitelistArrayToPrefsFile;
- (DOMElement *)container;
- (void)setContainer:(DOMElement *)newValue;
View
38 Plugin/Plugin.m
@@ -52,6 +52,9 @@ of this software and associated documentation files (the "Software"), to deal
static NSString *sApplicationWhitelist = @"applicationWhitelist";
static NSString *sDrawGearImageOnlyOnMouseOverHiddenPref = @"drawGearImageOnlyOnMouseOver";
+ // Info.plist key for app developers
+static NSString *sCTFOptOutKey = @"ClickToFlashOptOut";
+
BOOL usingMATrackingArea = NO;
@interface CTFClickToFlashPlugin (Internal)
@@ -106,6 +109,17 @@ - (id) initWithArguments:(NSDictionary *)arguments
{
self = [super init];
if (self) {
+ defaultWhitelist = [NSArray arrayWithObjects: @"com.apple.frontrow",
+ @"com.apple.dashboard",
+ @"com.apple.dashboard.client",
+ @"com.apple.ScreenSaver.Engine",
+ @"com.hulu.HuluDesktop",
+ @"com.riverfold.WiiTransfer",
+ @"com.bitcartel.pandorajam",
+ @"com.adobe.flexbuilder",
+ @"com.Zattoo.prefs",
+ nil];
+
[[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.github.rentzsch.clicktoflash"];
SparkleManager *sharedSparkleManager = [SparkleManager sharedManager];
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
@@ -128,7 +142,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
[self _migrateWhitelist];
[self _migratePrefsToExternalFile];
- [self _addApplicationWhitelistToPrefsFile];
+ [self _addApplicationWhitelistArrayToPrefsFile];
// Get URL
@@ -211,8 +225,11 @@ - (id) initWithArguments:(NSDictionary *)arguments
CTFUserDefaultsController *standardUserDefaults = [CTFUserDefaultsController standardUserDefaults];
BOOL pluginEnabled = [standardUserDefaults boolForKey:sPluginEnabled ];
NSString *hostAppBundleID = [[NSBundle mainBundle] bundleIdentifier];
- BOOL hostAppIsInWhitelist = [[standardUserDefaults arrayForKey:sApplicationWhitelist] containsObject:hostAppBundleID];
- if ( (! pluginEnabled) || (hostAppIsInWhitelist) ) {
+ BOOL hostAppIsInDefaultWhitelist = [defaultWhitelist containsObject:hostAppBundleID];
+ BOOL hostAppIsInUserWhitelist = [[standardUserDefaults arrayForKey:sApplicationWhitelist] containsObject:hostAppBundleID];
+ BOOL hostAppWhitelistedInInfoPlist = NO;
+ if ([[[NSBundle mainBundle] infoDictionary] objectForKey:sCTFOptOutKey]) hostAppWhitelistedInInfoPlist = YES;
+ if ( (! pluginEnabled) || (hostAppIsInDefaultWhitelist || hostAppIsInUserWhitelist || hostAppWhitelistedInInfoPlist) ) {
_isLoadingFromWhitelist = YES;
[self _convertTypesForContainer];
return self;
@@ -426,20 +443,15 @@ - (void) _migratePrefsToExternalFile
}
}
-- (void) _addApplicationWhitelistToPrefsFile
+- (void) _addApplicationWhitelistArrayToPrefsFile
{
CTFUserDefaultsController *standardUserDefaults = [CTFUserDefaultsController standardUserDefaults];
NSArray *applicationWhitelist = [standardUserDefaults arrayForKey:sApplicationWhitelist];
if (! applicationWhitelist) {
- // add the default list of apps to the whitelist
- NSArray *defaultWhitelist = [NSArray arrayWithObjects:@"com.hulu.HuluDesktop",
- @"com.echoone.iSwiff",
- @"com.riverfold.WiiTransfer",
- @"com.bitcartel.pandorajam",
- @"com.adobe.flexbuilder",
- @"com.Zattoo.prefs",
- nil];
- [standardUserDefaults setObject:defaultWhitelist forKey:sApplicationWhitelist];
+ // add an empty array to the plist file so people know exactly where to
+ // whitelist apps
+
+ [standardUserDefaults setObject:[NSArray array] forKey:sApplicationWhitelist];
}
}

0 comments on commit 7afbf03

Please sign in to comment.