Blame widget/PluginWidgetProxy.h

Packit f0b94e
/* This Source Code Form is subject to the terms of the Mozilla Public
Packit f0b94e
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit f0b94e
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit f0b94e
Packit f0b94e
#ifndef mozilla_widget_RemotePlugin_h__
Packit f0b94e
#define mozilla_widget_RemotePlugin_h__
Packit f0b94e
Packit f0b94e
#ifndef XP_WIN
Packit f0b94e
#error "Plugin widgets are Windows-only."
Packit f0b94e
#endif
Packit f0b94e
Packit f0b94e
#include "PuppetWidget.h"
Packit f0b94e
#include "mozilla/dom/TabChild.h"
Packit f0b94e
Packit f0b94e
/*
Packit f0b94e
 * PluginWidgetProxy is a nsIWidget wrapper we hand around in plugin and layout
Packit f0b94e
 * code. It wraps a native widget it creates in the chrome process. Since this
Packit f0b94e
 * is for plugins, only a limited set of the widget apis need to be overridden,
Packit f0b94e
 * the rest of the implementation is in PuppetWidget or nsBaseWidget.
Packit f0b94e
 */
Packit f0b94e
Packit f0b94e
namespace mozilla {
Packit f0b94e
namespace plugins {
Packit f0b94e
class PluginWidgetChild;
Packit f0b94e
}  // namespace plugins
Packit f0b94e
namespace widget {
Packit f0b94e
Packit f0b94e
class PluginWidgetProxy final : public PuppetWidget {
Packit f0b94e
 public:
Packit f0b94e
  explicit PluginWidgetProxy(dom::TabChild* aTabChild,
Packit f0b94e
                             mozilla::plugins::PluginWidgetChild* aChannel);
Packit f0b94e
Packit f0b94e
 protected:
Packit f0b94e
  virtual ~PluginWidgetProxy();
Packit f0b94e
Packit f0b94e
 public:
Packit f0b94e
  NS_DECL_ISUPPORTS_INHERITED
Packit f0b94e
Packit f0b94e
  // nsIWidget
Packit f0b94e
  using PuppetWidget::Create;  // for Create signature not overridden here
Packit f0b94e
  virtual MOZ_MUST_USE nsresult
Packit f0b94e
  Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
Packit f0b94e
         const LayoutDeviceIntRect& aRect,
Packit f0b94e
         nsWidgetInitData* aInitData = nullptr) override;
Packit f0b94e
  virtual void Destroy() override;
Packit f0b94e
  virtual nsresult SetFocus(bool aRaise = false) override;
Packit f0b94e
  virtual void SetParent(nsIWidget* aNewParent) override;
Packit f0b94e
Packit f0b94e
  virtual nsIWidget* GetParent(void) override;
Packit f0b94e
  virtual void* GetNativeData(uint32_t aDataType) override;
Packit f0b94e
  void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
Packit f0b94e
  virtual nsTransparencyMode GetTransparencyMode() override {
Packit f0b94e
    return eTransparencyOpaque;
Packit f0b94e
  }
Packit f0b94e
  virtual void GetWindowClipRegion(
Packit f0b94e
      nsTArray<LayoutDeviceIntRect>* aRects) override;
Packit f0b94e
Packit f0b94e
 public:
Packit f0b94e
  /**
Packit f0b94e
   * When tabs are closed PPluginWidget can terminate before plugin code is
Packit f0b94e
   * finished tearing us down. When this happens plugin calls over mActor
Packit f0b94e
   * fail triggering an abort in the content process. To protect against this
Packit f0b94e
   * the connection tells us when it is torn down here so we can avoid making
Packit f0b94e
   * calls while content finishes tearing us down.
Packit f0b94e
   */
Packit f0b94e
  void ChannelDestroyed() { mActor = nullptr; }
Packit f0b94e
Packit f0b94e
 private:
Packit f0b94e
  // Our connection with the chrome widget, created on PBrowser.
Packit f0b94e
  mozilla::plugins::PluginWidgetChild* mActor;
Packit f0b94e
  // PuppetWidget does not implement parent apis, but we need
Packit f0b94e
  // them for plugin widgets.
Packit f0b94e
  nsCOMPtr<nsIWidget> mParent;
Packit f0b94e
  uintptr_t mCachedPluginPort;
Packit f0b94e
};
Packit f0b94e
Packit f0b94e
}  // namespace widget
Packit f0b94e
}  // namespace mozilla
Packit f0b94e
Packit f0b94e
#endif