tor-browser

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

ColorPickerParent.h (1876B)


      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_ColorPickerParent_h
      8 #define mozilla_dom_ColorPickerParent_h
      9 
     10 #include "mozilla/dom/PColorPickerParent.h"
     11 #include "nsIColorPicker.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 class ColorPickerParent : public PColorPickerParent {
     16 public:
     17  ColorPickerParent(BrowsingContext* aBrowsingContext, const nsString& aTitle,
     18                    const nsString& aInitialColor,
     19                    const nsTArray<nsString>& aDefaultColors)
     20      : mBrowsingContext(aBrowsingContext),
     21        mTitle(aTitle),
     22        mInitialColor(aInitialColor),
     23        mDefaultColors(aDefaultColors.Clone()) {}
     24 
     25  NS_INLINE_DECL_REFCOUNTING(ColorPickerParent, final)
     26 
     27  virtual mozilla::ipc::IPCResult RecvOpen() override;
     28  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
     29 
     30  class ColorPickerShownCallback final : public nsIColorPickerShownCallback {
     31   public:
     32    explicit ColorPickerShownCallback(ColorPickerParent* aColorPickerParnet)
     33        : mColorPickerParent(aColorPickerParnet) {}
     34 
     35    NS_DECL_ISUPPORTS
     36    NS_DECL_NSICOLORPICKERSHOWNCALLBACK
     37 
     38    void Destroy();
     39 
     40   private:
     41    ~ColorPickerShownCallback() = default;
     42    RefPtr<ColorPickerParent> mColorPickerParent;
     43  };
     44 
     45 private:
     46  virtual ~ColorPickerParent() = default;
     47 
     48  bool CreateColorPicker();
     49 
     50  RefPtr<BrowsingContext> mBrowsingContext;
     51  RefPtr<ColorPickerShownCallback> mCallback;
     52  nsCOMPtr<nsIColorPicker> mPicker;
     53 
     54  nsString mTitle;
     55  nsString mInitialColor;
     56  nsTArray<nsString> mDefaultColors;
     57 };
     58 
     59 }  // namespace mozilla::dom
     60 
     61 #endif  // mozilla_dom_ColorPickerParent_h