Back to index

lightning-sunbird  0.9+nobinonly
EmbeddedFramePluginInstance.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the MRJ Carbon OJI Plugin.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corp.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Patrick C. Beard <beard@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039        EmbeddedFramePluginInstance.cpp
00040  */
00041 
00042 #include "EmbeddedFramePluginInstance.h"
00043 #include "EmbeddedFrame.h"
00044 #include "MRJPlugin.h"
00045 
00046 #include "nsIPluginInstancePeer.h"
00047 #include "nsIPluginTagInfo.h"
00048 
00049 #include <stdio.h>
00050 
00051 EmbeddedFramePluginInstance::EmbeddedFramePluginInstance()
00052        :      mPeer(NULL), mFrame(NULL)
00053 {
00054 }
00055 
00056 EmbeddedFramePluginInstance::~EmbeddedFramePluginInstance()
00057 {
00058        if (mFrame != NULL)
00059               delete mFrame;
00060 }
00061 
00062 NS_METHOD EmbeddedFramePluginInstance::Initialize(nsIPluginInstancePeer* peer)
00063 {
00064        mPeer = peer;
00065        NS_ADDREF(mPeer);
00066 
00067        nsIPluginTagInfo* tagInfo = NULL;
00068        if (mPeer->QueryInterface(NS_GET_IID(nsIPluginTagInfo), (void**)&tagInfo) == NS_OK) {
00069               const char* frameValue = NULL;
00070               if (tagInfo->GetAttribute("JAVAFRAME", &frameValue) == NS_OK) {
00071                      sscanf(frameValue, "%X", &mFrame);
00072               }
00073               if (mFrame != NULL)
00074                      mFrame->setPluginInstance(this);
00075               NS_RELEASE(tagInfo);
00076        }
00077 
00078        return NS_OK;
00079 }
00080 
00081 NS_METHOD EmbeddedFramePluginInstance::GetPeer(nsIPluginInstancePeer* *resultingPeer)
00082 {
00083        if (mPeer != NULL) {
00084               *resultingPeer = mPeer;
00085               mPeer->AddRef();
00086        }
00087        return NS_OK;
00088 }
00089 
00090 NS_METHOD EmbeddedFramePluginInstance::Destroy()
00091 {
00092        NS_IF_RELEASE(mPeer);
00093 
00094        // assume that Java will release this frame.
00095        if (mFrame != NULL) {
00096               mFrame->showHide(false);
00097               // delete mFrame;
00098               mFrame = NULL;
00099        }
00100 
00101        return NS_OK;
00102 }
00103 
00104 NS_METHOD EmbeddedFramePluginInstance::SetWindow(nsPluginWindow* pluginWindow)
00105 {
00106        if (mFrame != NULL) {
00107               if (pluginWindow != NULL)
00108                      mFrame->setWindow(WindowRef(pluginWindow->window->port));
00109               else
00110                      mFrame->setWindow(NULL);
00111        }
00112        return NS_OK;
00113 }
00114 
00115 NS_METHOD EmbeddedFramePluginInstance::HandleEvent(nsPluginEvent* pluginEvent, PRBool* eventHandled)
00116 {
00117        if (mFrame != NULL)
00118               *eventHandled = mFrame->handleEvent(pluginEvent->event);
00119        return NS_OK;
00120 }
00121 
00122 void EmbeddedFramePluginInstance::setFrame(EmbeddedFrame* frame)
00123 {
00124        mFrame = frame;
00125 }
00126 
00127 NS_IMPL_ISUPPORTS1(EmbeddedFramePluginInstance, nsIPluginInstance)