PermissionObserver.h (1134B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_PermissionObserver_h_ 8 #define mozilla_dom_PermissionObserver_h_ 9 10 #include "nsIObserver.h" 11 #include "nsTArray.h" 12 #include "nsWeakReference.h" 13 14 namespace mozilla::dom { 15 16 class PermissionStatusSink; 17 18 // Singleton that watches for perm-changed notifications in order to notify 19 // PermissionStatus objects. 20 class PermissionObserver final : public nsIObserver, 21 public nsSupportsWeakReference { 22 public: 23 NS_DECL_ISUPPORTS 24 NS_DECL_NSIOBSERVER 25 26 static already_AddRefed<PermissionObserver> GetInstance(); 27 28 void AddSink(PermissionStatusSink* aSink); 29 void RemoveSink(PermissionStatusSink* aSink); 30 31 private: 32 PermissionObserver(); 33 virtual ~PermissionObserver(); 34 35 nsTArray<RefPtr<PermissionStatusSink>> mSinks; 36 }; 37 38 } // namespace mozilla::dom 39 40 #endif