1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/alerts/nsXULAlerts.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsXULAlerts_h__ 1.10 +#define nsXULAlerts_h__ 1.11 + 1.12 +#include "nsHashKeys.h" 1.13 +#include "nsInterfaceHashtable.h" 1.14 + 1.15 +#include "nsIDOMWindow.h" 1.16 +#include "nsIObserver.h" 1.17 + 1.18 +class nsXULAlerts { 1.19 + friend class nsXULAlertObserver; 1.20 +public: 1.21 + nsXULAlerts() 1.22 + { 1.23 + } 1.24 + 1.25 + virtual ~nsXULAlerts() {} 1.26 + 1.27 + nsresult ShowAlertNotification(const nsAString& aImageUrl, const nsAString& aAlertTitle, 1.28 + const nsAString& aAlertText, bool aAlertTextClickable, 1.29 + const nsAString& aAlertCookie, nsIObserver* aAlertListener, 1.30 + const nsAString& aAlertName, const nsAString& aBidi, 1.31 + const nsAString& aLang); 1.32 + 1.33 + nsresult CloseAlert(const nsAString& aAlertName); 1.34 +protected: 1.35 + nsInterfaceHashtable<nsStringHashKey, nsIDOMWindow> mNamedWindows; 1.36 +}; 1.37 + 1.38 +/** 1.39 + * This class wraps observers for alerts and watches 1.40 + * for the "alertfinished" event in order to release 1.41 + * the reference on the nsIDOMWindow of the XUL alert. 1.42 + */ 1.43 +class nsXULAlertObserver : public nsIObserver { 1.44 +public: 1.45 + NS_DECL_ISUPPORTS 1.46 + NS_DECL_NSIOBSERVER 1.47 + 1.48 + nsXULAlertObserver(nsXULAlerts* aXULAlerts, const nsAString& aAlertName, 1.49 + nsIObserver* aObserver) 1.50 + : mXULAlerts(aXULAlerts), mAlertName(aAlertName), 1.51 + mObserver(aObserver) {} 1.52 + 1.53 + void SetAlertWindow(nsIDOMWindow* aWindow) { mAlertWindow = aWindow; } 1.54 + 1.55 + virtual ~nsXULAlertObserver() {} 1.56 +protected: 1.57 + nsXULAlerts* mXULAlerts; 1.58 + nsString mAlertName; 1.59 + nsCOMPtr<nsIDOMWindow> mAlertWindow; 1.60 + nsCOMPtr<nsIObserver> mObserver; 1.61 +}; 1.62 + 1.63 +#endif /* nsXULAlerts_h__ */ 1.64 +