From 4c983992d6bbbb01912a4ab94371eb7dacadd7b7 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Tue, 8 Apr 2003 20:47:18 +0000 Subject: [PATCH] add url of window to be opened to nsIWindowCreator2::CreateChromeWindow2. bug 195992 r=adamlock,blizzard git-svn-id: svn://10.0.0.236/trunk@140857 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/embedding/base/nsIWindowCreator2.idl | 22 ++++++++++++++----- .../powerplant/source/CWindowCreator.cpp | 4 ++++ .../windowwatcher/src/nsWindowWatcher.cpp | 8 ++++++- mozilla/xpfe/bootstrap/nsWindowCreator.cpp | 16 +++++++++----- mozilla/xpfe/bootstrap/nsWindowCreator.h | 2 -- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/mozilla/embedding/base/nsIWindowCreator2.idl b/mozilla/embedding/base/nsIWindowCreator2.idl index 1a22c756ff6..9a1b1d84980 100644 --- a/mozilla/embedding/base/nsIWindowCreator2.idl +++ b/mozilla/embedding/base/nsIWindowCreator2.idl @@ -32,6 +32,7 @@ #include "nsIWindowCreator.idl" +interface nsIURI; interface nsIWebBrowserChrome; // This interface is not generally scriptable: only the const(s) @@ -49,16 +50,27 @@ interface nsIWindowCreator2 : nsIWindowCreator { /** Create a new window. Gecko will/may call this method, if made available to it, to create new windows. - @param parent parent window, if any. null if not. the newly created + @param parent Parent window, if any. Null if not. The newly created window should be made a child/dependent window of the parent, if any (and if the concept applies to the underlying OS). - @param chromeFlags chrome features from nsIWebBrowserChrome - @param contextFlags flags about the context of the window being created. - @return the new window + @param chromeFlags Chrome features from nsIWebBrowserChrome + @param contextFlags Flags about the context of the window being created. + @param uri The URL for which this window is intended. It can be null + or zero-length. The implementation of this interface + may use the URL to help determine what sort of window + to open or whether to cancel window creation. It will not + load the URL. + @param cancel Return |true| to reject window creation. If true the + implementation has determined the window should not + be created at all. The caller should not default + to any possible backup scheme for creating the window. + @return the new window. Will be null if canceled or an error occurred. */ [noscript] nsIWebBrowserChrome createChromeWindow2(in nsIWebBrowserChrome parent, in PRUint32 chromeFlags, - in PRUint32 contextFlags); + in PRUint32 contextFlags, + in nsIURI uri, + out boolean cancel); }; diff --git a/mozilla/embedding/browser/powerplant/source/CWindowCreator.cpp b/mozilla/embedding/browser/powerplant/source/CWindowCreator.cpp index cc524e4bb96..88074eadcf7 100644 --- a/mozilla/embedding/browser/powerplant/source/CWindowCreator.cpp +++ b/mozilla/embedding/browser/powerplant/source/CWindowCreator.cpp @@ -42,6 +42,7 @@ #include "nsIServiceManagerUtils.h" #include "nsIWebBrowserSetup.h" #include "nsIPrefBranch.h" +#include "nsIURI.h" #include "CBrowserShell.h" #include "CBrowserWindow.h" @@ -85,8 +86,11 @@ NS_IMETHODIMP CWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent, NS_IMETHODIMP CWindowCreator::CreateChromeWindow2(nsIWebBrowserChrome *parent, PRUint32 chromeFlags, PRUint32 contextFlags, + nsIURI *aURI, PRBool *aCancel, nsIWebBrowserChrome **_retval) { + NS_ENSURE_ARG_POINTER(aCancel); + *aCancel = PR_FALSE; if (contextFlags & nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT) { nsCOMPtr prefs(do_GetService("@mozilla.org/preferences-service;1")); if (prefs) { diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 361fe61ab96..d735c4eb01e 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -610,8 +610,14 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent, if (popupConditions) contextFlags |= nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT; + PRBool cancel = PR_FALSE; rv = windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags, - contextFlags, getter_AddRefs(newChrome)); + contextFlags, uriToLoad, &cancel, + getter_AddRefs(newChrome)); + if (NS_SUCCEEDED(rv) && cancel) { + newChrome = 0; // just in case + rv = NS_ERROR_ABORT; + } } else rv = mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags, diff --git a/mozilla/xpfe/bootstrap/nsWindowCreator.cpp b/mozilla/xpfe/bootstrap/nsWindowCreator.cpp index 8adb503ab23..57c49b48dd9 100644 --- a/mozilla/xpfe/bootstrap/nsWindowCreator.cpp +++ b/mozilla/xpfe/bootstrap/nsWindowCreator.cpp @@ -74,6 +74,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIServiceManager.h" +#include "nsIURI.h" #include "nsIXULWindow.h" #include "nsIWebBrowserChrome.h" @@ -92,16 +93,21 @@ nsWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent, PRUint32 aChromeFlags, nsIWebBrowserChrome **_retval) { - return CreateChromeWindow2(aParent, aChromeFlags, 0, _retval); + PRBool cancel; + return CreateChromeWindow2(aParent, aChromeFlags, 0, 0, &cancel, _retval); } NS_IMETHODIMP -nsWindowCreator::CreateChromeWindow2(nsIWebBrowserChrome *aParent, - PRUint32 aChromeFlags, - PRUint32 aContextFlags, - nsIWebBrowserChrome **_retval) +nsWindowCreator::CreateChromeWindow2( nsIWebBrowserChrome *aParent, + PRUint32 aChromeFlags, + PRUint32 aContextFlags, + nsIURI *aURI, + PRBool *aCancel, + nsIWebBrowserChrome **_retval) { + NS_ENSURE_ARG_POINTER(aCancel); NS_ENSURE_ARG_POINTER(_retval); + *aCancel = PR_FALSE; *_retval = 0; nsCOMPtr newWindow; diff --git a/mozilla/xpfe/bootstrap/nsWindowCreator.h b/mozilla/xpfe/bootstrap/nsWindowCreator.h index fe0857aa080..0d7fbe568f5 100644 --- a/mozilla/xpfe/bootstrap/nsWindowCreator.h +++ b/mozilla/xpfe/bootstrap/nsWindowCreator.h @@ -40,8 +40,6 @@ #include "nsIWindowCreator2.h" -class nsIURI; - class nsWindowCreator : public nsIWindowCreator2 {