author Doug Thayer <dothayer@mozilla.com>
Fri, 01 Mar 2019 18:29:09 +0000
changeset 520116 8b3fe0426ffc1b3a2ad044ef6cdde6c4f736f8e2
parent 511623 5f4630838d46dd81dadb13220a4af0da9e23a619
child 529755 9813ce146bc725dd83e8ff6f41bfc36dd17d935b
permissions -rw-r--r--
Bug 1442694 - Fix failures due to removing selected tab r=Gijs This adds test which reproduce the failure as well as the fix. Essentially, if we hit the edited case in SessionStore with `tab` equal to `tabbrowser.tabs[t]`, we remove the tab and then try to pin it, which obviously blows up. Note: the additional method in SessionStore.jsm was largely to get around complexity requirements inside restoreWindow. Cleaner solutions welcome. Differential Revision: https://phabricator.services.mozilla.com/D21383

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_widget_RemotePlugin_h__
#define mozilla_widget_RemotePlugin_h__

#ifndef XP_WIN
#  error "Plugin widgets are Windows-only."

#include "PuppetWidget.h"
#include "mozilla/dom/TabChild.h"

 * PluginWidgetProxy is a nsIWidget wrapper we hand around in plugin and layout
 * code. It wraps a native widget it creates in the chrome process. Since this
 * is for plugins, only a limited set of the widget apis need to be overridden,
 * the rest of the implementation is in PuppetWidget or nsBaseWidget.

namespace mozilla {
namespace plugins {
class PluginWidgetChild;
}  // namespace plugins
namespace widget {

class PluginWidgetProxy final : public PuppetWidget {
  explicit PluginWidgetProxy(dom::TabChild* aTabChild,
                             mozilla::plugins::PluginWidgetChild* aChannel);

  virtual ~PluginWidgetProxy();


  // nsIWidget
  using PuppetWidget::Create;  // for Create signature not overridden here
  virtual MOZ_MUST_USE nsresult
  Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
         const LayoutDeviceIntRect& aRect,
         nsWidgetInitData* aInitData = nullptr) override;
  virtual void Destroy() override;
  virtual nsresult SetFocus(bool aRaise = false) override;
  virtual void SetParent(nsIWidget* aNewParent) override;

  virtual nsIWidget* GetParent(void) override;
  virtual void* GetNativeData(uint32_t aDataType) override;
  void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
  virtual nsTransparencyMode GetTransparencyMode() override {
    return eTransparencyOpaque;
  virtual void GetWindowClipRegion(
      nsTArray<LayoutDeviceIntRect>* aRects) override;

   * When tabs are closed PPluginWidget can terminate before plugin code is
   * finished tearing us down. When this happens plugin calls over mActor
   * fail triggering an abort in the content process. To protect against this
   * the connection tells us when it is torn down here so we can avoid making
   * calls while content finishes tearing us down.
  void ChannelDestroyed() { mActor = nullptr; }

  // Our connection with the chrome widget, created on PBrowser.
  mozilla::plugins::PluginWidgetChild* mActor;
  // PuppetWidget does not implement parent apis, but we need
  // them for plugin widgets.
  nsCOMPtr<nsIWidget> mParent;
  uintptr_t mCachedPluginPort;

}  // namespace widget
}  // namespace mozilla