CloseWatcherManager.h (1356B)
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 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_CloseWatcherManager_h 8 #define mozilla_dom_CloseWatcherManager_h 9 10 #include "nsCycleCollectionParticipant.h" 11 #include "nsISupportsImpl.h" 12 #include "nsTObserverArray.h" 13 14 namespace mozilla::dom { 15 16 class CloseWatcher; 17 18 using CloseWatcherArray = 19 nsTObserverArray<nsTObserverArray<RefPtr<CloseWatcher>>>; 20 21 class CloseWatcherManager : public nsISupports { 22 public: 23 CloseWatcherManager() = default; 24 25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 26 NS_DECL_CYCLE_COLLECTION_CLASS(CloseWatcherManager) 27 28 void NotifyUserInteraction(); 29 30 MOZ_CAN_RUN_SCRIPT bool ProcessCloseRequest(); 31 32 void Add(CloseWatcher&); 33 34 void Remove(CloseWatcher&); 35 36 bool Contains(const CloseWatcher&) const; 37 38 bool CanGrow() const; 39 40 bool IsEmpty() const { return mGroups.IsEmpty(); } 41 42 protected: 43 virtual ~CloseWatcherManager() = default; 44 45 CloseWatcherArray mGroups; 46 uint32_t mAllowedNumberOfGroups = 1; 47 bool mNextUserInteractionAllowsNewGroup = true; 48 }; 49 50 } // namespace mozilla::dom 51 52 #endif // mozilla_dom_CloseWatcherManager_h