michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsXULAlerts_h__ michael@0: #define nsXULAlerts_h__ michael@0: michael@0: #include "nsHashKeys.h" michael@0: #include "nsInterfaceHashtable.h" michael@0: michael@0: #include "nsIDOMWindow.h" michael@0: #include "nsIObserver.h" michael@0: michael@0: class nsXULAlerts { michael@0: friend class nsXULAlertObserver; michael@0: public: michael@0: nsXULAlerts() michael@0: { michael@0: } michael@0: michael@0: virtual ~nsXULAlerts() {} michael@0: michael@0: nsresult ShowAlertNotification(const nsAString& aImageUrl, const nsAString& aAlertTitle, michael@0: const nsAString& aAlertText, bool aAlertTextClickable, michael@0: const nsAString& aAlertCookie, nsIObserver* aAlertListener, michael@0: const nsAString& aAlertName, const nsAString& aBidi, michael@0: const nsAString& aLang); michael@0: michael@0: nsresult CloseAlert(const nsAString& aAlertName); michael@0: protected: michael@0: nsInterfaceHashtable mNamedWindows; michael@0: }; michael@0: michael@0: /** michael@0: * This class wraps observers for alerts and watches michael@0: * for the "alertfinished" event in order to release michael@0: * the reference on the nsIDOMWindow of the XUL alert. michael@0: */ michael@0: class nsXULAlertObserver : public nsIObserver { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIOBSERVER michael@0: michael@0: nsXULAlertObserver(nsXULAlerts* aXULAlerts, const nsAString& aAlertName, michael@0: nsIObserver* aObserver) michael@0: : mXULAlerts(aXULAlerts), mAlertName(aAlertName), michael@0: mObserver(aObserver) {} michael@0: michael@0: void SetAlertWindow(nsIDOMWindow* aWindow) { mAlertWindow = aWindow; } michael@0: michael@0: virtual ~nsXULAlertObserver() {} michael@0: protected: michael@0: nsXULAlerts* mXULAlerts; michael@0: nsString mAlertName; michael@0: nsCOMPtr mAlertWindow; michael@0: nsCOMPtr mObserver; michael@0: }; michael@0: michael@0: #endif /* nsXULAlerts_h__ */ michael@0: