Permalink
Browse files

occurred to me that since multiple apps could have had their prefs fi…

…le infected, we'd want to merge those prefs with the external prefs file; this commit takes care of that, and has been tested with Hulu Desktop
  • Loading branch information...
1 parent d15afcb commit e379669ac9d31b336d5fe0e2a844d75227e29e96 Simone Manganelli committed Jun 25, 2009
Showing with 15 additions and 1 deletion.
  1. +15 −1 Plugin/Plugin.m
View
@@ -389,7 +389,21 @@ - (void) _migratePrefsToExternalFile
NSString *currentParasiticDefault = [parasiticDefaultsNameArray objectAtIndex:i];
id prefValue = [[NSUserDefaults standardUserDefaults] objectForKey:currentParasiticDefault];
if (prefValue) {
- [externalFileDefaults setObject:prefValue forKey:[externalDefaultsNameArray objectAtIndex:i]];
+ NSString *externalPrefDefaultName = [externalDefaultsNameArray objectAtIndex:i];
+ id existingExternalPref = [[CTFUserDefaultsController standardUserDefaults] objectForKey:externalPrefDefaultName];
+ if (! existingExternalPref) {
+ // don't overwrite existing external preferences
+ [externalFileDefaults setObject:prefValue forKey:externalPrefDefaultName];
+ } else {
+ if ([currentParasiticDefault isEqualToString:@"ClickToFlash_siteInfo"]) {
+ // merge the arrays of whitelisted sites, in case they're not identical
+
+ NSMutableArray *combinedWhitelist = [NSMutableArray arrayWithArray:prefValue];
+ [combinedWhitelist addObjectsFromArray:existingExternalPref];
+ [externalFileDefaults setObject:combinedWhitelist forKey:externalPrefDefaultName];
+ }
+ }
+ // eliminate the parasitic default, regardless of whether we transferred them or not
[[NSUserDefaults standardUserDefaults] removeObjectForKey:currentParasiticDefault];
}
}

0 comments on commit e379669

Please sign in to comment.