Skip to content

Commit

Permalink
changed whitelist logic a bit: there is now a default internal list o…
Browse files Browse the repository at this point in the history
…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
Simone Manganelli authored and Simone Manganelli committed Jul 1, 2009
1 parent 1052b17 commit 7afbf03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ THE SOFTWARE.
#import <WebKit/WebKit.h>

@interface CTFClickToFlashPlugin : NSView <WebPlugInViewFactory> {
NSArray *defaultWhitelist;

DOMElement *_container;
NSString *_host;
NSDictionary* _flashVars;
Expand All @@ -55,7 +57,7 @@ THE SOFTWARE.

- (id) initWithArguments:(NSDictionary *)arguments;
- (void)_migratePrefsToExternalFile;
- (void) _addApplicationWhitelistToPrefsFile;
- (void) _addApplicationWhitelistArrayToPrefsFile;

- (DOMElement *)container;
- (void)setContainer:(DOMElement *)newValue;
Expand Down
38 changes: 25 additions & 13 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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];
Expand All @@ -128,7 +142,7 @@ - (id) initWithArguments:(NSDictionary *)arguments

[self _migrateWhitelist];
[self _migratePrefsToExternalFile];
[self _addApplicationWhitelistToPrefsFile];
[self _addApplicationWhitelistArrayToPrefsFile];


// Get URL
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}
}

Expand Down

0 comments on commit 7afbf03

Please sign in to comment.