Camino only - Bug 370084: Allow for blacklisting in the popup exceptions list. r=stridey sr=mento

This commit is contained in:
stuart.morgan%alumni.case.edu 2007-02-23 00:51:11 +00:00
Родитель de9dc4bce3
Коммит cc74833985
6 изменённых файлов: 62 добавлений и 7 удалений

Двоичный файл не отображается.

Просмотреть файл

@ -44,6 +44,7 @@
mEnablePlugins = NSButton;
mEnablePopupBlocking = NSButton;
mImageResize = NSButton;
mPolicyColumn = NSTableColumn;
mPreventAnimation = NSButton;
mTabToFormElements = NSButton;
mTabToLinks = NSButton;

Просмотреть файл

@ -3,13 +3,17 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>5 7 356 240 0 0 1920 1178 </string>
<string>63 7 356 240 0 0 1920 1178 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOldestOS</key>
<integer>2</integer>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>8L127</string>
<string>8L2127</string>
<key>IBUserGuides</key>
<dict>
<key>312</key>

Двоичные данные
camino/PreferencePanes/WebFeatures/English.lproj/WebFeatures.nib/keyedobjects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -62,6 +62,7 @@ class nsISupportsArray;
IBOutlet id mWhitelistPanel;
IBOutlet ExtendedTableView* mWhitelistTable;
IBOutlet NSTableColumn* mPolicyColumn;
IBOutlet NSTextField* mAddField;
IBOutlet NSButton* mAddButton;

Просмотреть файл

@ -156,6 +156,13 @@ const int kAnnoyancePrefSome = 3;
[mEnableFlashBlock setState:(enableFlashBlock ? NSOnState : NSOffState)];
}
// Set up policy popups
NSPopUpButtonCell *popupButtonCell = [mPolicyColumn dataCell];
[popupButtonCell setEditable:YES];
[popupButtonCell addItemsWithTitles:[NSArray arrayWithObjects:[self getLocalizedString:@"Allow"],
[self getLocalizedString:@"Deny"],
nil]];
// Set inital values for tabfocus pref. Internally, it's a bitwise additive pref:
// bit 0 adds focus for text fields (not exposed in the UI, so not given a constant)
// bit 1 adds focus for other form elements (kFocusForms)
@ -407,21 +414,63 @@ const int kAnnoyancePrefSome = 3;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
NSString* retVal = nil;
id retVal = nil;
if ( mCachedPermissions ) {
nsCOMPtr<nsISupports> rowItem = dont_AddRef(mCachedPermissions->ElementAt(rowIndex));
nsCOMPtr<nsIPermission> perm ( do_QueryInterface(rowItem) );
if ( perm ) {
// only 1 column and it's the website url column
nsCAutoString host;
perm->GetHost(host);
retVal = [NSString stringWithCString:host.get()];
if (aTableColumn == mPolicyColumn) {
PRUint32 capability;
perm->GetCapability(&capability);
retVal = [NSNumber numberWithInt:((capability == nsIPermissionManager::ALLOW_ACTION) ? 0 : 1)];
}
else { // website column
nsCAutoString host;
perm->GetHost(host);
retVal = [NSString stringWithCString:host.get()];
}
}
}
return retVal;
}
// currently, this only applies to the site allow/deny, since that's the only editable column
-(void) tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
if (aTableColumn == mPolicyColumn) {
if (!(mCachedPermissions && mManager))
return;
nsCOMPtr<nsISupports> rowItem = dont_AddRef(mCachedPermissions->ElementAt(rowIndex));
nsCOMPtr<nsIPermission> perm (do_QueryInterface(rowItem));
if (!perm)
return;
// create a URI from the hostname of the changed site
nsCAutoString host;
perm->GetHost(host);
NSString* url = [NSString stringWithFormat:@"http://%s", host.get()];
const char* siteURL = [url UTF8String];
nsCOMPtr<nsIURI> newURI;
NS_NewURI(getter_AddRefs(newURI), siteURL);
if (!newURI)
return;
// nsIPermissions are immutable, and there's no API to change the action,
// so instead we have to replace the previous policy entirely.
mManager->Add(newURI, "popup", ([anObject intValue] == 0) ? nsIPermissionManager::ALLOW_ACTION
: nsIPermissionManager::DENY_ACTION);
// there really should be a better way to keep the cache up-to-date than rebuilding
// it, but the nsIPermissionManager interface doesn't have a way to get a pointer
// to a site's nsIPermission. It's this, use a custom class that duplicates the
// information (wasting a lot of memory), or find a way to tie in to
// PERM_CHANGE_NOTIFICATION to get the new nsIPermission that way.
mCachedPermissions->Clear();
[self populatePermissionCache:mCachedPermissions];
}
}
- (void)controlTextDidChange:(NSNotification*)notification
{
[mAddButton setEnabled:[[mAddField stringValue] length] > 0];