Bug 1769952 - Fix running raptor on a Win10-64 VM r=sparky
[gecko.git] / dom / commandhandler / nsCommandManager.h
blob77a10e5f3517427e63c547e4ceba38f37cfe4324
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/. */
7 #ifndef nsCommandManager_h__
8 #define nsCommandManager_h__
10 #include "nsString.h"
11 #include "nsClassHashtable.h"
12 #include "nsWeakReference.h"
14 #include "nsICommandManager.h"
15 #include "nsCycleCollectionParticipant.h"
17 class nsIController;
18 template <class E>
19 class nsCOMArray;
21 class nsCommandManager final : public nsICommandManager,
22 public nsSupportsWeakReference {
23 public:
24 using ObserverList = nsTArray<nsCOMPtr<nsIObserver>>;
26 nsCommandManager() = delete;
28 /**
29 * @param aWindow An window which is what this command manager lives on.
31 explicit nsCommandManager(mozIDOMWindowProxy* aWindow);
33 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
34 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCommandManager, nsICommandManager)
36 NS_DECL_NSICOMMANDMANAGER
38 /**
39 * Notify the command manager that the status of a command changed. It may
40 * have changed from enabled to disabled, or vice versa, or become toggled
41 * etc.
43 void CommandStatusChanged(const char* aCommandName);
45 bool IsCommandEnabled(const nsCString& aCommandName,
46 mozIDOMWindowProxy* aTargetWindow);
48 protected:
49 virtual ~nsCommandManager();
51 nsresult GetControllerForCommand(const char* aCommand,
52 mozIDOMWindowProxy* aDirectedToThisWindow,
53 nsIController** aResult);
55 protected:
56 nsClassHashtable<nsCharPtrHashKey, ObserverList> mObserversTable;
58 mozIDOMWindowProxy* mWindow; // weak ptr. The window should always outlive us
61 nsCommandManager* nsICommandManager::AsCommandManager() {
62 return static_cast<nsCommandManager*>(this);
65 const nsCommandManager* nsICommandManager::AsCommandManager() const {
66 return static_cast<const nsCommandManager*>(this);
69 #endif // nsCommandManager_h__