diff --git a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Localizable.strings.in b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Localizable.strings.in index 1b075460581..7074e395eb2 100644 --- a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Localizable.strings.in +++ b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Localizable.strings.in @@ -15,20 +15,24 @@ "RemoveAllCookiesWarningTitle" = "Are you sure you want to remove all cookies?"; "RemoveAllCookiesWarning" = "Removing cookies may cause websites to forget your identity, any online shopping carts, and other personalized site settings. You cannot undo this action."; +/* cookie permissions context menu */ +"ExpandException" = "Expand Exception"; +"ExpandExceptionForSite" = "Expand Exception to All of “%@”"; + /* cookie permissions removal warning */ "Remove All Exceptions" = "Remove All Exceptions"; "RemoveAllCookiePermissionsWarningTitle" = "Are you sure you want to remove all cookie site exceptions?"; "RemoveAllCookiePermissionsWarning" = "This will clear the list of sites for which you’ve made a decision about allowing or denying cookies. If you have “Ask before accepting each cookie” selected, you will be prompted again to accept cookies for any website that attempts to set them. You cannot undo this action."; /* cookies context menu */ -"AllowCookieFromSite" = "Allow all cookies from sites matching “%@”"; -"AllowCookiesFromSites" = "Allow all cookies from these sites"; +"AllowCookieFromSite" = "Allow All Cookies from Sites Matching “%@”"; +"AllowCookiesFromSites" = "Allow All Cookies from These Sites"; -"BlockCookieFromSite" = "Block cookies from sites matching “%@”"; -"BlockCookiesFromSites" = "Block cookies from these sites"; +"BlockCookieFromSite" = "Block Cookies from Sites Matching “%@”"; +"BlockCookiesFromSites" = "Block Cookies from These Sites"; -"RemoveAndBlockCookieFromSite" = "Remove and block cookies from sites matching “%@”"; -"RemoveAndBlockCookiesFromSites" = "Remove and block cookies from these sites"; +"RemoveAndBlockCookieFromSite" = "Remove and Block Cookies from Sites Matching “%@”"; +"RemoveAndBlockCookiesFromSites" = "Remove and Block Cookies from These Sites"; "RemoveAllKeychainExclusionsWarningTitle" = "Are you sure you want to remove all Keychain exclusions?"; "RemoveAllKeychainExclusionsWarning" = "This will clear the list of sites for which you’ve opted to never save passwords. If you log in to these sites in the future, Camino will offer to save your password. You cannot undo this action."; diff --git a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib index 9a56e9c3fa9..1e181feb472 100644 --- a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib +++ b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib @@ -1,98 +1,73 @@ { - IBClasses = ( - { - CLASS = CookieDateFormatter; - LANGUAGE = ObjC; - SUPERCLASS = NSDateFormatter; - }, - { - CLASS = ExtendedTableView; - LANGUAGE = ObjC; - SUPERCLASS = NSTableView; - }, - { - CLASS = FirstResponder; - LANGUAGE = ObjC; - SUPERCLASS = NSObject; - }, - { - CLASS = NSPreferencePane; - LANGUAGE = ObjC; - OUTLETS = { - "_firstKeyView" = id; - "_initialKeyView" = id; - "_lastKeyView" = id; - "_window" = id; - }; - SUPERCLASS = NSObject; - }, - { - CLASS = NSTableView; - LANGUAGE = ObjC; - SUPERCLASS = NSControl; - }, - { - ACTIONS = { - allowCookiesFromSites = id; - blockCookiesFromSites = id; - clickAskAboutCookies = id; - clickCookieBehavior = id; - clickStorePasswords = id; - cookieFilterChanged = id; - editCookies = id; - editCookiesDone = id; - editKeychainExclusions = id; - editKeychainExclusionsDone = id; - editPermissions = id; - editPermissionsDone = id; - keychainExclusionsFilterChanged = id; - launchKeychainAccess = id; - permissionFilterChanged = id; - removeAllCookiePermissions = id; - removeAllCookies = id; - removeAllKeychainExclusions = id; - removeCookiePermissions = id; - removeCookies = id; - removeCookiesAndBlockSites = id; - removeKeychainExclusions = id; - }; - CLASS = OrgMozillaCaminoPreferencePrivacy; - LANGUAGE = ObjC; - OUTLETS = { - mAskAboutCookies = NSButton; - mCookieBehavior = NSMatrix; - mCookiesFilterField = NSSearchField; - mCookiesPanel = id; - mCookiesTable = ExtendedTableView; - mKeychainExclusionsFilterField = NSSearchField; - mKeychainExclusionsPanel = id; - mKeychainExclusionsTable = ExtendedTableView; - mPermissionColumn = NSTableColumn; - mPermissionFilterField = NSSearchField; - mPermissionsPanel = id; - mPermissionsTable = ExtendedTableView; - mStorePasswords = NSButton; - }; - SUPERCLASS = PreferencePaneBase; - }, - { - CLASS = PopupMenuButton; - LANGUAGE = ObjC; - SUPERCLASS = NSButton; - }, - { - CLASS = PreferencePaneBase; - LANGUAGE = ObjC; - SUPERCLASS = NSPreferencePane; - }, - { - ACTIONS = { - selectText = id; - }; - CLASS = SearchTextField; - LANGUAGE = ObjC; - SUPERCLASS = NSTextField; + IBClasses = ( + {CLASS = CookieDateFormatter; LANGUAGE = ObjC; SUPERCLASS = NSDateFormatter; }, + {CLASS = ExtendedTableView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; }, + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + CLASS = NSPreferencePane; + LANGUAGE = ObjC; + OUTLETS = { + "_firstKeyView" = id; + "_initialKeyView" = id; + "_lastKeyView" = id; + "_window" = id; + }; + SUPERCLASS = NSObject; + }, + {CLASS = NSTableView; LANGUAGE = ObjC; SUPERCLASS = NSControl; }, + { + ACTIONS = { + allowCookiesFromSites = id; + blockCookiesFromSites = id; + clickAskAboutCookies = id; + clickCookieBehavior = id; + clickStorePasswords = id; + cookieFilterChanged = id; + editCookies = id; + editCookiesDone = id; + editKeychainExclusions = id; + editKeychainExclusionsDone = id; + editPermissions = id; + editPermissionsDone = id; + expandCookiePermission = id; + keychainExclusionsFilterChanged = id; + launchKeychainAccess = id; + permissionFilterChanged = id; + removeAllCookiePermissions = id; + removeAllCookies = id; + removeAllKeychainExclusions = id; + removeCookiePermissions = id; + removeCookies = id; + removeCookiesAndBlockSites = id; + removeKeychainExclusions = id; + }; + CLASS = OrgMozillaCaminoPreferencePrivacy; + LANGUAGE = ObjC; + OUTLETS = { + mAskAboutCookies = NSButton; + mCookieBehavior = NSMatrix; + mCookiesFilterField = NSSearchField; + mCookiesPanel = id; + mCookiesTable = ExtendedTableView; + mKeychainExclusionsFilterField = NSSearchField; + mKeychainExclusionsPanel = id; + mKeychainExclusionsTable = ExtendedTableView; + mPermissionColumn = NSTableColumn; + mPermissionFilterField = NSSearchField; + mPermissionsPanel = id; + mPermissionsTable = ExtendedTableView; + mStorePasswords = NSButton; + }; + SUPERCLASS = PreferencePaneBase; + }, + {CLASS = PopupMenuButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; }, + {CLASS = PreferencePaneBase; LANGUAGE = ObjC; SUPERCLASS = NSPreferencePane; }, + { + ACTIONS = {selectText = id; }; + CLASS = SearchTextField; + LANGUAGE = ObjC; + SUPERCLASS = NSTextField; } - ); - IBVersion = 1; + ); + IBVersion = 1; } \ No newline at end of file diff --git a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib index 55c7c9bef50..9b06bda33c1 100644 --- a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib +++ b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib @@ -1,5 +1,5 @@ - + IBDocumentLocation @@ -7,17 +7,17 @@ IBEditorPositions 622 - 208 247 252 169 0 0 1440 878 + 208 247 254 149 0 0 1440 878 635 - 725 436 126 76 0 0 1440 878 + 479 406 157 111 0 0 1440 878 709 - 60 401 126 76 0 0 1440 878 + 60 401 126 68 0 0 1440 878 IBFramework Version - 489.0 + 446.1 IBOldestOS 3 IBSystem Version - 9B18 + 8S2167 diff --git a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/keyedobjects.nib b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/keyedobjects.nib index a7305e58a1d..ec2724b401e 100644 Binary files a/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/keyedobjects.nib and b/mozilla/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/keyedobjects.nib differ diff --git a/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.h b/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.h index 36344c5760b..f2f2fefc303 100644 --- a/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.h +++ b/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.h @@ -113,12 +113,13 @@ typedef enum ECookiePolicyPopupIndex -(IBAction) removeCookiesAndBlockSites:(id)aSender; // permission editing functions --(void) populatePermissionCache; --(IBAction) editPermissions:(id)aSender; --(IBAction) editPermissionsDone:(id)aSender; --(IBAction) removeCookiePermissions:(id)aSender; --(IBAction) removeAllCookiePermissions:(id)aSender; --(int) rowForPermissionWithHost:(NSString *)aHost; +- (void)populatePermissionCache; +- (IBAction)editPermissions:(id)aSender; +- (IBAction)editPermissionsDone:(id)aSender; +- (IBAction)expandCookiePermission:(id)aSender; +- (IBAction)removeCookiePermissions:(id)aSender; +- (IBAction)removeAllCookiePermissions:(id)aSender; +- (int)rowForPermissionWithHost:(NSString *)aHost; // keychain exclusion list editing functions - (void)loadKeychainExclusions; diff --git a/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.mm b/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.mm index b04cc125f12..1794c115a7c 100644 --- a/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.mm +++ b/mozilla/camino/PreferencePanes/Privacy/PrivacyPane.mm @@ -70,6 +70,8 @@ const int kSortReverse = 1; @interface OrgMozillaCaminoPreferencePrivacy(Private) ++ (NSString*)superdomainForHost:(NSString*)host; + // helper method for blocking/allowing multiple sites at once - (void)addPermissionForSelection:(int)inPermission; @@ -111,9 +113,9 @@ const int kSortReverse = 1; return result; } if (selfIndex < otherIndex) - return NSOrderedDescending; - else if (selfIndex > otherIndex) return NSOrderedAscending; + else if (selfIndex > otherIndex) + return NSOrderedDescending; else return NSOrderedSame; } @@ -520,6 +522,57 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, [mPermissionsPanel setMinSize:min]; } +// Note that this operates only a single row (enforced by menu validation), +// unlike many of the other context menu actions. +- (IBAction)expandCookiePermission:(id)aSender +{ + CHPermission* selectedPermission = [mCachedPermissions objectAtIndex:[mPermissionsTable selectedRow]]; + NSString* host = [selectedPermission host]; + NSString* superdomain = [[self class] superdomainForHost:host]; + int policy = [selectedPermission policy]; + + CHPermissionManager* permManager = [CHPermissionManager permissionManager]; + // Walk the permissions, cleaning up any that are superceded by the general + // policy (but leaving any that have a different policy). + NSString* domainSuffix = [NSString stringWithFormat:@".%@", superdomain]; + NSEnumerator* permEnumerator = [mCachedPermissions objectEnumerator]; + CHPermission* perm; + while ((perm = [permEnumerator nextObject])) { + if ([perm policy] == policy && [[perm host] hasSuffix:domainSuffix]) + [permManager removePermissionForHost:[perm host] + type:CHPermissionTypeCookie]; + } + // Add the new general policy. + [permManager setPolicy:policy forHost:superdomain type:CHPermissionTypeCookie]; + + [self populatePermissionCache]; + [mPermissionsTable reloadData]; + [self sortPermissionsByKey:[[mPermissionsTable highlightedTableColumn] identifier] + inAscendingOrder:mSortedAscending]; + + // Select the new permission. + if ([mPermissionsTable numberOfRows] > 0) { + int rowToSelect = [self rowForPermissionWithHost:superdomain]; + if ((rowToSelect >= 0) && (rowToSelect < [mPermissionsTable numberOfRows])) { + [mPermissionsTable selectRow:rowToSelect byExtendingSelection:NO]; + [mPermissionsTable scrollRowToVisible:rowToSelect]; + } + } +} + +// Returns the host that is one level more broad than the given host (e.g., +// foo.bar.com -> bar.com), or nil if the given host has only one component. ++ (NSString*)superdomainForHost:(NSString*)host +{ + NSRange dotRange = [host rangeOfString:@"."]; + if (dotRange.location == NSNotFound || dotRange.location == ([host length] - 1)) + return nil; + if (dotRange.location == 0) // .bar.com == bar.com + return [[self class] superdomainForHost:[host substringFromIndex:1]]; + else + return [host substringFromIndex:(dotRange.location + 1)]; +} + -(IBAction) removeCookiePermissions:(id)aSender { CHPermissionManager* permManager = [CHPermissionManager permissionManager]; @@ -584,7 +637,7 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, { int numRows = [mCachedPermissions count]; for (int row = 0; row < numRows; ++row) { - if ([[mCachedPermissions objectAtIndex:row] isEqualToString:aHost]) + if ([[[mCachedPermissions objectAtIndex:row] host] isEqualToString:aHost]) return row; } return -1; @@ -1099,8 +1152,7 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, return ([mCookiesTable numberOfRows] > 0 && [[mCookiesFilterField stringValue] length] == 0); - if (action == @selector(allowCookiesFromSites:)) - { + if (action == @selector(allowCookiesFromSites:)) { NSString* siteName = nil; int numCookieSites = [self numUniqueCookieSitesSelected:&siteName]; NSString* menuTitle = (numCookieSites == 1) ? @@ -1110,8 +1162,7 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, return (numCookieSites > 0); } - if (action == @selector(blockCookiesFromSites:)) - { + if (action == @selector(blockCookiesFromSites:)) { NSString* siteName = nil; int numCookieSites = [self numUniqueCookieSitesSelected:&siteName]; NSString* menuTitle = (numCookieSites == 1) ? @@ -1121,8 +1172,7 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, return (numCookieSites > 0); } - if (action == @selector(removeCookiesAndBlockSites:)) - { + if (action == @selector(removeCookiesAndBlockSites:)) { NSString* siteName = nil; int numCookieSites = [self numUniqueCookieSitesSelected:&siteName]; @@ -1133,6 +1183,22 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, return (numCookieSites > 0); } + if (action == @selector(expandCookiePermission:)) { + // If there is excatly one row selected and it is expandable (i.e., not + // just a TLD already), enable the menu and give it a descriptive title, + // otherwise disable it and give it a generic title. + int selectedRowCount = [[mPermissionsTable selectedRowIndexes] count]; + NSString* superdomain = nil; + if (selectedRowCount == 1) { + NSString* selectedHost = [[mCachedPermissions objectAtIndex:[mPermissionsTable selectedRow]] host]; + superdomain = [[self class] superdomainForHost:selectedHost]; + } + NSString* menuTitle = superdomain ? [NSString stringWithFormat:[self localizedStringForKey:@"ExpandExceptionForSite"], superdomain] + : [self localizedStringForKey:@"ExpandException"]; + [inMenuItem setTitle:menuTitle]; + return (superdomain != nil); + } + // permissions context menu if (action == @selector(removeCookiePermissions:)) return ([self numPermissionsSelectedInPermissionsPanel] > 0);