tor-browser

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

nsBaseCommandController.h (1908B)


      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 nsBaseCommandController_h__
      8 #define nsBaseCommandController_h__
      9 
     10 #include "nsIController.h"
     11 #include "nsIWeakReferenceUtils.h"
     12 
     13 #define NS_BASECOMMANDCONTROLLER_IID \
     14  {0xd749fad0, 0xccf1, 0x4972, {0xb9, 0xa3, 0xd4, 0x1b, 0xaf, 0xee, 0xf1, 0xb7}}
     15 
     16 class nsControllerCommandTable;
     17 
     18 // The base editor controller is used for both text widgets, and all other text
     19 // and html editing
     20 class nsBaseCommandController final : public nsIController,
     21                                      public nsICommandController {
     22 public:
     23  explicit nsBaseCommandController(nsControllerCommandTable*);
     24  void SetContext(nsISupportsWeakReference* aContext) {
     25    mContext = do_GetWeakReference(aContext);
     26  }
     27 
     28  NS_DECL_ISUPPORTS
     29  NS_DECL_NSICONTROLLER
     30  NS_DECL_NSICOMMANDCONTROLLER
     31  NS_INLINE_DECL_STATIC_IID(NS_BASECOMMANDCONTROLLER_IID)
     32 
     33  static already_AddRefed<nsBaseCommandController> CreateWindowController();
     34  static already_AddRefed<nsBaseCommandController> CreateEditorController();
     35  static already_AddRefed<nsBaseCommandController> CreateEditingController();
     36  static already_AddRefed<nsBaseCommandController> CreateHTMLEditorController();
     37  static already_AddRefed<nsBaseCommandController>
     38  CreateHTMLEditorDocStateController();
     39 
     40 protected:
     41  virtual ~nsBaseCommandController();
     42 
     43 private:
     44  nsWeakPtr mContext;
     45 
     46  // Our reference to the command manager
     47  RefPtr<nsControllerCommandTable> mCommandTable;
     48 };
     49 
     50 inline nsISupports* ToSupports(nsBaseCommandController* aController) {
     51  return static_cast<nsIController*>(aController);
     52 }
     53 
     54 #endif /* nsBaseCommandController_h_ */