michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsPluginNativeWindow_h_ michael@0: #define _nsPluginNativeWindow_h_ michael@0: michael@0: #include "nscore.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsISupportsImpl.h" michael@0: #include "nsNPAPIPluginInstance.h" michael@0: #include "npapi.h" michael@0: #include "nsIWidget.h" michael@0: michael@0: /** michael@0: * base class for native plugin window implementations michael@0: */ michael@0: class nsPluginNativeWindow : public NPWindow michael@0: { michael@0: public: michael@0: nsPluginNativeWindow() : NPWindow() { michael@0: MOZ_COUNT_CTOR(nsPluginNativeWindow); michael@0: } michael@0: michael@0: virtual ~nsPluginNativeWindow() { michael@0: MOZ_COUNT_DTOR(nsPluginNativeWindow); michael@0: } michael@0: michael@0: /** michael@0: * !!! CAUTION !!! michael@0: * michael@0: * The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h, michael@0: * thus it does not have a destructor of its own. michael@0: * One should never attempt to delete |nsPluginNativeWindow| object instance michael@0: * (or derivatives) using a pointer of |nsPluginWindow *| type. Should such michael@0: * necessity occur it must be properly casted first. michael@0: */ michael@0: michael@0: public: michael@0: nsresult GetPluginInstance(nsRefPtr &aPluginInstance) { michael@0: aPluginInstance = mPluginInstance; michael@0: return NS_OK; michael@0: } michael@0: nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) { michael@0: if (mPluginInstance != aPluginInstance) michael@0: mPluginInstance = aPluginInstance; michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult GetPluginWidget(nsIWidget **aWidget) { michael@0: NS_IF_ADDREF(*aWidget = mWidget); michael@0: return NS_OK; michael@0: } michael@0: nsresult SetPluginWidget(nsIWidget *aWidget) { michael@0: mWidget = aWidget; michael@0: return NS_OK; michael@0: } michael@0: michael@0: public: michael@0: virtual nsresult CallSetWindow(nsRefPtr &aPluginInstance) { michael@0: // null aPluginInstance means that we want to call SetWindow(null) michael@0: if (aPluginInstance) michael@0: aPluginInstance->SetWindow(this); michael@0: else if (mPluginInstance) michael@0: mPluginInstance->SetWindow(nullptr); michael@0: michael@0: SetPluginInstance(aPluginInstance); michael@0: return NS_OK; michael@0: } michael@0: michael@0: protected: michael@0: nsRefPtr mPluginInstance; michael@0: nsCOMPtr mWidget; michael@0: }; michael@0: michael@0: nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow); michael@0: nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow); michael@0: michael@0: #endif //_nsPluginNativeWindow_h_