Bug 267089 Remove nsIAlertListener from toolkit

patch by Alexander Opitz <opi@gmx.at> r=mconnor
This commit is contained in:
cbiesinger%web.de 2004-12-12 16:46:33 +00:00
parent d14ec825d5
commit 53359bb38a
5 changed files with 29 additions and 63 deletions

View File

@ -38,31 +38,26 @@
#include "nsISupports.idl"
#include "nsIObserver.idl"
/* nsIAlertsListener --> when a consumer asks the alerts service to put up an alert, they have the option
of passing in an alert listener as well. The alert listener gets notified when the alert has gone away.
*/
[scriptable, uuid(A840623B-5B87-4e99-A74A-9EF0886C11DD)]
interface nsIAlertListener : nsISupports
{
void onAlertFinished(in wstring aAlertCookie);
void onAlertClickCallback(in wstring aAlertCookie); // if the user clicks on the link and you wanted notified....
};
[scriptable, uuid(7E8B76C6-A70C-4075-81AA-D48B6152E1B4)]
[scriptable, uuid(F6D34CCE-EAC6-42BF-8F3B-9A8865493F31)]
interface nsIAlertsService : nsISupports
{
/* showAlertNotification: shows an animated alert icon
aImageUrl --> a url identifying an image to put in the alert.
aAlertTitle --> the title text for the alert (i.e. You have New Mail)
aAlertText --> the contents of the alert
alertTextClickable --> set to true if you wish to be notified if the user attempts to click
the alert text. Also causes the alert text to look like a link.
aAlertCookie --> a blind cookie the alert will pass back to the consumer during the alert listener callbacks
aAlertTitle --> the title text for the alert (i.e. You have New Mail)
aAlertText --> the contents of the alert
alertTextClickable --> set to true if you wish to be notified if the user attempts to click
the alert text. Also causes the alert text to look like a link.
aAlertCookie --> a blind cookie the alert will pass back to the consumer
during the alert listener callbacks
aAlertListener --> used for callbacks. Subject is null, topic is "alertfinished" when the
alert goes away, or "alertclickcallback" when the text is clicked. Data
is aAlertCookie.
*/
void showAlertNotification(in string aImageUrl, in wstring aAlertTitle,
in wstring aAlertText, in boolean alertTextClickable,
in wstring aAlertCookie,
in nsIAlertListener aAlertListener );
in wstring aAlertCookie,
in nsIObserver aAlertListener );
};

View File

@ -53,7 +53,7 @@ function prefillAlertInfo()
// arguments[2] --> the alert text
// arguments[3] --> is the text clickable?
// arguments[4] --> the alert cookie to be passed back to the listener
// arguments[5] --> an optional callback listener (nsIAlertListener)
// arguments[5] --> an optional callback listener (nsIObserver)
document.getElementById('alertImage').setAttribute('src', window.arguments[0]);
document.getElementById('alertTitleLabel').setAttribute('value', window.arguments[1]);
@ -65,8 +65,7 @@ function prefillAlertInfo()
document.getElementById('alertTextLabel').setAttribute('clickable', true);
// the 5th argument is optional
if (window.arguments[5])
gAlertListener = window.arguments[5].QueryInterface(Components.interfaces.nsIAlertListener);
gAlertListener = window.arguments[5];
}
function onAlertLoad()
@ -117,7 +116,7 @@ function closeAlert()
else
{
if (gAlertListener)
gAlertListener.onAlertFinished(gAlertCookie);
gAlertListener.observe(null, "alertfinished", gAlertCookie);
window.close();
}
}
@ -125,5 +124,5 @@ function closeAlert()
function onAlertClick()
{
if (gAlertListener && gAlertTextClickable)
gAlertListener.onAlertClickCallback(gAlertCookie);
gAlertListener.observe(null, "alertclickcallback", gAlertCookie);
}

View File

@ -65,7 +65,7 @@ nsAlertsService::~nsAlertsService()
NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, const PRUnichar * aAlertTitle,
const PRUnichar * aAlertText, PRBool aAlertTextClickable,
const PRUnichar * aAlertCookie,
nsIAlertListener * aAlertListener)
nsIObserver * aAlertListener)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsCOMPtr<nsIDOMWindow> newWindow;
@ -113,11 +113,8 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, con
nsCOMPtr<nsISupports> iSupports (do_QueryInterface(aAlertListener));
ifptr->SetData(iSupports);
ifptr->SetDataIID(&NS_GET_IID(nsISupports));
ifptr->SetDataIID(&NS_GET_IID(nsIObserver));
argsArray->AppendElement(ifptr);
#if 0
argsArray->AppendElement(aAlertListener);
#endif
}
rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",

View File

@ -126,11 +126,7 @@ GetFilePathFromURI(nsIURI *aURI, nsAString &aPath)
///////////////////////////////////////////////////////////////////////////////
// nsDownloadManager
#ifdef XP_WIN
NS_IMPL_ISUPPORTS4(nsDownloadManager, nsIDownloadManager, nsIXPInstallManagerUI, nsIObserver, nsIAlertListener)
#else
NS_IMPL_ISUPPORTS3(nsDownloadManager, nsIDownloadManager, nsIXPInstallManagerUI, nsIObserver)
#endif
nsDownloadManager::nsDownloadManager() : mBatches(0)
{
@ -1340,6 +1336,16 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn
gStoppingDownloads = PR_FALSE;
}
}
else if (nsCRT::strcmp(aTopic, "allertclickcallback") == 0)
{
// Attempt to locate a browser window to parent the download manager to
nsCOMPtr<nsIWindowMediator> wm = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
nsCOMPtr<nsIDOMWindowInternal> browserWindow;
if (wm)
wm->GetMostRecentWindow(NS_LITERAL_STRING("navigator:browser").get(), getter_AddRefs(browserWindow));
return OpenDownloadManager(PR_TRUE, -1, nsnull, browserWindow);
}
return NS_OK;
}
@ -1411,31 +1417,6 @@ nsDownloadManager::GetHasActiveXPIOperations(PRBool* aHasOps)
return NS_OK;
}
#ifdef XP_WIN
///////////////////////////////////////////////////////////////////////////////
// nsIAlertListener
NS_IMETHODIMP
nsDownloadManager::OnAlertFinished(const PRUnichar* aAlertCookie)
{
// Nothing to do here.
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OnAlertClickCallback(const PRUnichar* aAlertCookie)
{
nsresult rv;
// Attempt to locate a browser window to parent the download manager to
nsCOMPtr<nsIWindowMediator> wm = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
nsCOMPtr<nsIDOMWindowInternal> browserWindow;
if (wm)
wm->GetMostRecentWindow(NS_LITERAL_STRING("navigator:browser").get(), getter_AddRefs(browserWindow));
return OpenDownloadManager(PR_TRUE, -1, nsnull, browserWindow);
}
#endif
///////////////////////////////////////////////////////////////////////////////
// nsXPIProgressListener

View File

@ -76,18 +76,12 @@ class nsDownload;
class nsDownloadManager : public nsIDownloadManager,
public nsIXPInstallManagerUI,
public nsIObserver
#ifdef XP_WIN
, public nsIAlertListener
#endif
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOWNLOADMANAGER
NS_DECL_NSIXPINSTALLMANAGERUI
NS_DECL_NSIOBSERVER
#ifdef XP_WIN
NS_DECL_NSIALERTLISTENER
#endif
nsresult Init();