Camino only - Bug 402778: Allow expanding the scope of cookie exceptions. r/sr=mento

git-svn-id: svn://10.0.0.236/trunk@242380 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stuart.morgan%alumni.case.edu
2008-01-04 23:03:53 +00:00
parent f806ffa958
commit 07fff965e9
6 changed files with 168 additions and 122 deletions

View File

@@ -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 youve 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 youve 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.";

View File

@@ -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;
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
@@ -7,17 +7,17 @@
<key>IBEditorPositions</key>
<dict>
<key>622</key>
<string>208 247 252 169 0 0 1440 878 </string>
<string>208 247 254 149 0 0 1440 878 </string>
<key>635</key>
<string>725 436 126 76 0 0 1440 878 </string>
<string>479 406 157 111 0 0 1440 878 </string>
<key>709</key>
<string>60 401 126 76 0 0 1440 878 </string>
<string>60 401 126 68 0 0 1440 878 </string>
</dict>
<key>IBFramework Version</key>
<string>489.0</string>
<string>446.1</string>
<key>IBOldestOS</key>
<integer>3</integer>
<key>IBSystem Version</key>
<string>9B18</string>
<string>8S2167</string>
</dict>
</plist>

View File

@@ -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;

View File

@@ -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);