Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef _nsPluginNativeWindow_h_ |
michael@0 | 7 | #define _nsPluginNativeWindow_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nscore.h" |
michael@0 | 10 | #include "nsAutoPtr.h" |
michael@0 | 11 | #include "nsCOMPtr.h" |
michael@0 | 12 | #include "nsISupportsImpl.h" |
michael@0 | 13 | #include "nsNPAPIPluginInstance.h" |
michael@0 | 14 | #include "npapi.h" |
michael@0 | 15 | #include "nsIWidget.h" |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * base class for native plugin window implementations |
michael@0 | 19 | */ |
michael@0 | 20 | class nsPluginNativeWindow : public NPWindow |
michael@0 | 21 | { |
michael@0 | 22 | public: |
michael@0 | 23 | nsPluginNativeWindow() : NPWindow() { |
michael@0 | 24 | MOZ_COUNT_CTOR(nsPluginNativeWindow); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | virtual ~nsPluginNativeWindow() { |
michael@0 | 28 | MOZ_COUNT_DTOR(nsPluginNativeWindow); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * !!! CAUTION !!! |
michael@0 | 33 | * |
michael@0 | 34 | * The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h, |
michael@0 | 35 | * thus it does not have a destructor of its own. |
michael@0 | 36 | * One should never attempt to delete |nsPluginNativeWindow| object instance |
michael@0 | 37 | * (or derivatives) using a pointer of |nsPluginWindow *| type. Should such |
michael@0 | 38 | * necessity occur it must be properly casted first. |
michael@0 | 39 | */ |
michael@0 | 40 | |
michael@0 | 41 | public: |
michael@0 | 42 | nsresult GetPluginInstance(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { |
michael@0 | 43 | aPluginInstance = mPluginInstance; |
michael@0 | 44 | return NS_OK; |
michael@0 | 45 | } |
michael@0 | 46 | nsresult SetPluginInstance(nsNPAPIPluginInstance *aPluginInstance) { |
michael@0 | 47 | if (mPluginInstance != aPluginInstance) |
michael@0 | 48 | mPluginInstance = aPluginInstance; |
michael@0 | 49 | return NS_OK; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | nsresult GetPluginWidget(nsIWidget **aWidget) { |
michael@0 | 53 | NS_IF_ADDREF(*aWidget = mWidget); |
michael@0 | 54 | return NS_OK; |
michael@0 | 55 | } |
michael@0 | 56 | nsresult SetPluginWidget(nsIWidget *aWidget) { |
michael@0 | 57 | mWidget = aWidget; |
michael@0 | 58 | return NS_OK; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | public: |
michael@0 | 62 | virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { |
michael@0 | 63 | // null aPluginInstance means that we want to call SetWindow(null) |
michael@0 | 64 | if (aPluginInstance) |
michael@0 | 65 | aPluginInstance->SetWindow(this); |
michael@0 | 66 | else if (mPluginInstance) |
michael@0 | 67 | mPluginInstance->SetWindow(nullptr); |
michael@0 | 68 | |
michael@0 | 69 | SetPluginInstance(aPluginInstance); |
michael@0 | 70 | return NS_OK; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | protected: |
michael@0 | 74 | nsRefPtr<nsNPAPIPluginInstance> mPluginInstance; |
michael@0 | 75 | nsCOMPtr<nsIWidget> mWidget; |
michael@0 | 76 | }; |
michael@0 | 77 | |
michael@0 | 78 | nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow); |
michael@0 | 79 | nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow); |
michael@0 | 80 | |
michael@0 | 81 | #endif //_nsPluginNativeWindow_h_ |