PluginWidgetProxy.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef mozilla_widget_RemotePlugin_h__
  5. #define mozilla_widget_RemotePlugin_h__
  6. #include "PuppetWidget.h"
  7. #include "mozilla/dom/TabChild.h"
  8. /*
  9. * PluginWidgetProxy is a nsIWidget wrapper we hand around in plugin and layout
  10. * code. It wraps a native widget it creates in the chrome process. Since this
  11. * is for plugins, only a limited set of the widget apis need to be overridden,
  12. * the rest of the implementation is in PuppetWidget or nsBaseWidget.
  13. */
  14. namespace mozilla {
  15. namespace plugins {
  16. class PluginWidgetChild;
  17. } // namespace plugins
  18. namespace widget {
  19. class PluginWidgetProxy final : public PuppetWidget
  20. {
  21. public:
  22. explicit PluginWidgetProxy(dom::TabChild* aTabChild,
  23. mozilla::plugins::PluginWidgetChild* aChannel);
  24. protected:
  25. virtual ~PluginWidgetProxy();
  26. public:
  27. NS_DECL_ISUPPORTS_INHERITED
  28. // nsIWidget
  29. using PuppetWidget::Create; // for Create signature not overridden here
  30. virtual MOZ_MUST_USE nsresult Create(nsIWidget* aParent,
  31. nsNativeWidget aNativeParent,
  32. const LayoutDeviceIntRect& aRect,
  33. nsWidgetInitData* aInitData = nullptr)
  34. override;
  35. virtual void Destroy() override;
  36. NS_IMETHOD SetFocus(bool aRaise = false) override;
  37. NS_IMETHOD SetParent(nsIWidget* aNewParent) override;
  38. virtual nsIWidget* GetParent(void) override;
  39. virtual void* GetNativeData(uint32_t aDataType) override;
  40. #if defined(XP_WIN)
  41. void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
  42. #endif
  43. virtual nsTransparencyMode GetTransparencyMode() override
  44. { return eTransparencyOpaque; }
  45. virtual void GetWindowClipRegion(nsTArray<LayoutDeviceIntRect>* aRects) override;
  46. public:
  47. /**
  48. * When tabs are closed PPluginWidget can terminate before plugin code is
  49. * finished tearing us down. When this happens plugin calls over mActor
  50. * fail triggering an abort in the content process. To protect against this
  51. * the connection tells us when it is torn down here so we can avoid making
  52. * calls while content finishes tearing us down.
  53. */
  54. void ChannelDestroyed() { mActor = nullptr; }
  55. private:
  56. // Our connection with the chrome widget, created on PBrowser.
  57. mozilla::plugins::PluginWidgetChild* mActor;
  58. // PuppetWidget does not implement parent apis, but we need
  59. // them for plugin widgets.
  60. nsCOMPtr<nsIWidget> mParent;
  61. uintptr_t mCachedPluginPort;
  62. };
  63. } // namespace widget
  64. } // namespace mozilla
  65. #endif