ColorPickerParent.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_ColorPickerParent_h
  6. #define mozilla_dom_ColorPickerParent_h
  7. #include "mozilla/dom/PColorPickerParent.h"
  8. #include "nsIColorPicker.h"
  9. namespace mozilla {
  10. namespace dom {
  11. class ColorPickerParent : public PColorPickerParent
  12. {
  13. public:
  14. ColorPickerParent(const nsString& aTitle,
  15. const nsString& aInitialColor)
  16. : mTitle(aTitle)
  17. , mInitialColor(aInitialColor)
  18. {}
  19. virtual bool RecvOpen() override;
  20. virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  21. class ColorPickerShownCallback final
  22. : public nsIColorPickerShownCallback
  23. {
  24. public:
  25. explicit ColorPickerShownCallback(ColorPickerParent* aColorPickerParnet)
  26. : mColorPickerParent(aColorPickerParnet)
  27. {}
  28. NS_DECL_ISUPPORTS
  29. NS_DECL_NSICOLORPICKERSHOWNCALLBACK
  30. void Destroy();
  31. private:
  32. ~ColorPickerShownCallback() {}
  33. ColorPickerParent* mColorPickerParent;
  34. };
  35. private:
  36. virtual ~ColorPickerParent() {}
  37. bool CreateColorPicker();
  38. RefPtr<ColorPickerShownCallback> mCallback;
  39. nsCOMPtr<nsIColorPicker> mPicker;
  40. nsString mTitle;
  41. nsString mInitialColor;
  42. };
  43. } // namespace dom
  44. } // namespace mozilla
  45. #endif // mozilla_dom_ColorPickerParent_h