toolkit/components/alerts/nsXULAlerts.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c236591d9da5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsXULAlerts_h__
7 #define nsXULAlerts_h__
8
9 #include "nsHashKeys.h"
10 #include "nsInterfaceHashtable.h"
11
12 #include "nsIDOMWindow.h"
13 #include "nsIObserver.h"
14
15 class nsXULAlerts {
16 friend class nsXULAlertObserver;
17 public:
18 nsXULAlerts()
19 {
20 }
21
22 virtual ~nsXULAlerts() {}
23
24 nsresult ShowAlertNotification(const nsAString& aImageUrl, const nsAString& aAlertTitle,
25 const nsAString& aAlertText, bool aAlertTextClickable,
26 const nsAString& aAlertCookie, nsIObserver* aAlertListener,
27 const nsAString& aAlertName, const nsAString& aBidi,
28 const nsAString& aLang);
29
30 nsresult CloseAlert(const nsAString& aAlertName);
31 protected:
32 nsInterfaceHashtable<nsStringHashKey, nsIDOMWindow> mNamedWindows;
33 };
34
35 /**
36 * This class wraps observers for alerts and watches
37 * for the "alertfinished" event in order to release
38 * the reference on the nsIDOMWindow of the XUL alert.
39 */
40 class nsXULAlertObserver : public nsIObserver {
41 public:
42 NS_DECL_ISUPPORTS
43 NS_DECL_NSIOBSERVER
44
45 nsXULAlertObserver(nsXULAlerts* aXULAlerts, const nsAString& aAlertName,
46 nsIObserver* aObserver)
47 : mXULAlerts(aXULAlerts), mAlertName(aAlertName),
48 mObserver(aObserver) {}
49
50 void SetAlertWindow(nsIDOMWindow* aWindow) { mAlertWindow = aWindow; }
51
52 virtual ~nsXULAlertObserver() {}
53 protected:
54 nsXULAlerts* mXULAlerts;
55 nsString mAlertName;
56 nsCOMPtr<nsIDOMWindow> mAlertWindow;
57 nsCOMPtr<nsIObserver> mObserver;
58 };
59
60 #endif /* nsXULAlerts_h__ */
61

mercurial