Back out bug 475201 due to the Xcode 2.x ld suckage
git-svn-id: svn://10.0.0.236/trunk@257057 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d5c9f57eb1
commit
30672decae
@ -995,8 +995,6 @@
|
||||
B3128A120E5D14C8009F0595 /* pageBigger.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B3757F860E5D0FE70006EDF1 /* pageBigger.tiff */; };
|
||||
B3128A130E5D14CD009F0595 /* pageSmaller.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B3757F870E5D0FE70006EDF1 /* pageSmaller.tiff */; };
|
||||
B3128A140E5D14CE009F0595 /* pageSmaller.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B3757F870E5D0FE70006EDF1 /* pageSmaller.tiff */; };
|
||||
B3886D880F79D53700D8E015 /* FlashblockWhitelistManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3886D870F79D53700D8E015 /* FlashblockWhitelistManager.mm */; };
|
||||
B3886D890F79D53700D8E015 /* FlashblockWhitelistManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3886D870F79D53700D8E015 /* FlashblockWhitelistManager.mm */; };
|
||||
C713F0900E9AF7DB002313B3 /* CHSlidingViewAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = C713F08E0E9AF7DB002313B3 /* CHSlidingViewAnimation.m */; };
|
||||
C713F0910E9AF7DB002313B3 /* CHSlidingViewAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = C713F08E0E9AF7DB002313B3 /* CHSlidingViewAnimation.m */; };
|
||||
C79573880D35314D0028A773 /* XMLSearchPluginParser.mm in Sources */ = {isa = PBXBuildFile; fileRef = C79573840D35314D0028A773 /* XMLSearchPluginParser.mm */; };
|
||||
@ -2873,8 +2871,6 @@
|
||||
A7FD31C90466004E00A80196 /* libsuitetypeaheadfind.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsuitetypeaheadfind.a; path = ../extensions/typeaheadfind/src/libsuitetypeaheadfind.a; sourceTree = SOURCE_ROOT; };
|
||||
B3757F860E5D0FE70006EDF1 /* pageBigger.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = pageBigger.tiff; path = resources/images/toolbar/pageBigger.tiff; sourceTree = "<group>"; };
|
||||
B3757F870E5D0FE70006EDF1 /* pageSmaller.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = pageSmaller.tiff; path = resources/images/toolbar/pageSmaller.tiff; sourceTree = "<group>"; };
|
||||
B3886D840F79D52700D8E015 /* FlashblockWhitelistManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FlashblockWhitelistManager.h; path = src/browser/FlashblockWhitelistManager.h; sourceTree = "<group>"; };
|
||||
B3886D870F79D53700D8E015 /* FlashblockWhitelistManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = FlashblockWhitelistManager.mm; path = src/browser/FlashblockWhitelistManager.mm; sourceTree = "<group>"; };
|
||||
C713F08E0E9AF7DB002313B3 /* CHSlidingViewAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CHSlidingViewAnimation.m; path = src/extensions/CHSlidingViewAnimation.m; sourceTree = "<group>"; };
|
||||
C713F08F0E9AF7DB002313B3 /* CHSlidingViewAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CHSlidingViewAnimation.h; path = src/extensions/CHSlidingViewAnimation.h; sourceTree = "<group>"; };
|
||||
C79573840D35314D0028A773 /* XMLSearchPluginParser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = XMLSearchPluginParser.mm; path = src/websearch/XMLSearchPluginParser.mm; sourceTree = "<group>"; };
|
||||
@ -4029,8 +4025,6 @@
|
||||
F6BA6D4E01B2F8A601A962F7 /* BrowserWrapper.mm */,
|
||||
F59E9F3D0237E28401A967DF /* ContentClickListener.h */,
|
||||
F59E9F3F0237E43401A967DF /* ContentClickListener.mm */,
|
||||
B3886D870F79D53700D8E015 /* FlashblockWhitelistManager.mm */,
|
||||
B3886D840F79D52700D8E015 /* FlashblockWhitelistManager.h */,
|
||||
);
|
||||
name = Content;
|
||||
sourceTree = "<group>";
|
||||
@ -6375,7 +6369,6 @@
|
||||
C7DE8DD70F30CFAC00CD3872 /* SafeBrowsingListManager.mm in Sources */,
|
||||
C7DE8DD80F30CFAC00CD3872 /* SafeBrowsingAboutModule.mm in Sources */,
|
||||
3DE5B63A0F6C11B300D2EF11 /* TransientBar.mm in Sources */,
|
||||
B3886D880F79D53700D8E015 /* FlashblockWhitelistManager.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -6564,7 +6557,6 @@
|
||||
C7DE8DD90F30CFAC00CD3872 /* SafeBrowsingListManager.mm in Sources */,
|
||||
C7DE8DDA0F30CFAC00CD3872 /* SafeBrowsingAboutModule.mm in Sources */,
|
||||
3DE5B63B0F6C11B400D2EF11 /* TransientBar.mm in Sources */,
|
||||
B3886D890F79D53700D8E015 /* FlashblockWhitelistManager.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@ -68,7 +68,8 @@
|
||||
IBOutlet ExtendedTableView* mFlashblockWhitelistTable;
|
||||
IBOutlet NSTextField* mAddFlashblockField;
|
||||
IBOutlet NSButton* mAddFlashblockButton;
|
||||
NSArray* mFlashblockSites; // STRONG
|
||||
NSMutableArray* mFlashblockSites; // STRONG
|
||||
NSCharacterSet* mFlashblockSiteCharSet; // STRONG
|
||||
|
||||
NSMutableArray* mCachedPermissions; // cached list for speed, STRONG
|
||||
}
|
||||
@ -98,7 +99,6 @@
|
||||
-(IBAction) editFlashblockWhitelistDone:(id)aSender;
|
||||
-(IBAction) removeFlashblockWhitelistSite:(id)aSender;
|
||||
-(IBAction) addFlashblockWhitelistSite:(id)Sender;
|
||||
-(void) updateFlashblockWhitelist;
|
||||
|
||||
// data source informal protocol (NSTableDataSource)
|
||||
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
|
||||
|
||||
@ -45,12 +45,11 @@
|
||||
#import "CHPermissionManager.h"
|
||||
#import "ExtendedTableView.h"
|
||||
#import "GeckoPrefConstants.h"
|
||||
#import "FlashblockWhitelistManager.h"
|
||||
|
||||
// need to match the strings in PreferenceManager.mm
|
||||
static NSString* const AdBlockingChangedNotificationName = @"AdBlockingChanged";
|
||||
static NSString* const kFlashBlockChangedNotificationName = @"FlashBlockChanged";
|
||||
static NSString* const kFlashblockWhitelistChangedNotificationName = @"FlashblockWhitelistChanged";
|
||||
static NSString* const kFlashBlockWhitelistChangedNotificationName = @"FlashBlockWhitelistChanged";
|
||||
|
||||
// for annoyance blocker prefs
|
||||
const int kAnnoyancePrefNone = 1;
|
||||
@ -64,6 +63,9 @@ const int kAnnoyancePrefSome = 3;
|
||||
- (int)preventAnimationCheckboxState;
|
||||
- (BOOL)isFlashBlockAllowed;
|
||||
- (void)updateFlashBlock;
|
||||
- (BOOL)isValidFlashblockSite:(NSString*)aSite;
|
||||
- (void)populateFlashblockCache;
|
||||
- (void)saveFlashblockWhitelist;
|
||||
- (void)populatePermissionCache;
|
||||
|
||||
@end
|
||||
@ -75,6 +77,7 @@ const int kAnnoyancePrefSome = 3;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[mFlashblockSites release];
|
||||
[mFlashblockSiteCharSet release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -320,9 +323,46 @@ const int kAnnoyancePrefSome = 3;
|
||||
[mAddField setStringValue:@""];
|
||||
}
|
||||
|
||||
// Flashblock Whitelist methods
|
||||
- (void)populateFlashblockCache
|
||||
{
|
||||
// Create the array to hold Flashblock sites
|
||||
if (!mFlashblockSites)
|
||||
mFlashblockSites = [[NSMutableArray alloc] init];
|
||||
else
|
||||
[mFlashblockSites removeAllObjects];
|
||||
|
||||
// Always reload pref since user may have manually edited list
|
||||
// The whitelist pref is a string with format:
|
||||
// siteA.com,www.siteB.com,*.siteC.com
|
||||
NSArray* whitelistArray = [[self getStringPref:"flashblock.whitelist" withSuccess:NULL]
|
||||
componentsSeparatedByString:@","];
|
||||
|
||||
NSEnumerator* enumerator = [whitelistArray objectEnumerator];
|
||||
NSString* site;
|
||||
while ((site = [enumerator nextObject])) {
|
||||
site = [site stringByRemovingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if ([self isValidFlashblockSite:site])
|
||||
[mFlashblockSites addObject:site];
|
||||
}
|
||||
|
||||
// Write correctly formatted sites to prefs so that we stay in sync
|
||||
if ([whitelistArray count] != [mFlashblockSites count])
|
||||
[self saveFlashblockWhitelist];
|
||||
}
|
||||
|
||||
- (void)saveFlashblockWhitelist
|
||||
{
|
||||
NSString* siteString = [mFlashblockSites componentsJoinedByString:@","];
|
||||
[self setPref:"flashblock.whitelist" toString:siteString];
|
||||
|
||||
// Send a notification that the whitelist settings have been changed
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFlashBlockWhitelistChangedNotificationName object:nil];
|
||||
}
|
||||
|
||||
- (IBAction)editFlashblockWhitelist:(id)aSender
|
||||
{
|
||||
[self updateFlashblockWhitelist];
|
||||
[self populateFlashblockCache];
|
||||
|
||||
[NSApp beginSheet:mFlashblockWhitelistPanel
|
||||
modalForWindow:[mEditFlashblockWhitelist window] // any old window accessor
|
||||
@ -333,25 +373,19 @@ const int kAnnoyancePrefSome = 3;
|
||||
[mFlashblockWhitelistTable setDeleteAction:@selector(removeFlashblockWhitelistSite:)];
|
||||
[mFlashblockWhitelistTable setTarget:self];
|
||||
|
||||
[mAddFlashblockButton setEnabled:NO];
|
||||
[mAddButton setEnabled:NO];
|
||||
[mAddFlashblockField setStringValue:@""];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(updateFlashblockWhitelist)
|
||||
name:kFlashblockWhitelistChangedNotificationName
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (IBAction)editFlashblockWhitelistDone:(id)aSender
|
||||
{
|
||||
[mFlashblockSites removeAllObjects];
|
||||
|
||||
[mFlashblockSiteCharSet release];
|
||||
mFlashblockSiteCharSet = nil;
|
||||
|
||||
[mFlashblockWhitelistPanel orderOut:self];
|
||||
[NSApp endSheet:mFlashblockWhitelistPanel];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:kFlashblockWhitelistChangedNotificationName
|
||||
object:nil];
|
||||
[mFlashblockSites release];
|
||||
mFlashblockSites = nil;
|
||||
}
|
||||
|
||||
- (IBAction)removeFlashblockWhitelistSite:(id)aSender
|
||||
@ -360,25 +394,34 @@ const int kAnnoyancePrefSome = 3;
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
[[FlashblockWhitelistManager sharedInstance] removeFlashblockWhitelistSite:[mFlashblockSites objectAtIndex:row]];
|
||||
[mFlashblockSites removeObjectAtIndex:row];
|
||||
[self saveFlashblockWhitelist];
|
||||
[mFlashblockWhitelistTable reloadData];
|
||||
}
|
||||
|
||||
- (IBAction)addFlashblockWhitelistSite:(id)sender
|
||||
{
|
||||
NSString* site = [mAddFlashblockField stringValue];
|
||||
[[FlashblockWhitelistManager sharedInstance] addFlashblockWhitelistSite:site];
|
||||
// The user can no longer add the site that's in the text field,
|
||||
// so clear the text field and disable the Add button.
|
||||
[mAddFlashblockField setStringValue:@""];
|
||||
[mAddFlashblockButton setEnabled:NO];
|
||||
}
|
||||
NSString* site = [[mAddFlashblockField stringValue] stringByRemovingCharactersInSet:
|
||||
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
// Remove any protocol specifier (eg. "http://")
|
||||
NSRange protocolRange = [site rangeOfString:@"://"];
|
||||
if (protocolRange.location != NSNotFound)
|
||||
site = [site substringFromIndex:(protocolRange.location + protocolRange.length)];
|
||||
|
||||
// Only add a Flashblock whitelist site if it's properly formatted and not already added
|
||||
if ([self isValidFlashblockSite:site] && ![mFlashblockSites containsObject:site]) {
|
||||
[mFlashblockSites addObject:site];
|
||||
[self saveFlashblockWhitelist];
|
||||
[mFlashblockWhitelistTable reloadData];
|
||||
|
||||
[mAddFlashblockField setStringValue:@""];
|
||||
[mAddFlashblockButton setEnabled:NO];
|
||||
}
|
||||
else {
|
||||
NSBeep();
|
||||
}
|
||||
|
||||
-(void) updateFlashblockWhitelist
|
||||
{
|
||||
// Get the updated whitelist array.
|
||||
[mFlashblockSites release];
|
||||
mFlashblockSites = [[[FlashblockWhitelistManager sharedInstance] whitelistArray] retain];
|
||||
[mFlashblockWhitelistTable reloadData];
|
||||
}
|
||||
|
||||
// data source informal protocol (NSTableDataSource)
|
||||
@ -427,8 +470,8 @@ const int kAnnoyancePrefSome = 3;
|
||||
|
||||
if (textField == mAddField)
|
||||
[mAddButton setEnabled:[[mAddField stringValue] length] > 0];
|
||||
else if (textField == mAddFlashblockField)
|
||||
[mAddFlashblockButton setEnabled:[[FlashblockWhitelistManager sharedInstance] canAddToWhitelist:[mAddFlashblockField stringValue]]];
|
||||
else // textField == mAddFlashblockField
|
||||
[mAddFlashblockButton setEnabled:[[mAddFlashblockField stringValue] length] > 0];
|
||||
}
|
||||
|
||||
//
|
||||
@ -567,4 +610,46 @@ const int kAnnoyancePrefSome = 3;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFlashBlockChangedNotificationName object:nil];
|
||||
}
|
||||
|
||||
//
|
||||
// isValidFlashblockSite
|
||||
//
|
||||
// Returns true if string contains a valid site (*.site.com or site.com)
|
||||
//
|
||||
- (BOOL)isValidFlashblockSite:(NSString*)aSite
|
||||
{
|
||||
if ([aSite length] == 0)
|
||||
return NO;
|
||||
|
||||
// Reuse character string for hostname validation since it's expensive to make.
|
||||
if (!mFlashblockSiteCharSet) {
|
||||
NSMutableCharacterSet* charSet = [[[NSCharacterSet alphanumericCharacterSet] mutableCopy] autorelease];
|
||||
[charSet addCharactersInString:@"-_"];
|
||||
mFlashblockSiteCharSet = [charSet copy];
|
||||
}
|
||||
|
||||
// Site may begin with '*.', in which case drop the first 2 characters.
|
||||
if ([aSite rangeOfString:@"*."].location == 0)
|
||||
aSite = [aSite substringFromIndex:2];
|
||||
|
||||
// Split string on '.' and check components for valid string.
|
||||
NSArray* subdomains = [aSite componentsSeparatedByString:@"."];
|
||||
|
||||
// There must be at least two components (eg. something.com)
|
||||
if ([subdomains count] < 2)
|
||||
return NO;
|
||||
|
||||
NSEnumerator* enumerator = [subdomains objectEnumerator];
|
||||
NSString* subdomain;
|
||||
while ((subdomain = [enumerator nextObject])) {
|
||||
if ([subdomain length] == 0)
|
||||
return NO;
|
||||
NSScanner* scanner = [NSScanner scannerWithString:subdomain];
|
||||
[scanner scanCharactersFromSet:mFlashblockSiteCharSet intoString:NULL];
|
||||
if (![scanner isAtEnd])
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -1,164 +1,206 @@
|
||||
{
|
||||
IBClasses = (
|
||||
{
|
||||
CLASS = AutoCompleteTextField;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {mLockIconContextMenu = NSMenu; mProxyIcon = PageProxyIcon; };
|
||||
SUPERCLASS = NSTextField;
|
||||
},
|
||||
{
|
||||
ACTIONS = {addFolder = id; };
|
||||
CLASS = BookmarkToolbar;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserContainerView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {mTabBarView = BrowserTabBarView; mTabView = BrowserTabView; };
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
ACTIONS = {toggleBookmarkManager = id; };
|
||||
CLASS = BrowserContentView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mBookmarkManagerView = NSView;
|
||||
mBookmarksToolbar = BookmarkToolbar;
|
||||
mBrowserContainerView = NSView;
|
||||
mStatusBar = NSView;
|
||||
};
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserTabBarView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {mTabView = BrowserTabView; };
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserTabView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {mTabBar = BrowserTabBarView; };
|
||||
SUPERCLASS = NSTabView;
|
||||
},
|
||||
{CLASS = BrowserTabViewItem; LANGUAGE = ObjC; SUPERCLASS = IconTabViewItem; },
|
||||
{CLASS = BrowserWindow; LANGUAGE = ObjC; SUPERCLASS = NSWindow; },
|
||||
{
|
||||
ACTIONS = {
|
||||
addBookmark = id;
|
||||
addBookmarkFolder = id;
|
||||
addBookmarkForLink = id;
|
||||
addBookmarkSeparator = id;
|
||||
addBookmarkWithoutPrompt = id;
|
||||
addTabGroup = id;
|
||||
addTabGroupWithoutPrompt = id;
|
||||
addToAddressBook = id;
|
||||
back = id;
|
||||
cancelLocationSheet = id;
|
||||
cancelSearchSheet = id;
|
||||
closeCurrentTab = id;
|
||||
closeOtherTabs = id;
|
||||
closeSendersTab = id;
|
||||
copyAddressToClipboard = id;
|
||||
copyImage = id;
|
||||
copyImageLocation = id;
|
||||
copyLinkLocation = id;
|
||||
endLocationSheet = id;
|
||||
endSearchSheet = id;
|
||||
findSearchEngines = id;
|
||||
forward = id;
|
||||
frameToNewTab = id;
|
||||
frameToNewWindow = id;
|
||||
frameToThisWindow = id;
|
||||
getInfo = id;
|
||||
goToLocationFromToolbarURLField = id;
|
||||
home = id;
|
||||
makePageBigger = id;
|
||||
makePageDefaultSize = id;
|
||||
makePageSmaller = id;
|
||||
makeTextBigger = id;
|
||||
makeTextDefaultSize = id;
|
||||
makeTextSmaller = id;
|
||||
manageBookmarks = id;
|
||||
manageHistory = id;
|
||||
manageSearchEngines = id;
|
||||
moveTabToNewWindow = id;
|
||||
newTab = id;
|
||||
nextTab = id;
|
||||
openFeedPrefPane = id;
|
||||
openLinkInNewTab = id;
|
||||
openLinkInNewWindow = id;
|
||||
pageSetup = id;
|
||||
previousTab = id;
|
||||
printDocument = id;
|
||||
reload = id;
|
||||
reloadAllTabs = id;
|
||||
reloadSendersTab = id;
|
||||
reloadWithNewCharset = id;
|
||||
saveFrameAs = id;
|
||||
saveImageAs = id;
|
||||
saveLinkAs = id;
|
||||
savePageAs = id;
|
||||
searchFieldTriggered = id;
|
||||
searchForSelection = id;
|
||||
sendURL = id;
|
||||
sendURLFromLink = id;
|
||||
showBookmarksInfo = id;
|
||||
showPageInfo = id;
|
||||
showSiteCertificate = id;
|
||||
stop = id;
|
||||
toggleStatusBar = id;
|
||||
toggleTabThumbnailView = id;
|
||||
unblockFlashFromCurrentDomain = id;
|
||||
viewOnlyThisImage = id;
|
||||
viewPageSource = id;
|
||||
viewSource = id;
|
||||
};
|
||||
CLASS = BrowserWindowController;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mBackItem = NSMenuItem;
|
||||
mContentView = BrowserContentView;
|
||||
mCopyItem = NSMenuItem;
|
||||
mForwardItem = NSMenuItem;
|
||||
mImageLinkMenu = NSMenu;
|
||||
mImageMailToLinkMenu = NSMenu;
|
||||
mImageMenu = NSMenu;
|
||||
mInputMenu = NSMenu;
|
||||
mLinkMenu = NSMenu;
|
||||
mLocationSheetURLField = NSTextField;
|
||||
mLocationSheetWindow = NSWindow;
|
||||
mLocationToolbarView = ExtendedSplitView;
|
||||
mMailToLinkMenu = NSMenu;
|
||||
mPageMenu = NSMenu;
|
||||
mPersonalToolbar = BookmarkToolbar;
|
||||
mProgress = NSProgressIndicator;
|
||||
mSearchBar = WebSearchField;
|
||||
mSearchSheetTextField = WebSearchField;
|
||||
mSearchSheetWindow = NSWindow;
|
||||
mStatus = NSTextField;
|
||||
mStatusBar = NSView;
|
||||
mTabBarMenu = NSMenu;
|
||||
mTabBrowser = BrowserTabView;
|
||||
mTabMenu = NSMenu;
|
||||
mURLBar = AutoCompleteTextField;
|
||||
};
|
||||
SUPERCLASS = NSWindowController;
|
||||
},
|
||||
{CLASS = ExtendedSplitView; LANGUAGE = ObjC; SUPERCLASS = NSSplitView; },
|
||||
{
|
||||
ACTIONS = {addBookmark = id; addBookmarkFolder = id; addBookmarkSeparator = id; };
|
||||
CLASS = FirstResponder;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
{CLASS = IconTabViewItem; LANGUAGE = ObjC; SUPERCLASS = NSTabViewItem; },
|
||||
{CLASS = NSObject; LANGUAGE = ObjC; },
|
||||
{CLASS = PageProxyIcon; LANGUAGE = ObjC; SUPERCLASS = NSImageView; },
|
||||
{CLASS = StatusBarView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
|
||||
{CLASS = ThrobberHandler; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
{CLASS = WebSearchField; LANGUAGE = ObjC; SUPERCLASS = NSSearchField; }
|
||||
);
|
||||
IBVersion = 1;
|
||||
IBClasses = (
|
||||
{
|
||||
CLASS = AutoCompleteTextField;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mLockIconContextMenu = NSMenu;
|
||||
mProxyIcon = PageProxyIcon;
|
||||
};
|
||||
SUPERCLASS = NSTextField;
|
||||
},
|
||||
{
|
||||
ACTIONS = {
|
||||
addFolder = id;
|
||||
};
|
||||
CLASS = BookmarkToolbar;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserContainerView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mTabBarView = BrowserTabBarView;
|
||||
mTabView = BrowserTabView;
|
||||
};
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
ACTIONS = {
|
||||
toggleBookmarkManager = id;
|
||||
};
|
||||
CLASS = BrowserContentView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mBookmarkManagerView = NSView;
|
||||
mBookmarksToolbar = BookmarkToolbar;
|
||||
mBrowserContainerView = NSView;
|
||||
mStatusBar = NSView;
|
||||
};
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserTabBarView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mTabView = BrowserTabView;
|
||||
};
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserTabView;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mTabBar = BrowserTabBarView;
|
||||
};
|
||||
SUPERCLASS = NSTabView;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserTabViewItem;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = IconTabViewItem;
|
||||
},
|
||||
{
|
||||
CLASS = BrowserWindow;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSWindow;
|
||||
},
|
||||
{
|
||||
ACTIONS = {
|
||||
addBookmark = id;
|
||||
addBookmarkFolder = id;
|
||||
addBookmarkForLink = id;
|
||||
addBookmarkSeparator = id;
|
||||
addBookmarkWithoutPrompt = id;
|
||||
addTabGroup = id;
|
||||
addTabGroupWithoutPrompt = id;
|
||||
addToAddressBook = id;
|
||||
back = id;
|
||||
cancelLocationSheet = id;
|
||||
cancelSearchSheet = id;
|
||||
closeCurrentTab = id;
|
||||
closeOtherTabs = id;
|
||||
closeSendersTab = id;
|
||||
copyAddressToClipboard = id;
|
||||
copyImage = id;
|
||||
copyImageLocation = id;
|
||||
copyLinkLocation = id;
|
||||
endLocationSheet = id;
|
||||
endSearchSheet = id;
|
||||
forward = id;
|
||||
frameToNewTab = id;
|
||||
frameToNewWindow = id;
|
||||
frameToThisWindow = id;
|
||||
getInfo = id;
|
||||
goToLocationFromToolbarURLField = id;
|
||||
home = id;
|
||||
makeTextBigger = id;
|
||||
makeTextDefaultSize = id;
|
||||
makeTextSmaller = id;
|
||||
manageBookmarks = id;
|
||||
manageHistory = id;
|
||||
moveTabToNewWindow = id;
|
||||
newTab = id;
|
||||
nextTab = id;
|
||||
openFeedPrefPane = id;
|
||||
openLinkInNewTab = id;
|
||||
openLinkInNewWindow = id;
|
||||
pageSetup = id;
|
||||
previousTab = id;
|
||||
printDocument = id;
|
||||
reload = id;
|
||||
reloadAllTabs = id;
|
||||
reloadSendersTab = id;
|
||||
reloadWithNewCharset = id;
|
||||
saveFrameAs = id;
|
||||
saveImageAs = id;
|
||||
saveLinkAs = id;
|
||||
savePageAs = id;
|
||||
searchFieldTriggered = id;
|
||||
searchForSelection = id;
|
||||
sendURL = id;
|
||||
sendURLFromLink = id;
|
||||
showBookmarksInfo = id;
|
||||
showPageInfo = id;
|
||||
showSiteCertificate = id;
|
||||
stop = id;
|
||||
toggleStatusBar = id;
|
||||
viewOnlyThisImage = id;
|
||||
viewPageSource = id;
|
||||
viewSource = id;
|
||||
};
|
||||
CLASS = BrowserWindowController;
|
||||
LANGUAGE = ObjC;
|
||||
OUTLETS = {
|
||||
mBackItem = NSMenuItem;
|
||||
mContentView = BrowserContentView;
|
||||
mCopyItem = NSMenuItem;
|
||||
mForwardItem = NSMenuItem;
|
||||
mImageLinkMenu = NSMenu;
|
||||
mImageMailToLinkMenu = NSMenu;
|
||||
mImageMenu = NSMenu;
|
||||
mInputMenu = NSMenu;
|
||||
mLinkMenu = NSMenu;
|
||||
mLocationSheetURLField = NSTextField;
|
||||
mLocationSheetWindow = NSWindow;
|
||||
mLocationToolbarView = ExtendedSplitView;
|
||||
mMailToLinkMenu = NSMenu;
|
||||
mPageMenu = NSMenu;
|
||||
mPersonalToolbar = BookmarkToolbar;
|
||||
mProgress = NSProgressIndicator;
|
||||
mProxyIcon = PageProxyIcon;
|
||||
mSearchBar = NSSearchField;
|
||||
mSearchSheetTextField = NSSearchField;
|
||||
mSearchSheetWindow = NSWindow;
|
||||
mStatus = NSTextField;
|
||||
mStatusBar = NSView;
|
||||
mTabBarMenu = NSMenu;
|
||||
mTabBrowser = BrowserTabView;
|
||||
mTabMenu = NSMenu;
|
||||
mURLBar = AutoCompleteTextField;
|
||||
};
|
||||
SUPERCLASS = NSWindowController;
|
||||
},
|
||||
{
|
||||
CLASS = ExtendedSplitView;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSSplitView;
|
||||
},
|
||||
{
|
||||
ACTIONS = {
|
||||
addBookmark = id;
|
||||
addBookmarkFolder = id;
|
||||
addBookmarkSeparator = id;
|
||||
};
|
||||
CLASS = FirstResponder;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
{
|
||||
CLASS = IconTabViewItem;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSTabViewItem;
|
||||
},
|
||||
{
|
||||
CLASS = NSObject;
|
||||
LANGUAGE = ObjC;
|
||||
},
|
||||
{
|
||||
CLASS = PageProxyIcon;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSImageView;
|
||||
},
|
||||
{
|
||||
CLASS = StatusBarView;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSView;
|
||||
},
|
||||
{
|
||||
CLASS = WebSearchField;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSSearchField;
|
||||
}
|
||||
);
|
||||
IBVersion = 1;
|
||||
}
|
||||
@ -1,24 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>111 74 356 240 0 0 1440 878 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>297</key>
|
||||
<string>526 315 226 424 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<string>95 62 356 240 0 0 1280 778 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>489.0</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>4</integer>
|
||||
<integer>5</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8S2167</string>
|
||||
<string>9F33</string>
|
||||
<key>targetFramework</key>
|
||||
<string>IBCocoaFramework</string>
|
||||
</dict>
|
||||
|
||||
Binary file not shown.
@ -357,8 +357,6 @@ typedef enum {
|
||||
- (IBAction)copyImage:(id)sender;
|
||||
- (IBAction)copyImageLocation:(id)sender;
|
||||
|
||||
- (IBAction)unblockFlashFromCurrentDomain:(id)sender;
|
||||
|
||||
- (BookmarkToolbar*) bookmarkToolbar;
|
||||
|
||||
- (BOOL)windowClosesQuietly;
|
||||
|
||||
@ -84,7 +84,6 @@
|
||||
#import "ToolbarScriptItem.h"
|
||||
#import "SearchEngineManager.h"
|
||||
#import "SearchEngineEditor.h"
|
||||
#import "FlashblockWhitelistManager.h"
|
||||
// For search plugin description keys:
|
||||
#import "XMLSearchPluginParser.h"
|
||||
|
||||
@ -115,12 +114,6 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMDocumentView.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSSValue.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
|
||||
#include "nsICommandManager.h"
|
||||
#include "nsICommandParams.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
@ -198,7 +191,6 @@ const int kSpellingRelatedItemsTag = 103;
|
||||
const int kItemsNeedingOpenBehaviorAlternatesTag = 104;
|
||||
const int kItemsNeedingForceAlternateTag = 105;
|
||||
const int kLinkOpeningItemsTag = 106;
|
||||
const int kFlashblockTag = 107;
|
||||
|
||||
// Cached toolbar defaults read in from a plist. If null, we'll use
|
||||
// hardcoded defaults.
|
||||
@ -620,7 +612,6 @@ public:
|
||||
- (void)populateEnginesIntoSearchField:(WebSearchField*)searchField;
|
||||
- (NSString*)lastKnownPreferredSearchEngine;
|
||||
- (void)setLastKnownPreferredSearchEngine:(NSString*)inPreferredEngine;
|
||||
- (BOOL)isFlashblockElement:(nsIDOMNode*)aNode;
|
||||
|
||||
@end
|
||||
|
||||
@ -4154,7 +4145,6 @@ public:
|
||||
|
||||
BOOL hasSelection = [[mBrowserView browserView] canCopy];
|
||||
BOOL isMidas = NO;
|
||||
BOOL isFlashblock = NO;
|
||||
|
||||
if (mDataOwner->mContextMenuNode) {
|
||||
nsCOMPtr<nsIDOMDocument> ownerDoc;
|
||||
@ -4262,24 +4252,12 @@ public:
|
||||
[mBackItem setEnabled: [[mBrowserView browserView] canGoBack]];
|
||||
[mForwardItem setEnabled: [[mBrowserView browserView] canGoForward]];
|
||||
[mCopyItem setEnabled:hasSelection];
|
||||
|
||||
if ([[PreferenceManager sharedInstance] getBooleanPref:kGeckoPrefBlockFlash withSuccess:NULL]
|
||||
&& [self isFlashblockElement:(mDataOwner->mContextMenuNode)]) {
|
||||
isFlashblock = YES;
|
||||
}
|
||||
}
|
||||
|
||||
// we have to clone the menu and return that, so that we don't change
|
||||
// our only copy of the menu
|
||||
NSMenu* result = [[menuPrototype copy] autorelease];
|
||||
|
||||
if (!isFlashblock) {
|
||||
NSMenuItem* flashblockItem;
|
||||
// this removes the separator above the item as well
|
||||
while ((flashblockItem = [result itemWithTag:kFlashblockTag]) != nil)
|
||||
[result removeItem:flashblockItem];
|
||||
}
|
||||
|
||||
if (isUnsafeLink) {
|
||||
NSMenuItem* frameItem;
|
||||
while ((frameItem = [result itemWithTag:kLinkOpeningItemsTag]) != nil)
|
||||
@ -4736,67 +4714,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// -isFlashblockElement:
|
||||
//
|
||||
// Returns YES if the element is a Flashblock placeholder. This is achieved by
|
||||
// looking for chrome://flashblock/content/* as the element's background image.
|
||||
//
|
||||
- (BOOL)isFlashblockElement:(nsIDOMNode*)aNode
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> flashElement(do_QueryInterface(aNode));
|
||||
if(!flashElement) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> document;
|
||||
flashElement->GetOwnerDocument(getter_AddRefs(document));
|
||||
nsCOMPtr<nsIDOMDocumentView> docView(do_QueryInterface(document));
|
||||
if (!docView) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMAbstractView> defaultView;
|
||||
docView->GetDefaultView(getter_AddRefs(defaultView));
|
||||
nsCOMPtr<nsIDOMViewCSS> defaultCSSView(do_QueryInterface(defaultView));
|
||||
if (!defaultCSSView) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMCSSStyleDeclaration> computedStyle;
|
||||
defaultCSSView->GetComputedStyle(flashElement, EmptyString(),
|
||||
getter_AddRefs(computedStyle));
|
||||
if (!computedStyle) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMCSSValue> cssValue;
|
||||
computedStyle->GetPropertyCSSValue(NS_LITERAL_STRING("background-image"),
|
||||
getter_AddRefs(cssValue));
|
||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> primitiveValue;
|
||||
primitiveValue = do_QueryInterface(cssValue);
|
||||
if (!primitiveValue) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
nsAutoString bgStringValue;
|
||||
primitiveValue->GetStringValue(bgStringValue);
|
||||
return [[NSString stringWith_nsAString:bgStringValue]
|
||||
hasPrefix:@"chrome://flashblock/content/"];
|
||||
}
|
||||
|
||||
//
|
||||
// -unblockFlashFromCurrentDomain:
|
||||
//
|
||||
// Context menu action for adding the current domain to the Flashblock whitelist.
|
||||
//
|
||||
- (IBAction)unblockFlashFromCurrentDomain:(id)sender
|
||||
{
|
||||
NSString *currentDomain = [[[self browserWrapper] browserView] pageLocationHost];
|
||||
[[FlashblockWhitelistManager sharedInstance] addFlashblockWhitelistSite:currentDomain];
|
||||
[self reload:nil];
|
||||
}
|
||||
|
||||
- (IBAction)showPageInfo:(id)sender
|
||||
{
|
||||
PageInfoWindowController* pageInfoController = [PageInfoWindowController sharedPageInfoWindowController];
|
||||
|
||||
@ -59,7 +59,6 @@
|
||||
|
||||
#include "CHBrowserService.h"
|
||||
#include "ContentClickListener.h"
|
||||
#import "FlashblockWhitelistManager.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIMutableArray.h"
|
||||
@ -95,6 +94,131 @@ enum StatusPriority {
|
||||
};
|
||||
|
||||
NSString* const kBrowserInstanceClosedNotification = @"BrowserInstanceClosed";
|
||||
static NSString* const kFlashBlockWhitelistChangedNotificationName = @"FlashBlockWhitelistChanged";
|
||||
|
||||
//
|
||||
// interface FlashblockWhitelistManager
|
||||
//
|
||||
// A singleton class to manage list of sites where Flash is allowed
|
||||
// when otherwise Flash is blocked
|
||||
//
|
||||
|
||||
@interface FlashblockWhitelistManager : NSObject
|
||||
{
|
||||
NSString* mFlashblockWhitelistPref; // STRONG
|
||||
NSMutableArray* mFlashblockWhitelistSites; // STRONG
|
||||
}
|
||||
|
||||
// Returns the shared FlashblockWhitelistManager instance.
|
||||
+ (FlashblockWhitelistManager*)sharedInstance;
|
||||
|
||||
// Loads whitelisted sites from preference
|
||||
- (void)reloadWhitelistSites;
|
||||
|
||||
// Checks if Flash is allowed for the site
|
||||
- (BOOL)isFlashAllowedForSite:(NSString*)site;
|
||||
|
||||
@end
|
||||
|
||||
static FlashblockWhitelistManager* sFlashblockWhitelistManager = nil;
|
||||
|
||||
@implementation FlashblockWhitelistManager
|
||||
|
||||
+ (FlashblockWhitelistManager*)sharedInstance
|
||||
{
|
||||
if (!sFlashblockWhitelistManager)
|
||||
sFlashblockWhitelistManager = [[self alloc] init];
|
||||
|
||||
return sFlashblockWhitelistManager;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
[self reloadWhitelistSites];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(reloadWhitelistSites)
|
||||
name:kFlashBlockWhitelistChangedNotificationName
|
||||
object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// Currently dealloc won't be called since there is no callback to tell the instance
|
||||
// that the application is shutting down. But nothing happens here that isn't already
|
||||
// taken care of when the application closes, so we don't need to enforce calling this.
|
||||
- (void)dealloc
|
||||
{
|
||||
[mFlashblockWhitelistPref release];
|
||||
[mFlashblockWhitelistSites release];
|
||||
|
||||
sFlashblockWhitelistManager = nil;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)reloadWhitelistSites
|
||||
{
|
||||
NSString* whitelistPref = [[PreferenceManager sharedInstance] getStringPref:"flashblock.whitelist" withSuccess:NULL];
|
||||
|
||||
// Update array of whitelisted sites only if the preference has changed
|
||||
if (!mFlashblockWhitelistPref || ![mFlashblockWhitelistPref isEqualToString:whitelistPref]) {
|
||||
[mFlashblockWhitelistPref release];
|
||||
mFlashblockWhitelistPref = [whitelistPref retain];
|
||||
|
||||
if (!mFlashblockWhitelistSites)
|
||||
mFlashblockWhitelistSites = [[NSMutableArray alloc] init];
|
||||
else
|
||||
[mFlashblockWhitelistSites removeAllObjects];
|
||||
|
||||
// Whitelist is a string with format:
|
||||
// siteA.com,www.siteB.com,*.siteC.com
|
||||
NSArray* whitelistSites = [mFlashblockWhitelistPref componentsSeparatedByString:@","];
|
||||
NSEnumerator* prefEnumerator = [whitelistSites objectEnumerator];
|
||||
NSString* prefSite;
|
||||
while ((prefSite = [prefEnumerator nextObject])) {
|
||||
// Require at least one '.' so that an entry of 'com' or an empty string won't
|
||||
// match every site.
|
||||
if ([prefSite rangeOfString:@"."].location == NSNotFound)
|
||||
continue;
|
||||
|
||||
prefSite = [[prefSite lowercaseString] stringByTrimmingCharactersInSet:
|
||||
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
// Goal: For 'site.com' whitelist, match www.site.com and site.com, but not thesite.com.
|
||||
// Strategy: Append '.' to whitelist strings, then match the end of the site string
|
||||
// with the whitelist strings. This will prevent 'site.com' from matching the end of
|
||||
// thesite.com but will match site.com and www.site.com.If site string is not in proper
|
||||
// format, it will (gracefully) not match.
|
||||
if ([prefSite rangeOfString:@"*."].location == 0)
|
||||
prefSite = [prefSite substringFromIndex:1];
|
||||
else
|
||||
prefSite = [@"." stringByAppendingString:prefSite];
|
||||
|
||||
[mFlashblockWhitelistSites addObject:prefSite];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isFlashAllowedForSite:(NSString*)site
|
||||
{
|
||||
// As above, add "." to the beginning of site so that site.com will match a whitelist
|
||||
// of site.com that has been saved in the array as '.site.com'
|
||||
site = [@"." stringByAppendingString:site];
|
||||
|
||||
NSEnumerator* enumerator = [mFlashblockWhitelistSites objectEnumerator];
|
||||
NSString* whitelistSite;
|
||||
while ((whitelistSite = [enumerator nextObject])) {
|
||||
if ([site hasSuffix:whitelistSite])
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface BrowserWrapper(Private)
|
||||
|
||||
|
||||
@ -1,90 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Bryan Atwood
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bryan Atwood <bryan.h.atwood@gmail.com>
|
||||
* Christopher Henderson <trendyhendy2000@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
//
|
||||
// interface FlashblockWhitelistManager
|
||||
//
|
||||
// A singleton class to manage list of sites where Flash is allowed
|
||||
// when otherwise Flash is blocked
|
||||
//
|
||||
@interface FlashblockWhitelistManager : NSObject
|
||||
{
|
||||
NSString* mFlashblockWhitelistPref; // STRONG
|
||||
NSMutableArray* mFlashblockWhitelistSites; // STRONG
|
||||
NSCharacterSet* mFlashblockSiteCharSet; // STRONG
|
||||
}
|
||||
|
||||
// Returns the shared FlashblockWhitelistManager instance.
|
||||
+ (FlashblockWhitelistManager*)sharedInstance;
|
||||
|
||||
// Loads whitelisted sites from the preference.
|
||||
- (void)loadWhitelistSites;
|
||||
|
||||
// Sets the Flashblock whitelist Gecko preference to the current whitelist array.
|
||||
- (void)saveFlashblockWhitelist;
|
||||
|
||||
// Adds the site to the Flashblock whitelist, if valid and not already present.
|
||||
// aSite should be just the host (site.tld, sub.site.tld, or *.site.tld).
|
||||
// Returns YES if the site was added.
|
||||
- (BOOL)addFlashblockWhitelistSite:(NSString*)aSite;
|
||||
|
||||
// Removes the site from the whitelist, if present, and saves the modified list.
|
||||
// aSite should be just the host (site.tld, sub.site.tld, or *.site.tld).
|
||||
- (void)removeFlashblockWhitelistSite:(NSString*)aSite;
|
||||
|
||||
// Returns YES if the site or any of its subdomains is in the whitelist.
|
||||
// aSite should be just the host (site.tld or sub.site.tld).
|
||||
- (BOOL)isFlashAllowedForSite:(NSString*)aSite;
|
||||
|
||||
// Returns YES if the string contains a valid site and is not already in the
|
||||
// whitelist.
|
||||
// aSite should be just the host (site.tld, sub.site.tld, or *.site.tld).
|
||||
- (BOOL)canAddToWhitelist:(NSString*)aSite;
|
||||
|
||||
// Returns YES if string contains a valid site.
|
||||
// aSite should be just the host (site.tld, sub.site.tld, or *.site.tld).
|
||||
- (BOOL)isValidFlashblockSite:(NSString*)aSite;
|
||||
|
||||
// The current array of whitelist sites.
|
||||
- (NSArray*)whitelistArray;
|
||||
|
||||
@end
|
||||
@ -1,256 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Bryan Atwood
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bryan Atwood <bryan.h.atwood@gmail.com>
|
||||
* Christopher Henderson <trendyhendy2000@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import "FlashblockWhitelistManager.h"
|
||||
|
||||
#import "PreferenceManager.h"
|
||||
#import "NSString+Utils.h"
|
||||
|
||||
static FlashblockWhitelistManager* sFlashblockWhitelistManager = nil;
|
||||
static NSString* const kFlashblockWhitelistChangedNotificationName = @"FlashblockWhitelistChanged";
|
||||
|
||||
@implementation FlashblockWhitelistManager
|
||||
|
||||
+ (FlashblockWhitelistManager*)sharedInstance
|
||||
{
|
||||
if (!sFlashblockWhitelistManager)
|
||||
sFlashblockWhitelistManager = [[self alloc] init];
|
||||
|
||||
return sFlashblockWhitelistManager;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
[self loadWhitelistSites];
|
||||
|
||||
[[PreferenceManager sharedInstance] addObserver:self forPref:kGeckoPrefFlashblockWhitelist];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(loadWhitelistSites)
|
||||
name:kPrefChangedNotificationName
|
||||
object:self]; // since we added ourself as the Gecko pref observer
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// Currently dealloc won't be called since there is no callback to tell the instance
|
||||
// that the application is shutting down. But nothing happens here that isn't already
|
||||
// taken care of when the application closes, so we don't need to enforce calling this.
|
||||
- (void)dealloc
|
||||
{
|
||||
[mFlashblockWhitelistPref release];
|
||||
[mFlashblockWhitelistSites release];
|
||||
[mFlashblockSiteCharSet release];
|
||||
|
||||
sFlashblockWhitelistManager = nil;
|
||||
|
||||
[[PreferenceManager sharedInstanceDontCreate] removeObserver:self forPref:kGeckoPrefFlashblockWhitelist];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
//
|
||||
// -loadWhitelistSites:
|
||||
//
|
||||
// Load the list of Flashblock whitelist sites from the Gecko preference.
|
||||
// Parse each site to allow subdomain matching within |isFlashAllowedForSite|.
|
||||
// Post a notification that the whitelist has changed, so that observers can
|
||||
// obtain an updated list using |whitelistArray|.
|
||||
//
|
||||
- (void)loadWhitelistSites
|
||||
{
|
||||
NSString* whitelistPref = [[PreferenceManager sharedInstance] getStringPref:kGeckoPrefFlashblockWhitelist
|
||||
withSuccess:NULL];
|
||||
// Update array of whitelisted sites only if the preference has changed
|
||||
if (!mFlashblockWhitelistPref || ![mFlashblockWhitelistPref isEqualToString:whitelistPref]) {
|
||||
[mFlashblockWhitelistPref release];
|
||||
mFlashblockWhitelistPref = [whitelistPref retain];
|
||||
|
||||
if (!mFlashblockWhitelistSites)
|
||||
mFlashblockWhitelistSites = [[NSMutableArray alloc] init];
|
||||
else
|
||||
[mFlashblockWhitelistSites removeAllObjects];
|
||||
|
||||
// Whitelist is a string with format:
|
||||
// siteA.tld, www.siteB.tld, *.siteC.tld
|
||||
NSArray* whitelistSites = [mFlashblockWhitelistPref componentsSeparatedByString:@","];
|
||||
NSEnumerator* prefEnumerator = [whitelistSites objectEnumerator];
|
||||
NSString* prefSite;
|
||||
while ((prefSite = [prefEnumerator nextObject])) {
|
||||
// Require at least one '.' so that an entry of 'tld' or an empty string won't
|
||||
// match every site.
|
||||
if ([prefSite rangeOfString:@"."].location == NSNotFound)
|
||||
continue;
|
||||
|
||||
prefSite = [[prefSite lowercaseString] stringByTrimmingCharactersInSet:
|
||||
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
// Goal: For 'site.tld' whitelist, match www.site.tld and site.tld, but not thesite.tld.
|
||||
// Strategy: Append '.' to whitelist strings, then match the end of the site string
|
||||
// with the whitelist strings. This will prevent 'site.tld' from matching the end of
|
||||
// thesite.tld but will match site.tld and www.site.tld. If site string is not in proper
|
||||
// format, it will (gracefully) not match.
|
||||
if ([prefSite rangeOfString:@"*."].location == 0)
|
||||
prefSite = [prefSite substringFromIndex:1];
|
||||
else
|
||||
prefSite = [@"." stringByAppendingString:prefSite];
|
||||
|
||||
[mFlashblockWhitelistSites addObject:prefSite];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFlashblockWhitelistChangedNotificationName object:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)saveFlashblockWhitelist
|
||||
{
|
||||
NSArray* arrayToSave = [self whitelistArray];
|
||||
NSString* siteString = [arrayToSave componentsJoinedByString:@","];
|
||||
[[PreferenceManager sharedInstance] setPref:kGeckoPrefFlashblockWhitelist toString:siteString];
|
||||
}
|
||||
|
||||
- (BOOL)addFlashblockWhitelistSite:(NSString*)aSite
|
||||
{
|
||||
NSString* site = [aSite stringByRemovingCharactersInSet:
|
||||
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
// Remove any protocol specifier (eg. "http://")
|
||||
NSRange protocolRange = [site rangeOfString:@"://"];
|
||||
if (protocolRange.location != NSNotFound)
|
||||
site = [site substringFromIndex:(protocolRange.location + protocolRange.length)];
|
||||
|
||||
// Only add a Flashblock whitelist site if it's properly formatted and not already added
|
||||
if ([self canAddToWhitelist:site]) {
|
||||
[mFlashblockWhitelistSites addObject:site];
|
||||
[self saveFlashblockWhitelist];
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeFlashblockWhitelistSite:(NSString*)aSite
|
||||
{
|
||||
[mFlashblockWhitelistSites removeObject:[@"." stringByAppendingString:aSite]];
|
||||
[self saveFlashblockWhitelist];
|
||||
}
|
||||
|
||||
- (BOOL)isFlashAllowedForSite:(NSString*)aSite
|
||||
{
|
||||
// As above, add "." to the beginning of site so that site.tld will match a whitelist
|
||||
// of site.tld that has been saved in the array as '.site.tld'
|
||||
aSite = [@"." stringByAppendingString:aSite];
|
||||
NSEnumerator* enumerator = [mFlashblockWhitelistSites objectEnumerator];
|
||||
NSString* whitelistSite;
|
||||
while ((whitelistSite = [enumerator nextObject])) {
|
||||
if ([aSite hasSuffix:whitelistSite])
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)canAddToWhitelist:(NSString*)aSite
|
||||
{
|
||||
return ([self isValidFlashblockSite:aSite]
|
||||
&& ![mFlashblockWhitelistSites containsObject:[@"." stringByAppendingString:aSite]]);
|
||||
}
|
||||
|
||||
- (BOOL)isValidFlashblockSite:(NSString*)aSite
|
||||
{
|
||||
if ([aSite length] == 0)
|
||||
return NO;
|
||||
|
||||
// Reuse character string for hostname validation since it's expensive to make.
|
||||
if (!mFlashblockSiteCharSet) {
|
||||
NSMutableCharacterSet* charSet = [[[NSCharacterSet alphanumericCharacterSet] mutableCopy] autorelease];
|
||||
[charSet addCharactersInString:@"-_"];
|
||||
mFlashblockSiteCharSet = [charSet copy];
|
||||
}
|
||||
|
||||
// Site may begin with '*.', in which case drop the first 2 characters.
|
||||
if ([aSite rangeOfString:@"*."].location == 0)
|
||||
aSite = [aSite substringFromIndex:2];
|
||||
|
||||
// Split string on '.' and check components for valid string.
|
||||
NSArray* subdomains = [aSite componentsSeparatedByString:@"."];
|
||||
|
||||
// There must be at least two components (e.g., something.tld)
|
||||
if ([subdomains count] < 2)
|
||||
return NO;
|
||||
|
||||
NSEnumerator* enumerator = [subdomains objectEnumerator];
|
||||
NSString* subdomain;
|
||||
while ((subdomain = [enumerator nextObject])) {
|
||||
if ([subdomain length] == 0)
|
||||
return NO;
|
||||
NSScanner* scanner = [NSScanner scannerWithString:subdomain];
|
||||
[scanner scanCharactersFromSet:mFlashblockSiteCharSet intoString:NULL];
|
||||
if (![scanner isAtEnd])
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
//
|
||||
// -whitelistArray:
|
||||
//
|
||||
// Returns an array of the current entries in the whitelist. Removes the dots
|
||||
// at the beginning of each string, making them suitable for displaying in
|
||||
// the Web Features preference pane and for saving to the preference.
|
||||
//
|
||||
- (NSArray*)whitelistArray
|
||||
{
|
||||
NSEnumerator* enumerator = [mFlashblockWhitelistSites objectEnumerator];
|
||||
NSString* singleSite;
|
||||
NSMutableArray* noDotArray = [NSMutableArray arrayWithCapacity:[mFlashblockWhitelistSites count]];
|
||||
while ((singleSite = (NSString*)[enumerator nextObject])) {
|
||||
if ([singleSite rangeOfString:@"*."].location == 0)
|
||||
[noDotArray addObject:[singleSite substringFromIndex:2]];
|
||||
else if ([singleSite rangeOfString:@"."].location == 0)
|
||||
[noDotArray addObject:[singleSite substringFromIndex:1]];
|
||||
else
|
||||
[noDotArray addObject:singleSite];
|
||||
}
|
||||
return noDotArray;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -113,9 +113,6 @@ extern const char* const kGeckoPrefBlockAds; // bool
|
||||
// Controls whether Flashblock is enabled
|
||||
extern const char* const kGeckoPrefBlockFlash; // bool
|
||||
|
||||
// The whitelist of allowed Flash sites
|
||||
extern const char* const kGeckoPrefFlashblockWhitelist; // string
|
||||
|
||||
// Controls how animated images are allowed to animate
|
||||
extern const char* const kGeckoPrefImageAnimationBehavior; // string
|
||||
// Possible values:
|
||||
|
||||
@ -113,7 +113,6 @@ const char* const kGeckoPrefEnablePlugins = "camino.enable_plugins";
|
||||
const char* const kGeckoPrefBlockPopups = "dom.disable_open_during_load";
|
||||
const char* const kGeckoPrefBlockAds = "camino.enable_ad_blocking";
|
||||
const char* const kGeckoPrefBlockFlash = "camino.enable_flashblock";
|
||||
const char* const kGeckoPrefFlashblockWhitelist = "flashblock.whitelist";
|
||||
const char* const kGeckoPrefImageAnimationBehavior = "image.animation_mode";
|
||||
const char* const kGeckoPrefPreventDOMWindowResize = "dom.disable_window_move_resize";
|
||||
const char* const kGeckoPrefPreventDOMStatusChange = "dom.disable_window_status_change";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user