LCOV - code coverage report
Current view: directory - dom/plugins/base - nsPluginNativeWindow.h (source / functions) Found Hit Coverage
Test: app.info Lines: 23 0 0.0 %
Date: 2012-06-02 Functions: 7 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Andrei Volkov <av@netscape.com>
      24                 :  *   Brian Stell <bstell@netscape.com>
      25                 :  *   Peter Lubczynski <peterl@netscape.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      29                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #ifndef _nsPluginNativeWindow_h_
      42                 : #define _nsPluginNativeWindow_h_
      43                 : 
      44                 : #include "nscore.h"
      45                 : #include "nsAutoPtr.h"
      46                 : #include "nsCOMPtr.h"
      47                 : #include "nsNPAPIPluginInstance.h"
      48                 : #include "npapi.h"
      49                 : #include "nsIWidget.h"
      50                 : #include "nsTraceRefcnt.h"
      51                 : 
      52                 : /**
      53                 :  * base class for native plugin window implementations
      54                 :  */
      55                 : class nsPluginNativeWindow : public NPWindow
      56                 : {
      57                 : public: 
      58               0 :   nsPluginNativeWindow() : NPWindow() {
      59               0 :     MOZ_COUNT_CTOR(nsPluginNativeWindow);
      60               0 :   }
      61                 : 
      62               0 :   virtual ~nsPluginNativeWindow() {
      63               0 :     MOZ_COUNT_DTOR(nsPluginNativeWindow);
      64               0 :   }
      65                 : 
      66                 :   /**
      67                 :    *   !!! CAUTION !!!
      68                 :    *
      69                 :    * The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h,
      70                 :    * thus it does not have a destructor of its own.
      71                 :    * One should never attempt to delete |nsPluginNativeWindow| object instance
      72                 :    * (or derivatives) using a pointer of |nsPluginWindow *| type. Should such
      73                 :    * necessity occur it must be properly casted first.
      74                 :    */
      75                 : 
      76                 : public:
      77                 :   nsresult GetPluginInstance(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { 
      78                 :     aPluginInstance = mPluginInstance;
      79                 :     return NS_OK;
      80                 :   }
      81               0 :   nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) { 
      82               0 :     if (mPluginInstance != aPluginInstance)
      83               0 :       mPluginInstance = aPluginInstance;
      84               0 :     return NS_OK;
      85                 :   }
      86                 : 
      87               0 :   nsresult GetPluginWidget(nsIWidget **aWidget) {
      88               0 :     NS_IF_ADDREF(*aWidget = mWidget);
      89               0 :     return NS_OK;
      90                 :   }
      91               0 :   nsresult SetPluginWidget(nsIWidget *aWidget) { 
      92               0 :     mWidget = aWidget;
      93               0 :     return NS_OK;
      94                 :   }
      95                 : 
      96                 : public:
      97               0 :   virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) {
      98                 :     // null aPluginInstance means that we want to call SetWindow(null)
      99               0 :     if (aPluginInstance)
     100               0 :       aPluginInstance->SetWindow(this);
     101               0 :     else if (mPluginInstance)
     102               0 :       mPluginInstance->SetWindow(nsnull);
     103                 : 
     104               0 :     SetPluginInstance(aPluginInstance);
     105               0 :     return NS_OK;
     106                 :   }
     107                 : 
     108                 : protected:
     109                 :   nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;
     110                 :   nsCOMPtr<nsIWidget> mWidget;
     111                 : };
     112                 : 
     113                 : nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
     114                 : nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
     115                 : 
     116                 : #endif //_nsPluginNativeWindow_h_

Generated by: LCOV version 1.7