michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 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 nsAutoCopyListener_h_ michael@0: #define nsAutoCopyListener_h_ michael@0: michael@0: #include "nsISelectionListener.h" michael@0: #include "nsISelectionPrivate.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsAutoCopyListener MOZ_FINAL : public nsISelectionListener michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSISELECTIONLISTENER michael@0: michael@0: void Listen(nsISelectionPrivate *aSelection) michael@0: { michael@0: NS_ASSERTION(aSelection, "Null selection passed to Listen()"); michael@0: aSelection->AddSelectionListener(this); michael@0: } michael@0: michael@0: static nsAutoCopyListener* GetInstance() michael@0: { michael@0: if (!sInstance) { michael@0: sInstance = new nsAutoCopyListener(); michael@0: michael@0: NS_ADDREF(sInstance); michael@0: } michael@0: michael@0: return sInstance; michael@0: } michael@0: michael@0: static void Shutdown() michael@0: { michael@0: NS_IF_RELEASE(sInstance); michael@0: } michael@0: michael@0: private: michael@0: static nsAutoCopyListener* sInstance; michael@0: }; michael@0: michael@0: #endif