tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsControllerCommandTable.h (1777B)


      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 nsControllerCommandTable_h_
      8 #define nsControllerCommandTable_h_
      9 
     10 #include "nsHashKeys.h"
     11 #include "nsISupportsImpl.h"
     12 #include "nsRefPtrHashtable.h"
     13 
     14 namespace mozilla {
     15 class ControllerCommand;
     16 }
     17 
     18 class nsICommandParams;
     19 
     20 class nsControllerCommandTable final {
     21 public:
     22  nsControllerCommandTable();
     23 
     24  NS_INLINE_DECL_REFCOUNTING(nsControllerCommandTable);
     25 
     26  static nsControllerCommandTable* EditorCommandTable();
     27  static nsControllerCommandTable* EditingCommandTable();
     28  static nsControllerCommandTable* HTMLEditorCommandTable();
     29  static nsControllerCommandTable* HTMLEditorDocStateCommandTable();
     30  static nsControllerCommandTable* WindowCommandTable();
     31 
     32  void RegisterCommand(const nsACString&, mozilla::ControllerCommand*);
     33  void UnregisterCommand(const nsACString&, mozilla::ControllerCommand*);
     34  mozilla::ControllerCommand* FindCommandHandler(const nsACString&) const;
     35  bool IsCommandEnabled(const nsACString&, nsISupports* aContext) const;
     36  bool SupportsCommand(const nsACString& aName) const {
     37    return !!FindCommandHandler(aName);
     38  }
     39  void MakeImmutable() { mMutable = false; }
     40  void GetSupportedCommands(nsTArray<nsCString>&) const;
     41 
     42 private:
     43  ~nsControllerCommandTable();
     44  // Hash table of nsIControllerCommands, keyed by command name.
     45  nsRefPtrHashtable<nsCStringHashKey, mozilla::ControllerCommand>
     46      mCommandsTable;
     47 
     48  // Are we mutable?
     49  bool mMutable = true;
     50 };
     51 
     52 #endif  // nsControllerCommandTable_h_