dom/plugins/base/nsPluginNativeWindow.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/base/nsPluginNativeWindow.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _nsPluginNativeWindow_h_
    1.10 +#define _nsPluginNativeWindow_h_
    1.11 +
    1.12 +#include "nscore.h"
    1.13 +#include "nsAutoPtr.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsISupportsImpl.h"
    1.16 +#include "nsNPAPIPluginInstance.h"
    1.17 +#include "npapi.h"
    1.18 +#include "nsIWidget.h"
    1.19 +
    1.20 +/**
    1.21 + * base class for native plugin window implementations
    1.22 + */
    1.23 +class nsPluginNativeWindow : public NPWindow
    1.24 +{
    1.25 +public: 
    1.26 +  nsPluginNativeWindow() : NPWindow() {
    1.27 +    MOZ_COUNT_CTOR(nsPluginNativeWindow);
    1.28 +  }
    1.29 +
    1.30 +  virtual ~nsPluginNativeWindow() {
    1.31 +    MOZ_COUNT_DTOR(nsPluginNativeWindow);
    1.32 +  }
    1.33 +
    1.34 +  /**
    1.35 +   *   !!! CAUTION !!!
    1.36 +   *
    1.37 +   * The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h,
    1.38 +   * thus it does not have a destructor of its own.
    1.39 +   * One should never attempt to delete |nsPluginNativeWindow| object instance
    1.40 +   * (or derivatives) using a pointer of |nsPluginWindow *| type. Should such
    1.41 +   * necessity occur it must be properly casted first.
    1.42 +   */
    1.43 +
    1.44 +public:
    1.45 +  nsresult GetPluginInstance(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { 
    1.46 +    aPluginInstance = mPluginInstance;
    1.47 +    return NS_OK;
    1.48 +  }
    1.49 +  nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) { 
    1.50 +    if (mPluginInstance != aPluginInstance)
    1.51 +      mPluginInstance = aPluginInstance;
    1.52 +    return NS_OK;
    1.53 +  }
    1.54 +
    1.55 +  nsresult GetPluginWidget(nsIWidget **aWidget) {
    1.56 +    NS_IF_ADDREF(*aWidget = mWidget);
    1.57 +    return NS_OK;
    1.58 +  }
    1.59 +  nsresult SetPluginWidget(nsIWidget *aWidget) { 
    1.60 +    mWidget = aWidget;
    1.61 +    return NS_OK;
    1.62 +  }
    1.63 +
    1.64 +public:
    1.65 +  virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
    1.66 +    // null aPluginInstance means that we want to call SetWindow(null)
    1.67 +    if (aPluginInstance)
    1.68 +      aPluginInstance->SetWindow(this);
    1.69 +    else if (mPluginInstance)
    1.70 +      mPluginInstance->SetWindow(nullptr);
    1.71 +
    1.72 +    SetPluginInstance(aPluginInstance);
    1.73 +    return NS_OK;
    1.74 +  }
    1.75 +
    1.76 +protected:
    1.77 +  nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;
    1.78 +  nsCOMPtr<nsIWidget> mWidget;
    1.79 +};
    1.80 +
    1.81 +nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
    1.82 +nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
    1.83 +
    1.84 +#endif //_nsPluginNativeWindow_h_

mercurial