LCOV - code coverage report
Current view: directory - dom/base - nsPluginArray.h (source / functions) Found Hit Coverage
Test: app.info Lines: 8 0 0.0 %
Date: 2012-06-02 Functions: 2 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                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsPluginArray_h___
      39                 : #define nsPluginArray_h___
      40                 : 
      41                 : #include "nsCOMPtr.h"
      42                 : #include "nsIDOMPluginArray.h"
      43                 : #include "nsIDOMPlugin.h"
      44                 : #include "nsIPluginHost.h"
      45                 : #include "nsIURL.h"
      46                 : #include "nsWeakReference.h"
      47                 : 
      48                 : namespace mozilla {
      49                 : namespace dom {
      50                 : class Navigator;
      51                 : } // namespace dom
      52                 : } // namespace mozilla
      53                 : 
      54                 : class nsIDocShell;
      55                 : 
      56                 : // NB: Due to weak references, Navigator has intimate knowledge of our
      57                 : // internals.
      58                 : class nsPluginArray : public nsIDOMPluginArray
      59                 : {
      60                 : public:
      61                 :   nsPluginArray(mozilla::dom::Navigator* navigator, nsIDocShell *aDocShell);
      62                 :   virtual ~nsPluginArray();
      63                 : 
      64                 :   NS_DECL_ISUPPORTS
      65                 : 
      66                 :   // nsIDOMPluginArray
      67                 :   NS_DECL_NSIDOMPLUGINARRAY
      68                 : 
      69                 :   nsresult GetPluginHost(nsIPluginHost** aPluginHost);
      70                 : 
      71                 :   nsIDOMPlugin* GetItemAt(PRUint32 aIndex, nsresult* aResult);
      72                 :   nsIDOMPlugin* GetNamedItem(const nsAString& aName, nsresult* aResult);
      73                 : 
      74               0 :   static nsPluginArray* FromSupports(nsISupports* aSupports)
      75                 :   {
      76                 : #ifdef DEBUG
      77                 :     {
      78               0 :       nsCOMPtr<nsIDOMPluginArray> array_qi = do_QueryInterface(aSupports);
      79                 : 
      80                 :       // If this assertion fires the QI implementation for the object in
      81                 :       // question doesn't use the nsIDOMPluginArray pointer as the nsISupports
      82                 :       // pointer. That must be fixed, or we'll crash...
      83               0 :       NS_ASSERTION(array_qi == static_cast<nsIDOMPluginArray*>(aSupports),
      84                 :                    "Uh, fix QI!");
      85                 :     }
      86                 : #endif
      87                 : 
      88               0 :     return static_cast<nsPluginArray*>(aSupports);
      89                 :   }
      90                 : 
      91                 : private:
      92                 :   nsresult GetPlugins();
      93                 :   bool AllowPlugins();
      94                 : 
      95                 : public:
      96                 :   void Invalidate();
      97                 : 
      98                 : protected:
      99                 :   mozilla::dom::Navigator* mNavigator;
     100                 :   nsCOMPtr<nsIPluginHost> mPluginHost;
     101                 :   PRUint32 mPluginCount;
     102                 :   nsIDOMPlugin** mPluginArray;
     103                 :   nsWeakPtr mDocShell;
     104                 : };
     105                 : 
     106                 : class nsPluginElement : public nsIDOMPlugin
     107                 : {
     108                 : public:
     109                 :   nsPluginElement(nsIDOMPlugin* plugin);
     110                 :   virtual ~nsPluginElement();
     111                 : 
     112                 :   NS_DECL_ISUPPORTS
     113                 :   NS_DECL_NSIDOMPLUGIN
     114                 : 
     115                 :   nsIDOMMimeType* GetItemAt(PRUint32 aIndex, nsresult* aResult);
     116                 :   nsIDOMMimeType* GetNamedItem(const nsAString& aName, nsresult* aResult);
     117                 : 
     118               0 :   static nsPluginElement* FromSupports(nsISupports* aSupports)
     119                 :   {
     120                 : #ifdef DEBUG
     121                 :     {
     122               0 :       nsCOMPtr<nsIDOMPlugin> plugin_qi = do_QueryInterface(aSupports);
     123                 : 
     124                 :       // If this assertion fires the QI implementation for the object in
     125                 :       // question doesn't use the nsIDOMPlugin pointer as the nsISupports
     126                 :       // pointer. That must be fixed, or we'll crash...
     127               0 :       NS_ASSERTION(plugin_qi == static_cast<nsIDOMPlugin*>(aSupports),
     128                 :                    "Uh, fix QI!");
     129                 :     }
     130                 : #endif
     131                 : 
     132               0 :     return static_cast<nsPluginElement*>(aSupports);
     133                 :   }
     134                 : 
     135                 : private:
     136                 :   nsresult GetMimeTypes();
     137                 : 
     138                 : protected:
     139                 :   nsIDOMPlugin* mPlugin;
     140                 :   PRUint32 mMimeTypeCount;
     141                 :   nsIDOMMimeType** mMimeTypeArray;
     142                 : };
     143                 : 
     144                 : #endif /* nsPluginArray_h___ */

Generated by: LCOV version 1.7