Skip to content

Commit

Permalink
Added an application whitelist; four apps are on it by default: Hulu …
Browse files Browse the repository at this point in the history
…Desktop, iSwiff, Wii Transfer, and PandoraJam
  • Loading branch information
Simone Manganelli authored and Simone Manganelli committed Jun 25, 2009
1 parent 488ee14 commit f2a1e75
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions Plugin/Plugin.h
Expand Up @@ -53,6 +53,7 @@ THE SOFTWARE.

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

- (DOMElement *)container;
- (void)setContainer:(DOMElement *)newValue;
Expand Down
24 changes: 22 additions & 2 deletions Plugin/Plugin.m
Expand Up @@ -46,6 +46,7 @@ of this software and associated documentation files (the "Software"), to deal
static NSString *sUseYouTubeH264DefaultsKey = @"useYouTubeH264";
static NSString *sAutoLoadInvisibleFlashViewsKey = @"autoLoadInvisibleViews";
static NSString *sPluginEnabled = @"pluginEnabled";
static NSString *sApplicationWhitelist = @"applicationWhitelist";

BOOL usingMATrackingArea = NO;

Expand Down Expand Up @@ -125,6 +126,7 @@ - (id) initWithArguments:(NSDictionary *)arguments

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


// Get URL
Expand Down Expand Up @@ -189,7 +191,11 @@ - (id) initWithArguments:(NSDictionary *)arguments

// check whether plugin is disabled, load all content as normal if so

if ( ![ [ CTFUserDefaultsController standardUserDefaults ] boolForKey: sPluginEnabled ] ) {
CTFUserDefaultsController *standardUserDefaults = [CTFUserDefaultsController standardUserDefaults];
BOOL pluginEnabled = [standardUserDefaults boolForKey:sPluginEnabled ];
NSString *hostAppBundleID = [[NSBundle mainBundle] bundleIdentifier];
BOOL hostAppIsInWhitelist = [[standardUserDefaults arrayForKey:sApplicationWhitelist] containsObject:hostAppBundleID];
if ( (! pluginEnabled) || (hostAppIsInWhitelist) ) {
_isLoadingFromWhitelist = YES;
[self _convertTypesForContainer];
return self;
Expand Down Expand Up @@ -358,7 +364,7 @@ - (void) dealloc
[super dealloc];
}

- (void)_migratePrefsToExternalFile
- (void) _migratePrefsToExternalFile
{
NSArray *parasiticDefaultsNameArray = [NSArray arrayWithObjects:@"ClickToFlash_pluginEnabled",
@"ClickToFlash_useYouTubeH264",
Expand Down Expand Up @@ -389,6 +395,20 @@ - (void)_migratePrefsToExternalFile
}
}

- (void) _addApplicationWhitelistToPrefsFile
{
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.riverfold.WiiTransfer",
@"com.bitcartel.pandorajam",
nil];
[standardUserDefaults setObject:defaultWhitelist forKey:sApplicationWhitelist];
}
}

- (void) drawRect:(NSRect)rect
{
if(!_isLoadingFromWhitelist)
Expand Down

0 comments on commit f2a1e75

Please sign in to comment.