2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef _nsPluginNativeWindow_h_
|
|
|
|
#define _nsPluginNativeWindow_h_
|
|
|
|
|
|
|
|
#include "nscore.h"
|
2011-05-17 18:48:34 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2014-02-26 13:36:35 -08:00
|
|
|
#include "nsISupportsImpl.h"
|
2011-05-17 18:48:34 -07:00
|
|
|
#include "nsNPAPIPluginInstance.h"
|
2009-09-16 18:30:26 -07:00
|
|
|
#include "npapi.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIWidget.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* base class for native plugin window implementations
|
|
|
|
*/
|
2009-09-16 18:30:26 -07:00
|
|
|
class nsPluginNativeWindow : public NPWindow
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2009-09-16 18:30:26 -07:00
|
|
|
nsPluginNativeWindow() : NPWindow() {
|
2009-01-10 09:13:31 -08:00
|
|
|
MOZ_COUNT_CTOR(nsPluginNativeWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsPluginNativeWindow() {
|
|
|
|
MOZ_COUNT_DTOR(nsPluginNativeWindow);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* !!! CAUTION !!!
|
|
|
|
*
|
|
|
|
* The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h,
|
|
|
|
* thus it does not have a destructor of its own.
|
|
|
|
* One should never attempt to delete |nsPluginNativeWindow| object instance
|
|
|
|
* (or derivatives) using a pointer of |nsPluginWindow *| type. Should such
|
|
|
|
* necessity occur it must be properly casted first.
|
|
|
|
*/
|
|
|
|
|
|
|
|
public:
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult GetPluginInstance(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
|
2007-03-22 10:30:00 -07:00
|
|
|
aPluginInstance = mPluginInstance;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-05-17 18:48:34 -07:00
|
|
|
nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mPluginInstance != aPluginInstance)
|
|
|
|
mPluginInstance = aPluginInstance;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult GetPluginWidget(nsIWidget **aWidget) {
|
|
|
|
NS_IF_ADDREF(*aWidget = mWidget);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsresult SetPluginWidget(nsIWidget *aWidget) {
|
|
|
|
mWidget = aWidget;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2011-05-17 18:48:34 -07:00
|
|
|
virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// null aPluginInstance means that we want to call SetWindow(null)
|
|
|
|
if (aPluginInstance)
|
|
|
|
aPluginInstance->SetWindow(this);
|
|
|
|
else if (mPluginInstance)
|
2012-07-30 07:20:58 -07:00
|
|
|
mPluginInstance->SetWindow(nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
SetPluginInstance(aPluginInstance);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2011-05-17 18:48:34 -07:00
|
|
|
nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;
|
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
|
|
|
|
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
|
|
|
|
|
|
|
|
#endif //_nsPluginNativeWindow_h_
|