Skip to content

Commit 7afbf03

Browse files
Simone ManganelliSimone Manganelli
Simone Manganelli
authored and
Simone Manganelli
committed
changed whitelist logic a bit: there is now a default internal list of 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
1 parent 1052b17 commit 7afbf03

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

Plugin/Plugin.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ THE SOFTWARE.
2929
#import <WebKit/WebKit.h>
3030

3131
@interface CTFClickToFlashPlugin : NSView <WebPlugInViewFactory> {
32+
NSArray *defaultWhitelist;
33+
3234
DOMElement *_container;
3335
NSString *_host;
3436
NSDictionary* _flashVars;
@@ -55,7 +57,7 @@ THE SOFTWARE.
5557

5658
- (id) initWithArguments:(NSDictionary *)arguments;
5759
- (void)_migratePrefsToExternalFile;
58-
- (void) _addApplicationWhitelistToPrefsFile;
60+
- (void) _addApplicationWhitelistArrayToPrefsFile;
5961

6062
- (DOMElement *)container;
6163
- (void)setContainer:(DOMElement *)newValue;

Plugin/Plugin.m

+25-13
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ of this software and associated documentation files (the "Software"), to deal
5252
static NSString *sApplicationWhitelist = @"applicationWhitelist";
5353
static NSString *sDrawGearImageOnlyOnMouseOverHiddenPref = @"drawGearImageOnlyOnMouseOver";
5454

55+
// Info.plist key for app developers
56+
static NSString *sCTFOptOutKey = @"ClickToFlashOptOut";
57+
5558
BOOL usingMATrackingArea = NO;
5659

5760
@interface CTFClickToFlashPlugin (Internal)
@@ -106,6 +109,17 @@ - (id) initWithArguments:(NSDictionary *)arguments
106109
{
107110
self = [super init];
108111
if (self) {
112+
defaultWhitelist = [NSArray arrayWithObjects: @"com.apple.frontrow",
113+
@"com.apple.dashboard",
114+
@"com.apple.dashboard.client",
115+
@"com.apple.ScreenSaver.Engine",
116+
@"com.hulu.HuluDesktop",
117+
@"com.riverfold.WiiTransfer",
118+
@"com.bitcartel.pandorajam",
119+
@"com.adobe.flexbuilder",
120+
@"com.Zattoo.prefs",
121+
nil];
122+
109123
[[NSUserDefaults standardUserDefaults] addSuiteNamed:@"com.github.rentzsch.clicktoflash"];
110124
SparkleManager *sharedSparkleManager = [SparkleManager sharedManager];
111125
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
@@ -128,7 +142,7 @@ - (id) initWithArguments:(NSDictionary *)arguments
128142

129143
[self _migrateWhitelist];
130144
[self _migratePrefsToExternalFile];
131-
[self _addApplicationWhitelistToPrefsFile];
145+
[self _addApplicationWhitelistArrayToPrefsFile];
132146

133147

134148
// Get URL
@@ -211,8 +225,11 @@ - (id) initWithArguments:(NSDictionary *)arguments
211225
CTFUserDefaultsController *standardUserDefaults = [CTFUserDefaultsController standardUserDefaults];
212226
BOOL pluginEnabled = [standardUserDefaults boolForKey:sPluginEnabled ];
213227
NSString *hostAppBundleID = [[NSBundle mainBundle] bundleIdentifier];
214-
BOOL hostAppIsInWhitelist = [[standardUserDefaults arrayForKey:sApplicationWhitelist] containsObject:hostAppBundleID];
215-
if ( (! pluginEnabled) || (hostAppIsInWhitelist) ) {
228+
BOOL hostAppIsInDefaultWhitelist = [defaultWhitelist containsObject:hostAppBundleID];
229+
BOOL hostAppIsInUserWhitelist = [[standardUserDefaults arrayForKey:sApplicationWhitelist] containsObject:hostAppBundleID];
230+
BOOL hostAppWhitelistedInInfoPlist = NO;
231+
if ([[[NSBundle mainBundle] infoDictionary] objectForKey:sCTFOptOutKey]) hostAppWhitelistedInInfoPlist = YES;
232+
if ( (! pluginEnabled) || (hostAppIsInDefaultWhitelist || hostAppIsInUserWhitelist || hostAppWhitelistedInInfoPlist) ) {
216233
_isLoadingFromWhitelist = YES;
217234
[self _convertTypesForContainer];
218235
return self;
@@ -426,20 +443,15 @@ - (void) _migratePrefsToExternalFile
426443
}
427444
}
428445

429-
- (void) _addApplicationWhitelistToPrefsFile
446+
- (void) _addApplicationWhitelistArrayToPrefsFile
430447
{
431448
CTFUserDefaultsController *standardUserDefaults = [CTFUserDefaultsController standardUserDefaults];
432449
NSArray *applicationWhitelist = [standardUserDefaults arrayForKey:sApplicationWhitelist];
433450
if (! applicationWhitelist) {
434-
// add the default list of apps to the whitelist
435-
NSArray *defaultWhitelist = [NSArray arrayWithObjects:@"com.hulu.HuluDesktop",
436-
@"com.echoone.iSwiff",
437-
@"com.riverfold.WiiTransfer",
438-
@"com.bitcartel.pandorajam",
439-
@"com.adobe.flexbuilder",
440-
@"com.Zattoo.prefs",
441-
nil];
442-
[standardUserDefaults setObject:defaultWhitelist forKey:sApplicationWhitelist];
451+
// add an empty array to the plist file so people know exactly where to
452+
// whitelist apps
453+
454+
[standardUserDefaults setObject:[NSArray array] forKey:sApplicationWhitelist];
443455
}
444456
}
445457

0 commit comments

Comments
 (0)