Fix bug 331194, implement ability to show (and whitelist) blocked popups. r/sr=pinkerton

This commit is contained in:
hwaara%gmail.com 2006-07-06 08:13:25 +00:00
Родитель 7ce269136a
Коммит ecbd24f472
9 изменённых файлов: 42 добавлений и 60 удалений

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

@ -58,8 +58,3 @@
}
@end
@interface BookmarkManagerView : NSView
{
}
@end

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

@ -186,24 +186,3 @@
}
@end
#pragma mark -
@implementation BookmarkManagerView
- (BOOL) isOpaque
{
return YES;
}
- (void)drawRect:(NSRect)aRect
{
[[NSColor windowBackgroundColor] set];
NSRectFill(aRect);
[[NSColor lightGrayColor] set];
NSFrameRect([self bounds]);
}
@end

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

@ -187,7 +187,7 @@ typedef enum
- (void)focusURLBar;
- (void)unblockAllPopupSites:(nsISupportsArray*)inSites;
- (void)unblockAllPopupSites:(nsIArray*)inSites;
- (void)performAppropriateLocationAction;
- (IBAction)goToLocationFromToolbarURLField:(id)sender;

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

@ -42,7 +42,8 @@
@class ToolTip;
@class AutoCompleteTextField;
class nsISupportsArray;
class nsIMutableArray;
class nsIArray;
//
// The BrowserWrapper communicates with the UI via this delegate.
@ -65,7 +66,7 @@ class nsISupportsArray;
- (void)showPopupBlocked:(BOOL)blocked;
- (void)configurePopupBlocking;
- (void)unblockAllPopupSites:(nsISupportsArray*)inSites;
- (void)unblockAllPopupSites:(nsIArray*)inSites;
- (void)showSecurityState:(unsigned long)state;
- (BOOL)userChangedLocationField;
@ -138,9 +139,9 @@ class nsISupportsArray;
NSString* mTitle;
// the title we use for the tab. This differs for mTitle when the tab is loading
NSString* mTabTitle;
// array of sites that have blocked popups. If nil, no sites are blocked. Cleared
// after each new page.
nsISupportsArray* mBlockedSites; // STRONG
// array of popupevents that have been blocked. We can use them to reconstruct the popups
// later. If nil, no sites are blocked. Cleared after each new page.
nsIMutableArray* mBlockedSites;
CHBrowserView* mBrowserView; // retained
NSString* mDefaultStatusString;
@ -194,7 +195,6 @@ class nsISupportsArray;
- (NSString*)getCurrentURI;
- (void)getBlockedSites:(nsISupportsArray**)outSites;
- (IBAction)configurePopupBlocking:(id)sender;
- (IBAction)unblockPopupSites:(id)sender;
- (IBAction)hideBlockedPopupView:(id)sender;

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

@ -55,7 +55,8 @@
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsIMutableArray.h"
#include "nsIArray.h"
#include "nsIURI.h"
#include "nsIIOService.h"
#include "nsIDocument.h"
@ -71,6 +72,7 @@
#include "nsIWebProgressListener.h"
#include "nsIBrowserDOMWindow.h"
class nsIDOMPopupBlockedEvent;
static NSString* const kOfflineNotificationName = @"offlineModeChanged";
@ -134,7 +136,6 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
mListenersAttached = NO;
mSecureState = nsIWebProgressListener::STATE_IS_INSECURE;
mProgress = 0.0;
mBlockedSites = nsnull;
BOOL gotPref;
BOOL pluginsEnabled = [[PreferenceManager sharedInstance] getBooleanPref:"camino.enable_plugins" withSuccess:&gotPref];
@ -317,7 +318,7 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
if (!mBlockedSites) return NO;
PRUint32 numBlocked = 0;
mBlockedSites->Count(&numBlocked);
mBlockedSites->GetLength(&numBlocked);
return (numBlocked > 0);
}
@ -526,7 +527,8 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
{
// defer hiding of blocked popup view until we've loaded the new page
[self removeBlockedPopupViewAndDisplay];
NS_IF_RELEASE(mBlockedSites);
if(mBlockedSites)
mBlockedSites->Clear();
[mDelegate showPopupBlocked:NO];
NSString* faviconURI = [SiteIconProvider defaultFaviconLocationStringFromURI:urlSpec];
@ -708,18 +710,18 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
//
// - onPopupBlocked:fromSite:
//
// Called when gecko blocks a popup, telling us who it came from. Keep track
// of the blocked URI so we can allow the user to unblock the site later. This
// Called when gecko blocks a popup, telling us who it came from, the modifiers of the popup
// and more data that we'll need if the user wants to unblock the popup later. This
// doesn't show the blocked popup view, we wait until the page finishes loading
// to do that.
//
- (void)onPopupBlocked:(nsIURI*)inURIBlocked fromSite:(nsIURI*)inSite
- (void)onPopupBlocked:(nsIDOMPopupBlockedEvent*)eventData;
{
// lazily instantiate.
if (!mBlockedSites)
NS_NewISupportsArray(&mBlockedSites);
CallCreateInstance(NS_ARRAY_CONTRACTID, &mBlockedSites);
if (mBlockedSites) {
mBlockedSites->AppendElement(inSite);
mBlockedSites->AppendElement((nsISupports*)eventData, PR_FALSE);
[mDelegate showPopupBlocked:YES];
}
}
@ -1046,14 +1048,6 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
return [[self getBrowserView] currentCharset];
}
- (void)getBlockedSites:(nsISupportsArray**)outSites
{
if ( !outSites )
return;
*outSites = mBlockedSites;
NS_IF_ADDREF(*outSites);
}
//
// -configurePopupBlocking:
//
@ -1077,7 +1071,8 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
{
NS_ASSERTION([self popupsBlocked], "no popups to unblock!");
if ([self popupsBlocked]) {
[mDelegate unblockAllPopupSites:mBlockedSites];
nsCOMPtr<nsIArray> blockedSites = do_QueryInterface(mBlockedSites);
[mDelegate unblockAllPopupSites:blockedSites];
[self removeBlockedPopupViewAndDisplay];
}
}

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

@ -1111,7 +1111,7 @@ KeychainFormSubmitObserver::CheckChangeDataYN(nsIDOMWindowInternal* window)
{
}
- (void)onPopupBlocked:(nsIURI*)inURIBlocked fromSite:(nsIURI*)inSite
- (void)onPopupBlocked:(nsIDOMPopupBlockedEvent*)data;
{
}

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

@ -769,13 +769,10 @@ CHBrowserListener::HandleEvent(nsIDOMEvent* inEvent)
nsresult
CHBrowserListener::HandleBlockedPopupEvent(nsIDOMEvent* inEvent)
{
nsCOMPtr<nsIDOMPopupBlockedEvent> blockEvent = do_QueryInterface(inEvent);
if (blockEvent) {
nsCOMPtr<nsIURI> blockedURI, blockedSite;
blockEvent->GetPopupWindowURI(getter_AddRefs(blockedURI));
blockEvent->GetRequestingWindowURI(getter_AddRefs(blockedSite));
[mContainer onPopupBlocked:blockedURI fromSite:blockedSite];
}
nsCOMPtr<nsIDOMPopupBlockedEvent> blockedPopupEvent = do_QueryInterface(inEvent);
if (blockedPopupEvent)
[mContainer onPopupBlocked:blockedPopupEvent];
return NS_OK;
}

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

@ -50,7 +50,9 @@
class CHBrowserListener;
class nsIDOMWindow;
class nsIWebBrowser;
class nsIDocShell;
class nsIDOMNode;
class nsIDOMPopupBlockedEvent;
class nsIDOMEvent;
class nsIEventSink;
class nsIDragHelperService;
@ -82,7 +84,7 @@ class nsISecureBrowserUI;
- (void)onShowTooltip:(NSPoint)where withText:(NSString*)text;
- (void)onHideTooltip;
// Called when a popup is blocked
- (void)onPopupBlocked:(nsIURI*)inURIBlocked fromSite:(nsIURI*)inSite;
- (void)onPopupBlocked:(nsIDOMPopupBlockedEvent*)data;
// Called when a "shortcut icon" link element is noticed
- (void)onFoundShortcutIcon:(NSString*)inIconURI;
@ -282,6 +284,8 @@ typedef enum {
- (already_AddRefed<nsISupports>)getPageDescriptor;
- (void)setPageDescriptor:(nsISupports*)aDesc displayType:(PRUint32)aDisplayType;
- (already_AddRefed<nsIDocShell>)findDocShellForURI:(nsIURI*)aURI;
@end
#endif // __nsCocoaBrowserView_h__

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

@ -117,6 +117,8 @@ typedef unsigned int DragReference;
#include "nsICommandManager.h"
#include "nsICommandParams.h"
#include "GeckoUtils.h"
const char kPersistContractID[] = "@mozilla.org/embedding/browser/nsWebBrowserPersist;1";
const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
@ -1219,6 +1221,16 @@ const long NSFindPanelActionSetFindString = 7;
return privWin->GetDocShell();
}
// used for finding a blocked popup's docshell
// addrefs the result!
- (already_AddRefed<nsIDocShell>)findDocShellForURI:(nsIURI*)aURI
{
nsIDocShell *match;
GeckoUtils::FindDocShellForURI(aURI, [self getDocShell], &match);
return match;
}
- (id<CHBrowserContainer>)getBrowserContainer
{
// i'm not sure why this doesn't return whatever -setContainer: was called with