зеркало из https://github.com/mozilla/pjs.git
Fixing bug 48972 -- adding GetOwner interface method to plugin instance peer, r=peterl, sr=beard
This commit is contained in:
Родитель
0470f79669
Коммит
cbb401e71a
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsPIPluginInstancePeer_h___
|
||||
#define nsPIPluginInstancePeer_h___
|
||||
|
||||
#include "nsIPluginInstanceOwner.h"
|
||||
|
||||
#define NS_PIPLUGININSTANCEPEER_IID \
|
||||
{/* 4a708562-8a37-400b-8c08-20037d1adad3 */ \
|
||||
0x4a708562, 0x8a37, 0x400b, \
|
||||
{0x8c, 0x08, 0x20, 0x03, 0x7d, 0x1a, 0xda, 0xd3} \
|
||||
}
|
||||
|
||||
class nsPIPluginInstancePeer : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_PIPLUGININSTANCEPEER_IID)
|
||||
|
||||
/*
|
||||
* To get a plugin instance owner
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetOwner(nsCOMPtr<nsIPluginInstanceOwner> &aOwner) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsPIPluginInstancePeer_h___ */
|
|
@ -506,10 +506,11 @@ nsActivePlugin::~nsActivePlugin()
|
|||
if(mPeer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsPluginInstancePeerImpl * peer = (nsPluginInstancePeerImpl *)mPeer;
|
||||
nsCOMPtr<nsPIPluginInstancePeer> peer(do_QueryInterface(mPeer));
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
rv = peer->GetOwner(*getter_AddRefs(owner));
|
||||
owner->SetInstance(nsnull);
|
||||
rv = peer->GetOwner(getter_AddRefs(owner));
|
||||
if (owner)
|
||||
owner->SetInstance(nsnull);
|
||||
}
|
||||
|
||||
// now check for cached plugins because they haven't had nsIPluginInstance::Destroy()
|
||||
|
@ -711,9 +712,9 @@ void nsActivePluginList::stopRunning(nsISupportsArray* aReloadDocs)
|
|||
// removing duplicates. These will be reframed (embedded) or reloaded (full-page) later
|
||||
// to kickstart our instances.
|
||||
if (aReloadDocs && p->mPeer) {
|
||||
nsPluginInstancePeerImpl * peer = (nsPluginInstancePeerImpl *)p->mPeer;
|
||||
nsCOMPtr<nsPIPluginInstancePeer> peer(do_QueryInterface(p->mPeer));
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
peer->GetOwner(*getter_AddRefs(owner));
|
||||
peer->GetOwner(getter_AddRefs(owner));
|
||||
if (owner) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
owner->GetDocument(getter_AddRefs(doc));
|
||||
|
@ -3027,17 +3028,14 @@ NS_IMETHODIMP nsPluginHostImpl::GetURLWithHeaders(nsISupports* pluginInst,
|
|||
{
|
||||
if (nsnull != target)
|
||||
{
|
||||
nsPluginInstancePeerImpl *peer;
|
||||
|
||||
rv = instance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
|
||||
|
||||
nsCOMPtr<nsIPluginInstancePeer> peer;
|
||||
rv = instance->GetPeer(getter_AddRefs(peer));
|
||||
if (NS_SUCCEEDED(rv) && peer)
|
||||
{
|
||||
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
|
||||
rv = peer->GetOwner(*getter_AddRefs(owner));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = privpeer->GetOwner(getter_AddRefs(owner));
|
||||
if (owner)
|
||||
{
|
||||
if ((0 == PL_strcmp(target, "newwindow")) ||
|
||||
(0 == PL_strcmp(target, "_new")))
|
||||
|
@ -3045,19 +3043,14 @@ NS_IMETHODIMP nsPluginHostImpl::GetURLWithHeaders(nsISupports* pluginInst,
|
|||
else if (0 == PL_strcmp(target, "_current"))
|
||||
target = "_self";
|
||||
|
||||
rv = owner->GetURL(url, target, nsnull, 0, (void *) getHeaders,
|
||||
getHeadersLength);
|
||||
rv = owner->GetURL(url, target, nsnull, 0, (void *) getHeaders, getHeadersLength);
|
||||
}
|
||||
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != streamListener)
|
||||
rv = NewPluginURLStream(string, instance, streamListener, nsnull,
|
||||
PR_FALSE, nsnull, getHeaders, getHeadersLength);
|
||||
|
||||
NS_RELEASE(instance);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -3112,16 +3105,15 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
|
|||
|
||||
if (nsnull != target)
|
||||
{
|
||||
nsPluginInstancePeerImpl *peer;
|
||||
rv = instance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
|
||||
nsCOMPtr<nsIPluginInstancePeer> peer;
|
||||
rv = instance->GetPeer(getter_AddRefs(peer));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && peer)
|
||||
{
|
||||
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
|
||||
rv = peer->GetOwner(*getter_AddRefs(owner));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = privpeer->GetOwner(getter_AddRefs(owner));
|
||||
if (owner)
|
||||
{
|
||||
if (!target) {
|
||||
target = "_self";
|
||||
|
@ -3137,8 +3129,6 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
|
|||
rv = owner->GetURL(url, target, (void*)dataToPost, postDataLen,
|
||||
(void*) postHeaders, postHeadersLength, isFile);
|
||||
}
|
||||
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5063,8 +5053,9 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
nsresult nsPluginHostImpl::FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsChanged)
|
||||
{
|
||||
// let's start timing if we are only really creating the plugin list
|
||||
if (aCreatePluginList)
|
||||
NS_TIMELINE_START_TIMER("LoadPlugins");
|
||||
if (aCreatePluginList) {
|
||||
NS_TIMELINE_START_TIMER("LoadPlugins");
|
||||
}
|
||||
|
||||
#ifdef CALL_SAFETY_ON
|
||||
// check preferences on whether or not we want to try safe calls to plugins
|
||||
|
@ -5614,13 +5605,15 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
// get the full URL of the document that the plugin is embedded
|
||||
// in to create an absolute url in case aURL is relative
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsPluginInstancePeerImpl *peer;
|
||||
nsCOMPtr<nsIPluginInstancePeer> peer;
|
||||
rv = aInstance->GetPeer(getter_AddRefs(peer));
|
||||
rv = aInstance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
|
||||
if (NS_SUCCEEDED(rv) && peer)
|
||||
{
|
||||
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
rv = peer->GetOwner(*getter_AddRefs(owner));
|
||||
if (NS_SUCCEEDED(rv) && owner)
|
||||
rv = privpeer->GetOwner(getter_AddRefs(owner));
|
||||
if (owner)
|
||||
{
|
||||
rv = owner->GetDocument(getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv) && doc)
|
||||
|
@ -5633,7 +5626,6 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
|||
rv = NS_MakeAbsoluteURI(absUrl, aURL, docURL);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
|
||||
if (absUrl.IsEmpty())
|
||||
|
@ -6107,10 +6099,11 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
|
|||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
|
||||
if (instance) {
|
||||
nsPluginInstancePeerImpl *peer;
|
||||
rv =instance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
|
||||
nsCOMPtr<nsIPluginInstancePeer> peer;
|
||||
rv =instance->GetPeer(getter_AddRefs(peer));
|
||||
if (NS_SUCCEEDED(rv) && peer) {
|
||||
peer->GetOwner(*getter_AddRefs(owner));
|
||||
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
||||
privpeer->GetOwner(getter_AddRefs(owner));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6544,20 +6537,18 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
|
|||
// mInstance->Stop calls mPStreamListener->CleanUpStream(), so stream will be properly clean up
|
||||
mInstance->Stop();
|
||||
mInstance->Start();
|
||||
nsPluginInstancePeerImpl *peer;
|
||||
mInstance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
|
||||
nsCOMPtr<nsIPluginInstancePeer> peer;
|
||||
mInstance->GetPeer(getter_AddRefs(peer));
|
||||
if (peer) {
|
||||
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
peer->GetOwner(*getter_AddRefs(owner));
|
||||
privpeer->GetOwner(getter_AddRefs(owner));
|
||||
if (owner) {
|
||||
nsPluginWindow *window = nsnull;
|
||||
owner->GetWindow(window);
|
||||
if (window->window)
|
||||
mInstance->SetWindow(window);
|
||||
}
|
||||
// because we are starting plugin using existing peer
|
||||
// it'll get one extra RefCnt, release it here.
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
|
||||
mPluginStreamInfo->SetSeekable(0);
|
||||
|
|
|
@ -86,55 +86,15 @@ nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl()
|
|||
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
||||
static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
|
||||
static NS_DEFINE_IID(kIJVMPluginTagInfoIID, NS_IJVMPLUGINTAGINFO_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININSTANCEPEER_IID);//~~~
|
||||
|
||||
NS_IMPL_ADDREF(nsPluginInstancePeerImpl);
|
||||
NS_IMPL_RELEASE(nsPluginInstancePeerImpl);
|
||||
|
||||
nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** instance)
|
||||
{
|
||||
if (instance == NULL)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(NS_GET_IID(nsIPluginInstancePeer)) || iid.Equals(NS_GET_IID(nsIPluginInstancePeer2))) {
|
||||
*instance = (void *)(nsIPluginInstancePeer2*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (iid.Equals(kIWindowlessPluginInstancePeerIID)) {
|
||||
*instance = (void *)(nsIWindowlessPluginInstancePeer*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (iid.Equals(kIPluginTagInfoIID)) {
|
||||
*instance = (void *)(nsIPluginTagInfo *)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (iid.Equals(kIPluginTagInfo2IID)) {
|
||||
*instance = (void *)(nsIPluginTagInfo2 *)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (iid.Equals(kIJVMPluginTagInfoIID)) {
|
||||
*instance = (void *)(nsIJVMPluginTagInfo *)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (iid.Equals(kISupportsIID)) {
|
||||
*instance = (void *)(nsISupports *)(nsIPluginTagInfo *)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_IMPL_ISUPPORTS7(nsPluginInstancePeerImpl,
|
||||
nsIPluginInstancePeer,
|
||||
nsIPluginInstancePeer2,
|
||||
nsIWindowlessPluginInstancePeer,
|
||||
nsIPluginTagInfo,
|
||||
nsIPluginTagInfo2,
|
||||
nsIJVMPluginTagInfo,
|
||||
nsPIPluginInstancePeer);
|
||||
|
||||
NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value)
|
||||
{
|
||||
|
@ -837,18 +797,14 @@ nsresult nsPluginInstancePeerImpl::SetOwner(nsIPluginInstanceOwner *aOwner)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner *&aOwner)
|
||||
NS_IMETHODIMP nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner **aOwner)
|
||||
{
|
||||
aOwner = mOwner;
|
||||
NS_ENSURE_ARG_POINTER(aOwner);
|
||||
*aOwner = mOwner;
|
||||
NS_IF_ADDREF(mOwner);
|
||||
|
||||
if (nsnull != mOwner)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return (mOwner) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRect(nsPluginRect *invalidRect)
|
||||
{
|
||||
if(!mOwner)
|
||||
|
|
|
@ -43,12 +43,13 @@
|
|||
#include "nsIPluginTagInfo.h"
|
||||
#include "nsIPluginInstanceOwner.h"
|
||||
#include "nsIJVMPluginTagInfo.h"
|
||||
|
||||
#include "nsPIPluginInstancePeer.h"
|
||||
|
||||
class nsPluginInstancePeerImpl : public nsIPluginInstancePeer2,
|
||||
public nsIWindowlessPluginInstancePeer,
|
||||
public nsIPluginTagInfo2,
|
||||
public nsIJVMPluginTagInfo
|
||||
public nsIJVMPluginTagInfo,
|
||||
public nsPIPluginInstancePeer
|
||||
|
||||
{
|
||||
public:
|
||||
|
@ -171,6 +172,11 @@ public:
|
|||
NS_IMETHOD
|
||||
GetMayScript(PRBool *result);
|
||||
|
||||
// nsPIPluginInstancePeer interface
|
||||
|
||||
NS_IMETHOD
|
||||
GetOwner(nsIPluginInstanceOwner **aOwner);
|
||||
|
||||
//locals
|
||||
|
||||
nsresult Initialize(nsIPluginInstanceOwner *aOwner,
|
||||
|
@ -178,8 +184,6 @@ public:
|
|||
|
||||
nsresult SetOwner(nsIPluginInstanceOwner *aOwner);
|
||||
|
||||
nsresult GetOwner(nsIPluginInstanceOwner *&aOwner);
|
||||
|
||||
private:
|
||||
nsIPluginInstance *mInstance; //we don't add a ref to this
|
||||
nsIPluginInstanceOwner *mOwner; //we don't add a ref to this
|
||||
|
|
Загрузка…
Ссылка в новой задаче