2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:set et cin sw=2 sts=2:
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
*
|
|
|
|
* 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 <object> loading code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Christian Biesinger <cbiesinger@web.de>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2010-04-08 00:45:00 -07:00
|
|
|
* Justin Dolske <dolske@mozilla.com>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*
|
2007-07-18 14:48:18 -07:00
|
|
|
* A base class implementing nsIObjectLoadingContent for use by
|
2007-03-22 10:30:00 -07:00
|
|
|
* various content nodes that want to provide plugin/document/image
|
|
|
|
* loading functionality (eg <embed>, <object>, <applet>, etc).
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Interface headers
|
|
|
|
#include "imgILoader.h"
|
2010-02-09 17:05:31 -08:00
|
|
|
#include "nsEventDispatcher.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDocument.h"
|
2010-02-09 17:05:31 -08:00
|
|
|
#include "nsIDOMDataContainerEvent.h"
|
|
|
|
#include "nsIDOMDocumentEvent.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIExternalProtocolHandler.h"
|
|
|
|
#include "nsIEventStateManager.h"
|
|
|
|
#include "nsIObjectFrame.h"
|
|
|
|
#include "nsIPluginDocument.h"
|
|
|
|
#include "nsIPluginHost.h"
|
2009-06-29 22:55:05 -07:00
|
|
|
#include "nsIPluginInstance.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIPresShell.h"
|
2010-02-09 17:05:31 -08:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsIStreamConverterService.h"
|
|
|
|
#include "nsIURILoader.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsIWebNavigation.h"
|
|
|
|
#include "nsIWebNavigationInfo.h"
|
2007-12-03 13:57:17 -08:00
|
|
|
#include "nsIScriptChannel.h"
|
2009-10-02 04:26:04 -07:00
|
|
|
#include "nsIBlocklistService.h"
|
2010-08-04 19:15:55 -07:00
|
|
|
#include "nsIAsyncVerifyRedirectCallback.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsPluginError.h"
|
|
|
|
|
|
|
|
// Util headers
|
|
|
|
#include "prlog.h"
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCURILoader.h"
|
|
|
|
#include "nsContentPolicyUtils.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsNetUtil.h"
|
2007-08-20 20:26:12 -07:00
|
|
|
#include "nsMimeTypes.h"
|
2008-03-26 16:04:57 -07:00
|
|
|
#include "nsStyleUtil.h"
|
2010-02-09 17:05:31 -08:00
|
|
|
#include "nsGUIEvent.h"
|
2011-02-08 05:35:25 -08:00
|
|
|
#include "nsUnicharUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Concrete classes
|
|
|
|
#include "nsFrameLoader.h"
|
|
|
|
|
|
|
|
#include "nsObjectLoadingContent.h"
|
2008-04-11 10:29:06 -07:00
|
|
|
#include "mozAutoDocUpdate.h"
|
2010-04-23 12:51:25 -07:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
|
|
|
#include "nsIChannelPolicy.h"
|
|
|
|
#include "nsChannelPolicy.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef PR_LOGGING
|
|
|
|
static PRLogModuleInfo* gObjectLog = PR_NewLogModule("objlc");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LOG(args) PR_LOG(gObjectLog, PR_LOG_DEBUG, args)
|
|
|
|
#define LOG_ENABLED() PR_LOG_TEST(gObjectLog, PR_LOG_DEBUG)
|
|
|
|
|
|
|
|
class nsAsyncInstantiateEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
// This stores both the content and the frame so that Instantiate calls can be
|
|
|
|
// avoided if the frame changed in the meantime.
|
|
|
|
nsObjectLoadingContent *mContent;
|
2008-12-03 02:53:50 -08:00
|
|
|
nsWeakFrame mFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString mContentType;
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
|
|
|
|
nsAsyncInstantiateEvent(nsObjectLoadingContent* aContent,
|
2008-12-03 02:53:50 -08:00
|
|
|
nsIFrame* aFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsCString& aType,
|
|
|
|
nsIURI* aURI)
|
|
|
|
: mContent(aContent), mFrame(aFrame), mContentType(aType), mURI(aURI)
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsIObjectLoadingContent *>(mContent)->AddRef();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~nsAsyncInstantiateEvent()
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsIObjectLoadingContent *>(mContent)->Release();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAsyncInstantiateEvent::Run()
|
|
|
|
{
|
|
|
|
// Check if we've been "revoked"
|
|
|
|
if (mContent->mPendingInstantiateEvent != this)
|
|
|
|
return NS_OK;
|
|
|
|
mContent->mPendingInstantiateEvent = nsnull;
|
|
|
|
|
|
|
|
// Make sure that we still have the right frame (NOTE: we don't need to check
|
2008-03-14 16:08:57 -07:00
|
|
|
// the type here - GetExistingFrame() only returns object frames, and that
|
|
|
|
// means we're a plugin)
|
2007-03-22 10:30:00 -07:00
|
|
|
// Also make sure that we still refer to the same data.
|
2008-03-14 16:08:57 -07:00
|
|
|
nsIObjectFrame* frame = mContent->
|
|
|
|
GetExistingFrame(nsObjectLoadingContent::eFlushContent);
|
2009-04-24 16:46:16 -07:00
|
|
|
|
|
|
|
nsIFrame* objectFrame = nsnull;
|
|
|
|
if (frame) {
|
|
|
|
objectFrame = do_QueryFrame(frame);
|
2009-04-08 08:28:52 -07:00
|
|
|
}
|
2009-04-24 16:46:16 -07:00
|
|
|
|
|
|
|
if (objectFrame &&
|
|
|
|
mFrame.GetFrame() == objectFrame &&
|
2007-03-22 10:30:00 -07:00
|
|
|
mContent->mURI == mURI &&
|
|
|
|
mContent->mContentType.Equals(mContentType)) {
|
|
|
|
if (LOG_ENABLED()) {
|
|
|
|
nsCAutoString spec;
|
|
|
|
if (mURI) {
|
|
|
|
mURI->GetSpec(spec);
|
|
|
|
}
|
|
|
|
LOG(("OBJLC [%p]: Handling Instantiate event: Type=<%s> URI=%p<%s>\n",
|
|
|
|
mContent, mContentType.get(), mURI.get(), spec.get()));
|
|
|
|
}
|
|
|
|
|
2007-08-06 17:32:14 -07:00
|
|
|
nsresult rv = mContent->Instantiate(frame, mContentType, mURI);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mContent->Fallback(PR_TRUE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOG(("OBJLC [%p]: Discarding event, data changed\n", mContent));
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-07-13 17:28:05 -07:00
|
|
|
* A task for firing PluginNotFound and PluginBlocklisted DOM Events.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-07-13 17:28:05 -07:00
|
|
|
class nsPluginErrorEvent : public nsRunnable {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2008-09-09 08:43:21 -07:00
|
|
|
PluginSupportState mState;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-09 08:43:21 -07:00
|
|
|
nsPluginErrorEvent(nsIContent* aContent, PluginSupportState aState)
|
2007-07-13 17:28:05 -07:00
|
|
|
: mContent(aContent),
|
2008-09-09 08:43:21 -07:00
|
|
|
mState(aState)
|
2007-03-22 10:30:00 -07:00
|
|
|
{}
|
|
|
|
|
2007-07-13 17:28:05 -07:00
|
|
|
~nsPluginErrorEvent() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2007-07-13 17:28:05 -07:00
|
|
|
nsPluginErrorEvent::Run()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
LOG(("OBJLC []: Firing plugin not found event for content %p\n",
|
|
|
|
mContent.get()));
|
2008-09-09 08:43:21 -07:00
|
|
|
nsString type;
|
|
|
|
switch (mState) {
|
|
|
|
case ePluginUnsupported:
|
|
|
|
type = NS_LITERAL_STRING("PluginNotFound");
|
|
|
|
break;
|
|
|
|
case ePluginDisabled:
|
|
|
|
type = NS_LITERAL_STRING("PluginDisabled");
|
|
|
|
break;
|
|
|
|
case ePluginBlocklisted:
|
|
|
|
type = NS_LITERAL_STRING("PluginBlocklisted");
|
|
|
|
break;
|
2009-10-02 04:26:04 -07:00
|
|
|
case ePluginOutdated:
|
|
|
|
type = NS_LITERAL_STRING("PluginOutdated");
|
|
|
|
break;
|
2008-09-09 08:43:21 -07:00
|
|
|
default:
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsContentUtils::DispatchTrustedEvent(mContent->GetDocument(), mContent,
|
|
|
|
type, PR_TRUE, PR_TRUE);
|
2007-07-13 17:28:05 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
/**
|
|
|
|
* A task for firing PluginCrashed DOM Events.
|
|
|
|
*/
|
|
|
|
class nsPluginCrashedEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2010-03-24 14:22:04 -07:00
|
|
|
nsString mPluginDumpID;
|
|
|
|
nsString mBrowserDumpID;
|
2010-02-09 17:05:31 -08:00
|
|
|
nsString mPluginName;
|
2010-04-08 00:45:00 -07:00
|
|
|
nsString mPluginFilename;
|
2010-02-09 17:05:31 -08:00
|
|
|
PRBool mSubmittedCrashReport;
|
|
|
|
|
|
|
|
nsPluginCrashedEvent(nsIContent* aContent,
|
2010-03-24 14:22:04 -07:00
|
|
|
const nsAString& aPluginDumpID,
|
|
|
|
const nsAString& aBrowserDumpID,
|
2010-02-09 17:05:31 -08:00
|
|
|
const nsAString& aPluginName,
|
2010-04-08 00:45:00 -07:00
|
|
|
const nsAString& aPluginFilename,
|
2010-02-09 17:05:31 -08:00
|
|
|
PRBool submittedCrashReport)
|
|
|
|
: mContent(aContent),
|
2010-03-24 14:22:04 -07:00
|
|
|
mPluginDumpID(aPluginDumpID),
|
|
|
|
mBrowserDumpID(aBrowserDumpID),
|
2010-02-09 17:05:31 -08:00
|
|
|
mPluginName(aPluginName),
|
2010-04-08 00:45:00 -07:00
|
|
|
mPluginFilename(aPluginFilename),
|
2010-02-09 17:05:31 -08:00
|
|
|
mSubmittedCrashReport(submittedCrashReport)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~nsPluginCrashedEvent() {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginCrashedEvent::Run()
|
|
|
|
{
|
|
|
|
LOG(("OBJLC []: Firing plugin crashed event for content %p\n",
|
|
|
|
mContent.get()));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocumentEvent> domEventDoc =
|
|
|
|
do_QueryInterface(mContent->GetDocument());
|
|
|
|
if (!domEventDoc) {
|
|
|
|
NS_WARNING("Couldn't get document for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEvent> event;
|
|
|
|
domEventDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"),
|
|
|
|
getter_AddRefs(event));
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
|
|
|
|
nsCOMPtr<nsIDOMDataContainerEvent> containerEvent(do_QueryInterface(event));
|
|
|
|
if (!privateEvent || !containerEvent) {
|
|
|
|
NS_WARNING("Couldn't QI event for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
event->InitEvent(NS_LITERAL_STRING("PluginCrashed"), PR_TRUE, PR_TRUE);
|
|
|
|
privateEvent->SetTrusted(PR_TRUE);
|
|
|
|
privateEvent->GetInternalNSEvent()->flags |= NS_EVENT_FLAG_ONLY_CHROME_DISPATCH;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWritableVariant> variant;
|
|
|
|
|
2010-03-24 14:22:04 -07:00
|
|
|
// add a "pluginDumpID" property to this event
|
2010-03-16 22:10:08 -07:00
|
|
|
variant = do_CreateInstance("@mozilla.org/variant;1");
|
|
|
|
if (!variant) {
|
2010-03-24 14:22:04 -07:00
|
|
|
NS_WARNING("Couldn't create pluginDumpID variant for PluginCrashed event!");
|
2010-03-16 22:10:08 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-03-24 14:22:04 -07:00
|
|
|
variant->SetAsAString(mPluginDumpID);
|
|
|
|
containerEvent->SetData(NS_LITERAL_STRING("pluginDumpID"), variant);
|
|
|
|
|
|
|
|
// add a "browserDumpID" property to this event
|
|
|
|
variant = do_CreateInstance("@mozilla.org/variant;1");
|
|
|
|
if (!variant) {
|
|
|
|
NS_WARNING("Couldn't create browserDumpID variant for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
variant->SetAsAString(mBrowserDumpID);
|
|
|
|
containerEvent->SetData(NS_LITERAL_STRING("browserDumpID"), variant);
|
2010-03-16 22:10:08 -07:00
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
// add a "pluginName" property to this event
|
|
|
|
variant = do_CreateInstance("@mozilla.org/variant;1");
|
|
|
|
if (!variant) {
|
|
|
|
NS_WARNING("Couldn't create pluginName variant for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
variant->SetAsAString(mPluginName);
|
|
|
|
containerEvent->SetData(NS_LITERAL_STRING("pluginName"), variant);
|
|
|
|
|
2010-04-08 00:45:00 -07:00
|
|
|
// add a "pluginFilename" property to this event
|
|
|
|
variant = do_CreateInstance("@mozilla.org/variant;1");
|
|
|
|
if (!variant) {
|
|
|
|
NS_WARNING("Couldn't create pluginFilename variant for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
variant->SetAsAString(mPluginFilename);
|
|
|
|
containerEvent->SetData(NS_LITERAL_STRING("pluginFilename"), variant);
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
// add a "submittedCrashReport" property to this event
|
|
|
|
variant = do_CreateInstance("@mozilla.org/variant;1");
|
|
|
|
if (!variant) {
|
|
|
|
NS_WARNING("Couldn't create crashSubmit variant for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
variant->SetAsBool(mSubmittedCrashReport);
|
|
|
|
containerEvent->SetData(NS_LITERAL_STRING("submittedCrashReport"), variant);
|
|
|
|
|
|
|
|
nsEventDispatcher::DispatchDOMEvent(mContent, nsnull, event, nsnull, nsnull);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class AutoNotifier {
|
|
|
|
public:
|
|
|
|
AutoNotifier(nsObjectLoadingContent* aContent, PRBool aNotify) :
|
|
|
|
mContent(aContent), mNotify(aNotify) {
|
|
|
|
mOldType = aContent->Type();
|
|
|
|
mOldState = aContent->ObjectState();
|
|
|
|
}
|
|
|
|
~AutoNotifier() {
|
|
|
|
if (mNotify) {
|
|
|
|
mContent->NotifyStateChanged(mOldType, mOldState, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send notifications now, ignoring the value of mNotify. The new type and
|
|
|
|
* state is saved, and the destructor will notify again if mNotify is true
|
|
|
|
* and the values changed.
|
|
|
|
*/
|
|
|
|
void Notify() {
|
|
|
|
NS_ASSERTION(mNotify, "Should not notify when notify=false");
|
|
|
|
|
|
|
|
mContent->NotifyStateChanged(mOldType, mOldState, PR_TRUE);
|
|
|
|
mOldType = mContent->Type();
|
|
|
|
mOldState = mContent->ObjectState();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsObjectLoadingContent* mContent;
|
|
|
|
PRBool mNotify;
|
|
|
|
nsObjectLoadingContent::ObjectType mOldType;
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates mOldState;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that will automatically fall back if a |rv| variable has a failure
|
|
|
|
* code when this class is destroyed. It does not notify.
|
|
|
|
*/
|
|
|
|
class AutoFallback {
|
|
|
|
public:
|
|
|
|
AutoFallback(nsObjectLoadingContent* aContent, const nsresult* rv)
|
2008-09-09 08:43:21 -07:00
|
|
|
: mContent(aContent), mResult(rv), mPluginState(ePluginOtherState) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
~AutoFallback() {
|
|
|
|
if (NS_FAILED(*mResult)) {
|
|
|
|
LOG(("OBJLC [%p]: rv=%08x, falling back\n", mContent, *mResult));
|
|
|
|
mContent->Fallback(PR_FALSE);
|
2008-09-09 08:43:21 -07:00
|
|
|
if (mPluginState != ePluginOtherState) {
|
2010-01-13 08:42:41 -08:00
|
|
|
mContent->mFallbackReason = mPluginState;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-09 08:43:21 -07:00
|
|
|
* This should be set to something other than ePluginOtherState to indicate
|
|
|
|
* a specific failure that should be passed on.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2008-09-09 08:43:21 -07:00
|
|
|
void SetPluginState(PluginSupportState aState) {
|
|
|
|
NS_ASSERTION(aState != ePluginOtherState, "Should not be setting ePluginOtherState");
|
|
|
|
mPluginState = aState;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsObjectLoadingContent* mContent;
|
|
|
|
const nsresult* mResult;
|
2008-09-09 08:43:21 -07:00
|
|
|
PluginSupportState mPluginState;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class that automatically sets mInstantiating to false when it goes
|
|
|
|
* out of scope.
|
|
|
|
*/
|
|
|
|
class AutoSetInstantiatingToFalse {
|
|
|
|
public:
|
|
|
|
AutoSetInstantiatingToFalse(nsObjectLoadingContent* objlc) : mContent(objlc) {}
|
|
|
|
~AutoSetInstantiatingToFalse() { mContent->mInstantiating = PR_FALSE; }
|
|
|
|
private:
|
|
|
|
nsObjectLoadingContent* mContent;
|
|
|
|
};
|
|
|
|
|
|
|
|
// helper functions
|
|
|
|
static PRBool
|
|
|
|
IsSupportedImage(const nsCString& aMimeType)
|
|
|
|
{
|
|
|
|
imgILoader* loader = nsContentUtils::GetImgLoader();
|
|
|
|
if (!loader) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool supported;
|
|
|
|
nsresult rv = loader->SupportImageWithMimeType(aMimeType.get(), &supported);
|
|
|
|
return NS_SUCCEEDED(rv) && supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRBool
|
|
|
|
IsSupportedPlugin(const nsCString& aMIMEType)
|
|
|
|
{
|
2009-06-25 14:06:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!host) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
nsresult rv = host->IsPluginEnabledForType(aMIMEType.get());
|
|
|
|
return NS_SUCCEEDED(rv);
|
|
|
|
}
|
|
|
|
|
2007-07-18 14:48:18 -07:00
|
|
|
static void
|
|
|
|
GetExtensionFromURI(nsIURI* uri, nsCString& ext)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
|
|
|
if (url) {
|
|
|
|
url->GetFileExtension(ext);
|
|
|
|
} else {
|
|
|
|
nsCString spec;
|
|
|
|
uri->GetSpec(spec);
|
|
|
|
|
|
|
|
PRInt32 offset = spec.RFindChar('.');
|
|
|
|
if (offset != kNotFound) {
|
|
|
|
ext = Substring(spec, offset + 1, spec.Length());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether a plugin exists and is enabled for the extension
|
|
|
|
* in the given URI. The MIME type is returned in the mimeType out parameter.
|
|
|
|
*/
|
|
|
|
static PRBool
|
|
|
|
IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType)
|
|
|
|
{
|
|
|
|
nsCAutoString ext;
|
|
|
|
GetExtensionFromURI(uri, ext);
|
|
|
|
|
2007-08-06 11:02:14 -07:00
|
|
|
if (ext.IsEmpty())
|
|
|
|
return PR_FALSE;
|
|
|
|
|
2009-06-25 14:06:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
2007-07-18 14:48:18 -07:00
|
|
|
const char* typeFromExt;
|
|
|
|
if (host &&
|
|
|
|
NS_SUCCEEDED(host->IsPluginEnabledForExtension(ext.get(), typeFromExt))) {
|
|
|
|
mimeType = typeFromExt;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsObjectLoadingContent::nsObjectLoadingContent()
|
2007-07-05 15:44:27 -07:00
|
|
|
: mPendingInstantiateEvent(nsnull)
|
|
|
|
, mChannel(nsnull)
|
2007-03-22 10:30:00 -07:00
|
|
|
, mType(eType_Loading)
|
|
|
|
, mInstantiating(PR_FALSE)
|
|
|
|
, mUserDisabled(PR_FALSE)
|
|
|
|
, mSuppressed(PR_FALSE)
|
2010-08-17 07:13:55 -07:00
|
|
|
, mNetworkCreated(PR_TRUE)
|
2010-01-13 08:42:41 -08:00
|
|
|
, mFallbackReason(ePluginOtherState)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsObjectLoadingContent::~nsObjectLoadingContent()
|
|
|
|
{
|
|
|
|
DestroyImageLoadingContent();
|
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIRequestObserver
|
|
|
|
NS_IMETHODIMP
|
2008-03-27 16:12:18 -07:00
|
|
|
nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aRequest != mChannel) {
|
|
|
|
// This is a bit of an edge case - happens when a new load starts before the
|
|
|
|
// previous one got here
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoNotifier notifier(this, PR_TRUE);
|
|
|
|
|
|
|
|
if (!IsSuccessfulRequest(aRequest)) {
|
|
|
|
LOG(("OBJLC [%p]: OnStartRequest: Request failed\n", this));
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
|
|
|
|
NS_ASSERTION(chan, "Why is our request not a channel?");
|
|
|
|
|
|
|
|
nsresult rv = NS_ERROR_UNEXPECTED;
|
|
|
|
// This fallback variable MUST be declared after the notifier variable. Do NOT
|
|
|
|
// change the order of the declarations!
|
|
|
|
AutoFallback fallback(this, &rv);
|
|
|
|
|
2007-08-20 20:26:12 -07:00
|
|
|
nsCString channelType;
|
|
|
|
rv = chan->GetContentType(channelType);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2007-08-20 20:26:12 -07:00
|
|
|
if (channelType.EqualsASCII(APPLICATION_GUESS_FROM_EXT)) {
|
|
|
|
channelType = APPLICATION_OCTET_STREAM;
|
|
|
|
chan->SetContentType(channelType);
|
|
|
|
}
|
2008-03-17 17:36:14 -07:00
|
|
|
|
|
|
|
// We want to use the channel type unless one of the following is
|
|
|
|
// true:
|
|
|
|
//
|
|
|
|
// 1) The channel type is application/octet-stream and we have a
|
2009-12-02 20:56:59 -08:00
|
|
|
// type hint and the type hint is not a document type.
|
2008-03-17 17:36:14 -07:00
|
|
|
// 2) Our type hint is a type that we support with a plugin.
|
|
|
|
|
|
|
|
if ((channelType.EqualsASCII(APPLICATION_OCTET_STREAM) &&
|
2009-12-02 20:56:59 -08:00
|
|
|
!mContentType.IsEmpty() &&
|
|
|
|
GetTypeOfContent(mContentType) != eType_Document) ||
|
|
|
|
// Need to check IsSupportedPlugin() in addition to GetTypeOfContent()
|
|
|
|
// because otherwise the default plug-in's catch-all behavior would
|
|
|
|
// confuse things.
|
2008-03-17 17:36:14 -07:00
|
|
|
(IsSupportedPlugin(mContentType) &&
|
|
|
|
GetTypeOfContent(mContentType) == eType_Plugin)) {
|
2007-08-20 20:26:12 -07:00
|
|
|
// Set the type we'll use for dispatch on the channel. Otherwise we could
|
|
|
|
// end up trying to dispatch to a nsFrameLoader, which will complain that
|
|
|
|
// it couldn't find a way to handle application/octet-stream
|
2008-03-17 17:36:14 -07:00
|
|
|
|
2010-07-22 14:33:38 -07:00
|
|
|
nsCAutoString typeHint, dummy;
|
|
|
|
NS_ParseContentType(mContentType, typeHint, dummy);
|
|
|
|
if (!typeHint.IsEmpty()) {
|
|
|
|
chan->SetContentType(typeHint);
|
|
|
|
}
|
2008-03-17 17:36:14 -07:00
|
|
|
} else {
|
|
|
|
mContentType = channelType;
|
2007-08-20 20:26:12 -07:00
|
|
|
}
|
|
|
|
|
2008-03-27 16:12:18 -07:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
chan->GetURI(getter_AddRefs(uri));
|
|
|
|
|
|
|
|
if (mContentType.EqualsASCII(APPLICATION_OCTET_STREAM)) {
|
|
|
|
nsCAutoString extType;
|
|
|
|
if (IsPluginEnabledByExtension(uri, extType)) {
|
|
|
|
mContentType = extType;
|
|
|
|
chan->SetContentType(extType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Now find out what type the content is
|
|
|
|
// UnloadContent will set our type to null; need to be sure to only set it to
|
|
|
|
// the real value on success
|
|
|
|
ObjectType newType = GetTypeOfContent(mContentType);
|
|
|
|
LOG(("OBJLC [%p]: OnStartRequest: Content Type=<%s> Old type=%u New Type=%u\n",
|
|
|
|
this, mContentType.get(), mType, newType));
|
|
|
|
|
2007-09-14 11:57:59 -07:00
|
|
|
// Now do a content policy check
|
|
|
|
// XXXbz this duplicates some code in nsContentBlocker::ShouldLoad
|
|
|
|
PRInt32 contentPolicyType;
|
|
|
|
switch (newType) {
|
|
|
|
case eType_Image:
|
|
|
|
contentPolicyType = nsIContentPolicy::TYPE_IMAGE;
|
|
|
|
break;
|
|
|
|
case eType_Document:
|
|
|
|
contentPolicyType = nsIContentPolicy::TYPE_SUBDOCUMENT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
contentPolicyType = nsIContentPolicy::TYPE_OBJECT;
|
|
|
|
break;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
2007-09-14 11:57:59 -07:00
|
|
|
|
|
|
|
nsIDocument* doc = thisContent->GetOwnerDoc();
|
|
|
|
if (!doc) {
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt16 shouldProcess = nsIContentPolicy::ACCEPT;
|
|
|
|
rv =
|
|
|
|
NS_CheckContentProcessPolicy(contentPolicyType,
|
|
|
|
uri,
|
|
|
|
doc->NodePrincipal(),
|
|
|
|
static_cast<nsIImageLoadingContent*>(this),
|
|
|
|
mContentType,
|
|
|
|
nsnull, //extra
|
|
|
|
&shouldProcess,
|
|
|
|
nsContentUtils::GetContentPolicy(),
|
|
|
|
nsContentUtils::GetSecurityManager());
|
|
|
|
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldProcess)) {
|
|
|
|
HandleBeingBlockedByContentPolicy(rv, shouldProcess);
|
|
|
|
rv = NS_OK; // otherwise, the AutoFallback will make us fall back
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mType != newType) {
|
|
|
|
UnloadContent();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (newType) {
|
|
|
|
case eType_Image:
|
|
|
|
rv = LoadImageWithChannel(chan, getter_AddRefs(mFinalListener));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// If we have a success result but no final listener, then the image is
|
|
|
|
// cached. In that case, we can just return: No need to try to call the
|
|
|
|
// final listener.
|
|
|
|
if (!mFinalListener) {
|
|
|
|
mType = newType;
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eType_Document: {
|
|
|
|
if (!mFrameLoader) {
|
2010-08-17 07:13:55 -07:00
|
|
|
mFrameLoader = nsFrameLoader::Create(thisContent, mNetworkCreated);
|
2009-08-19 02:09:26 -07:00
|
|
|
if (!mFrameLoader) {
|
2007-03-22 10:30:00 -07:00
|
|
|
Fallback(PR_FALSE);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-17 00:43:36 -07:00
|
|
|
rv = mFrameLoader->CheckForRecursiveLoad(uri);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mType != newType) {
|
|
|
|
// XXX We must call this before getting the docshell to work around
|
|
|
|
// bug 300540; when that's fixed, this if statement can be removed.
|
|
|
|
mType = newType;
|
|
|
|
notifier.Notify();
|
2009-10-02 06:48:23 -07:00
|
|
|
|
|
|
|
if (!mFrameLoader) {
|
|
|
|
// mFrameLoader got nulled out when we notified, which most
|
|
|
|
// likely means the node was removed from the
|
|
|
|
// document. Abort the load that just started.
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-23 01:44:27 -07:00
|
|
|
// We're loading a document, so we have to set LOAD_DOCUMENT_URI
|
|
|
|
// (especially important for firing onload)
|
|
|
|
nsLoadFlags flags = 0;
|
|
|
|
chan->GetLoadFlags(&flags);
|
|
|
|
flags |= nsIChannel::LOAD_DOCUMENT_URI;
|
|
|
|
chan->SetLoadFlags(flags);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
|
|
|
rv = mFrameLoader->GetDocShell(getter_AddRefs(docShell));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(docShell));
|
|
|
|
NS_ASSERTION(req, "Docshell must be an ifreq");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURILoader>
|
|
|
|
uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = uriLoader->OpenChannel(chan, nsIURILoader::DONT_RETARGET, req,
|
|
|
|
getter_AddRefs(mFinalListener));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case eType_Plugin:
|
|
|
|
mInstantiating = PR_TRUE;
|
|
|
|
if (mType != newType) {
|
|
|
|
// This can go away once plugin loading moves to content (bug 90268)
|
|
|
|
mType = newType;
|
|
|
|
notifier.Notify();
|
|
|
|
}
|
|
|
|
nsIObjectFrame* frame;
|
2008-03-14 16:08:57 -07:00
|
|
|
frame = GetExistingFrame(eFlushLayout);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!frame) {
|
|
|
|
// Do nothing in this case: This is probably due to a display:none
|
|
|
|
// frame. If we ever get a frame, HasNewFrame will do the right thing.
|
|
|
|
// Abort the load though, we have no use for the data.
|
|
|
|
mInstantiating = PR_FALSE;
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
2008-02-28 18:06:00 -08:00
|
|
|
|
|
|
|
{
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIFrame *nsiframe = do_QueryFrame(frame);
|
2008-02-28 18:06:00 -08:00
|
|
|
|
|
|
|
nsWeakFrame weakFrame(nsiframe);
|
|
|
|
|
|
|
|
rv = frame->Instantiate(chan, getter_AddRefs(mFinalListener));
|
|
|
|
|
|
|
|
mInstantiating = PR_FALSE;
|
|
|
|
|
|
|
|
if (!weakFrame.IsAlive()) {
|
|
|
|
// The frame was destroyed while instantiating. Abort the load.
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eType_Loading:
|
|
|
|
NS_NOTREACHED("Should not have a loading type here!");
|
|
|
|
case eType_Null:
|
|
|
|
LOG(("OBJLC [%p]: Unsupported type, falling back\n", this));
|
|
|
|
// Need to fallback here (instead of using the case below), so that we can
|
2010-01-13 08:42:41 -08:00
|
|
|
// set mFallbackReason without it being overwritten. This is also why we
|
2007-03-22 10:30:00 -07:00
|
|
|
// return early.
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
|
|
|
|
PluginSupportState pluginState = GetPluginSupportState(thisContent,
|
|
|
|
mContentType);
|
|
|
|
// Do nothing, but fire the plugin not found event if needed
|
2008-09-09 08:43:21 -07:00
|
|
|
if (pluginState != ePluginOtherState) {
|
2010-01-13 08:42:41 -08:00
|
|
|
mFallbackReason = pluginState;
|
2008-09-09 08:43:21 -07:00
|
|
|
FirePluginError(thisContent, pluginState);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFinalListener) {
|
|
|
|
mType = newType;
|
|
|
|
rv = mFinalListener->OnStartRequest(aRequest, aContext);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(("OBJLC [%p]: mFinalListener->OnStartRequest failed (%08x), falling back\n",
|
|
|
|
this, rv));
|
2007-08-02 13:16:49 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Shockwave on Mac is special and returns an error here even when it
|
|
|
|
// handles the content
|
|
|
|
if (mContentType.EqualsLiteral("application/x-director")) {
|
|
|
|
LOG(("OBJLC [%p]: (ignoring)\n", this));
|
|
|
|
rv = NS_OK; // otherwise, the AutoFallback will make us fall back
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
Fallback(PR_FALSE);
|
2007-08-02 14:15:05 -07:00
|
|
|
} else if (mType == eType_Plugin) {
|
2008-03-14 16:08:57 -07:00
|
|
|
nsIObjectFrame* frame = GetExistingFrame(eFlushContent);
|
2007-08-02 14:15:05 -07:00
|
|
|
if (frame) {
|
|
|
|
// We have to notify the wrapper here instead of right after
|
|
|
|
// Instantiate because the plugin only gets instantiated by
|
|
|
|
// OnStartRequest, not by Instantiate.
|
|
|
|
frame->TryNotifyContentObjectWrapper();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG(("OBJLC [%p]: Found no listener, falling back\n", this));
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::OnStopRequest(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsresult aStatusCode)
|
|
|
|
{
|
|
|
|
if (aRequest != mChannel) {
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
mChannel = nsnull;
|
|
|
|
|
|
|
|
if (mFinalListener) {
|
|
|
|
mFinalListener->OnStopRequest(aRequest, aContext, aStatusCode);
|
|
|
|
mFinalListener = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return value doesn't matter
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nsIStreamListener
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aInputStream, PRUint32 aOffset, PRUint32 aCount)
|
|
|
|
{
|
|
|
|
if (aRequest != mChannel) {
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFinalListener) {
|
|
|
|
return mFinalListener->OnDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Abort this load if we have no listener here
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIFrameLoaderOwner
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetFrameLoader(nsIFrameLoader** aFrameLoader)
|
|
|
|
{
|
|
|
|
*aFrameLoader = mFrameLoader;
|
|
|
|
NS_IF_ADDREF(*aFrameLoader);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-20 14:33:59 -07:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<nsFrameLoader>)
|
|
|
|
nsObjectLoadingContent::GetFrameLoader()
|
|
|
|
{
|
|
|
|
nsFrameLoader* loader = mFrameLoader;
|
|
|
|
NS_IF_ADDREF(loader);
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
2008-08-11 01:38:43 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::SwapFrameLoaders(nsIFrameLoaderOwner* aOtherLoader)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIObjectLoadingContent
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetActualType(nsACString& aType)
|
|
|
|
{
|
|
|
|
aType = mContentType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetDisplayedType(PRUint32* aType)
|
|
|
|
{
|
|
|
|
*aType = mType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::EnsureInstantiation(nsIPluginInstance** aInstance)
|
|
|
|
{
|
|
|
|
// Must set our out parameter to null as we have various early returns with
|
|
|
|
// an NS_OK result.
|
|
|
|
*aInstance = nsnull;
|
|
|
|
|
|
|
|
if (mType != eType_Plugin) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-14 16:08:57 -07:00
|
|
|
nsIObjectFrame* frame = GetExistingFrame(eFlushContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (frame) {
|
|
|
|
// If we have a frame, we may have pending instantiate events; revoke
|
|
|
|
// them.
|
|
|
|
if (mPendingInstantiateEvent) {
|
|
|
|
LOG(("OBJLC [%p]: Revoking pending instantiate event\n", this));
|
|
|
|
mPendingInstantiateEvent = nsnull;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// mInstantiating is true if we're in LoadObject; we shouldn't
|
|
|
|
// recreate frames in that case, we'd confuse that function.
|
|
|
|
if (mInstantiating) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trigger frame construction
|
|
|
|
mInstantiating = PR_TRUE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
nsIDocument* doc = thisContent->GetCurrentDoc();
|
|
|
|
if (!doc) {
|
|
|
|
// Nothing we can do while plugin loading is done in layout...
|
2007-07-18 17:28:39 -07:00
|
|
|
mInstantiating = PR_FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:43:47 -08:00
|
|
|
doc->FlushPendingNotifications(Flush_Frames);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mInstantiating = PR_FALSE;
|
|
|
|
|
2008-03-14 16:08:57 -07:00
|
|
|
frame = GetExistingFrame(eFlushContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!frame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIFrame *nsiframe = do_QueryFrame(frame);
|
2009-02-02 17:26:28 -08:00
|
|
|
|
|
|
|
if (nsiframe->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
// A frame for this plugin element already exists now, but it has
|
2009-07-27 01:46:59 -07:00
|
|
|
// not been reflowed yet. Force a reflow now so that we don't end
|
2009-02-02 17:26:28 -08:00
|
|
|
// up initializing a plugin before knowing its size. Also re-fetch
|
|
|
|
// the frame, as flushing can cause the frame to be deleted.
|
|
|
|
frame = GetExistingFrame(eFlushLayout);
|
|
|
|
|
|
|
|
if (!frame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsiframe = do_QueryFrame(frame);
|
|
|
|
}
|
|
|
|
|
2008-02-28 18:06:00 -08:00
|
|
|
nsWeakFrame weakFrame(nsiframe);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// We may have a plugin instance already; if so, do nothing
|
|
|
|
nsresult rv = frame->GetPluginInstance(*aInstance);
|
2008-02-28 18:06:00 -08:00
|
|
|
if (!*aInstance && weakFrame.IsAlive()) {
|
2007-08-06 17:32:14 -07:00
|
|
|
rv = Instantiate(frame, mContentType, mURI);
|
2008-02-28 18:06:00 -08:00
|
|
|
if (NS_SUCCEEDED(rv) && weakFrame.IsAlive()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
rv = frame->GetPluginInstance(*aInstance);
|
|
|
|
} else {
|
|
|
|
Fallback(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
|
|
|
|
{
|
|
|
|
LOG(("OBJLC [%p]: Got frame %p (mInstantiating=%i)\n", this, aFrame,
|
|
|
|
mInstantiating));
|
2008-06-27 12:54:27 -07:00
|
|
|
|
2009-12-10 20:02:13 -08:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
nsIDocument* doc = thisContent->GetOwnerDoc();
|
2011-02-17 21:52:03 -08:00
|
|
|
if (!doc || doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) {
|
2009-12-10 20:02:13 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-02-17 21:52:03 -08:00
|
|
|
|
2008-06-27 12:54:27 -07:00
|
|
|
// "revoke" any existing instantiate event as it likely has out of
|
|
|
|
// date data (frame pointer etc).
|
|
|
|
mPendingInstantiateEvent = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPluginInstance> instance;
|
|
|
|
aFrame->GetPluginInstance(*getter_AddRefs(instance));
|
|
|
|
|
|
|
|
if (instance) {
|
|
|
|
// The frame already has a plugin instance, that means the plugin
|
|
|
|
// has already been instantiated.
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mInstantiating && mType == eType_Plugin) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Asynchronously call Instantiate
|
|
|
|
// This can go away once plugin loading moves to content
|
|
|
|
// This must be done asynchronously to ensure that the frame is correctly
|
|
|
|
// initialized (has a view etc)
|
|
|
|
|
|
|
|
// When in a plugin document, the document will take care of calling
|
|
|
|
// instantiate
|
|
|
|
nsCOMPtr<nsIPluginDocument> pDoc (do_QueryInterface(GetOurDocument()));
|
|
|
|
if (pDoc) {
|
2008-10-07 11:53:23 -07:00
|
|
|
PRBool willHandleInstantiation;
|
|
|
|
pDoc->GetWillHandleInstantiation(&willHandleInstantiation);
|
|
|
|
if (willHandleInstantiation) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIFrame* frame = do_QueryFrame(aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIRunnable> event =
|
2008-12-03 02:53:50 -08:00
|
|
|
new nsAsyncInstantiateEvent(this, frame, mContentType, mURI);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!event) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG((" dispatching event\n"));
|
|
|
|
nsresult rv = NS_DispatchToCurrentThread(event);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("failed to dispatch nsAsyncInstantiateEvent");
|
|
|
|
} else {
|
|
|
|
// Remember this event. This is a weak reference that will be cleared
|
|
|
|
// when the event runs.
|
|
|
|
mPendingInstantiateEvent = event;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-14 16:08:57 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetPluginInstance(nsIPluginInstance** aInstance)
|
|
|
|
{
|
|
|
|
*aInstance = nsnull;
|
|
|
|
|
|
|
|
nsIObjectFrame* objFrame = GetExistingFrame(eDontFlush);
|
|
|
|
if (!objFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return objFrame->GetPluginInstance(*aInstance);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetContentTypeForMIMEType(const nsACString& aMIMEType,
|
|
|
|
PRUint32* aType)
|
|
|
|
{
|
|
|
|
*aType = GetTypeOfContent(PromiseFlatCString(aMIMEType));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIInterfaceRequestor
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetInterface(const nsIID & aIID, void **aResult)
|
|
|
|
{
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
|
|
|
|
nsIChannelEventSink* sink = this;
|
|
|
|
*aResult = sink;
|
|
|
|
NS_ADDREF(sink);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIChannelEventSink
|
|
|
|
NS_IMETHODIMP
|
2010-08-04 19:15:55 -07:00
|
|
|
nsObjectLoadingContent::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
|
|
|
nsIChannel *aNewChannel,
|
|
|
|
PRUint32 aFlags,
|
|
|
|
nsIAsyncVerifyRedirectCallback *cb)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// If we're already busy with a new load, cancel the redirect
|
|
|
|
if (aOldChannel != mChannel) {
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
mChannel = aNewChannel;
|
2010-08-04 19:15:55 -07:00
|
|
|
cb->OnRedirectVerifyCallback(NS_OK);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// <public>
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates
|
2007-03-22 10:30:00 -07:00
|
|
|
nsObjectLoadingContent::ObjectState() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eType_Loading:
|
|
|
|
return NS_EVENT_STATE_LOADING;
|
|
|
|
case eType_Image:
|
|
|
|
return ImageState();
|
|
|
|
case eType_Plugin:
|
|
|
|
case eType_Document:
|
|
|
|
// These are OK. If documents start to load successfully, they display
|
|
|
|
// something, and are thus not broken in this sense. The same goes for
|
|
|
|
// plugins.
|
2010-10-20 04:26:32 -07:00
|
|
|
return nsEventStates();
|
2007-03-22 10:30:00 -07:00
|
|
|
case eType_Null:
|
|
|
|
if (mSuppressed)
|
|
|
|
return NS_EVENT_STATE_SUPPRESSED;
|
|
|
|
if (mUserDisabled)
|
|
|
|
return NS_EVENT_STATE_USERDISABLED;
|
|
|
|
|
|
|
|
// Otherwise, broken
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates state = NS_EVENT_STATE_BROKEN;
|
2010-01-13 08:42:41 -08:00
|
|
|
switch (mFallbackReason) {
|
2008-09-09 08:43:21 -07:00
|
|
|
case ePluginDisabled:
|
|
|
|
state |= NS_EVENT_STATE_HANDLER_DISABLED;
|
|
|
|
break;
|
|
|
|
case ePluginBlocklisted:
|
|
|
|
state |= NS_EVENT_STATE_HANDLER_BLOCKED;
|
|
|
|
break;
|
2010-02-09 17:05:31 -08:00
|
|
|
case ePluginCrashed:
|
|
|
|
state |= NS_EVENT_STATE_HANDLER_CRASHED;
|
|
|
|
break;
|
2008-09-09 08:43:21 -07:00
|
|
|
case ePluginUnsupported:
|
|
|
|
state |= NS_EVENT_STATE_TYPE_UNSUPPORTED;
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
};
|
|
|
|
NS_NOTREACHED("unknown type?");
|
|
|
|
// this return statement only exists to avoid a compile warning
|
2010-10-20 04:26:32 -07:00
|
|
|
return nsEventStates();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// <protected>
|
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::LoadObject(const nsAString& aURI,
|
|
|
|
PRBool aNotify,
|
|
|
|
const nsCString& aTypeHint,
|
|
|
|
PRBool aForceLoad)
|
|
|
|
{
|
|
|
|
LOG(("OBJLC [%p]: Loading object: URI string=<%s> notify=%i type=<%s> forceload=%i\n",
|
|
|
|
this, NS_ConvertUTF16toUTF8(aURI).get(), aNotify, aTypeHint.get(), aForceLoad));
|
|
|
|
|
|
|
|
NS_ASSERTION(!mInstantiating, "LoadObject was reentered?");
|
|
|
|
|
|
|
|
// Avoid StringToURI in order to use the codebase attribute as base URI
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
nsIDocument* doc = thisContent->GetOwnerDoc();
|
|
|
|
nsCOMPtr<nsIURI> baseURI;
|
|
|
|
GetObjectBaseURI(thisContent, getter_AddRefs(baseURI));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
|
|
|
aURI, doc,
|
|
|
|
baseURI);
|
|
|
|
// If URI creation failed, fallback immediately - this only happens for
|
|
|
|
// malformed URIs
|
|
|
|
if (!uri) {
|
|
|
|
Fallback(aNotify);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_TryToSetImmutable(uri);
|
|
|
|
|
|
|
|
return LoadObject(uri, aNotify, aTypeHint, aForceLoad);
|
|
|
|
}
|
|
|
|
|
2007-12-03 13:57:17 -08:00
|
|
|
static PRBool
|
|
|
|
IsAboutBlank(nsIURI* aURI)
|
|
|
|
{
|
|
|
|
// XXXbz this duplicates an nsDocShell function, sadly
|
|
|
|
NS_PRECONDITION(aURI, "Must have URI");
|
|
|
|
|
|
|
|
// GetSpec can be expensive for some URIs, so check the scheme first.
|
|
|
|
PRBool isAbout = PR_FALSE;
|
|
|
|
if (NS_FAILED(aURI->SchemeIs("about", &isAbout)) || !isAbout) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCAutoString str;
|
|
|
|
aURI->GetSpec(str);
|
|
|
|
return str.EqualsLiteral("about:blank");
|
|
|
|
}
|
|
|
|
|
2008-02-26 16:29:02 -08:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::UpdateFallbackState(nsIContent* aContent,
|
|
|
|
AutoFallback& fallback,
|
|
|
|
const nsCString& aTypeHint)
|
|
|
|
{
|
2008-09-09 08:43:21 -07:00
|
|
|
// Notify the UI and update the fallback state
|
|
|
|
PluginSupportState state = GetPluginSupportState(aContent, aTypeHint);
|
|
|
|
if (state != ePluginOtherState) {
|
|
|
|
fallback.SetPluginState(state);
|
|
|
|
FirePluginError(aContent, state);
|
2008-02-26 16:29:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::LoadObject(nsIURI* aURI,
|
|
|
|
PRBool aNotify,
|
|
|
|
const nsCString& aTypeHint,
|
|
|
|
PRBool aForceLoad)
|
|
|
|
{
|
|
|
|
LOG(("OBJLC [%p]: Loading object: URI=<%p> notify=%i type=<%s> forceload=%i\n",
|
|
|
|
this, aURI, aNotify, aTypeHint.get(), aForceLoad));
|
|
|
|
|
|
|
|
if (mURI && aURI && !aForceLoad) {
|
|
|
|
PRBool equal;
|
|
|
|
nsresult rv = mURI->Equals(aURI, &equal);
|
|
|
|
if (NS_SUCCEEDED(rv) && equal) {
|
|
|
|
// URI didn't change, do nothing
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to revoke any potentially pending instantiate events
|
|
|
|
if (mType == eType_Plugin && mPendingInstantiateEvent) {
|
|
|
|
LOG(("OBJLC [%p]: Revoking pending instantiate event\n", this));
|
|
|
|
mPendingInstantiateEvent = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoNotifier notifier(this, aNotify);
|
|
|
|
|
|
|
|
// AutoSetInstantiatingToFalse is instantiated after AutoNotifier, so that if
|
|
|
|
// the AutoNotifier triggers frame construction, events can be posted as
|
|
|
|
// appropriate.
|
|
|
|
NS_ASSERTION(!mInstantiating, "LoadObject was reentered?");
|
|
|
|
mInstantiating = PR_TRUE;
|
|
|
|
AutoSetInstantiatingToFalse autoset(this);
|
|
|
|
|
|
|
|
mUserDisabled = mSuppressed = PR_FALSE;
|
|
|
|
|
|
|
|
mURI = aURI;
|
|
|
|
mContentType = aTypeHint;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
nsIDocument* doc = thisContent->GetOwnerDoc();
|
|
|
|
if (!doc) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// From here on, we will always change the content. This means that a
|
|
|
|
// possibly-loading channel should be aborted.
|
|
|
|
if (mChannel) {
|
|
|
|
LOG(("OBJLC [%p]: Cancelling existing load\n", this));
|
2008-03-12 14:52:47 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// These three statements are carefully ordered:
|
|
|
|
// - onStopRequest should get a channel whose status is the same as the
|
|
|
|
// status argument
|
|
|
|
// - onStopRequest must get a non-null channel
|
|
|
|
mChannel->Cancel(NS_BINDING_ABORTED);
|
|
|
|
if (mFinalListener) {
|
|
|
|
// NOTE: Since mFinalListener is only set in onStartRequest, which takes
|
|
|
|
// care of calling mFinalListener->OnStartRequest, mFinalListener is only
|
|
|
|
// non-null here if onStartRequest was already called.
|
|
|
|
mFinalListener->OnStopRequest(mChannel, nsnull, NS_BINDING_ABORTED);
|
|
|
|
mFinalListener = nsnull;
|
|
|
|
}
|
|
|
|
mChannel = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Security checks
|
2007-07-26 19:49:18 -07:00
|
|
|
if (doc->IsLoadedAsData()) {
|
2009-12-10 20:02:13 -08:00
|
|
|
if (!doc->IsStaticDocument()) {
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
}
|
2007-07-26 19:49:18 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Can't do security checks without a URI - hopefully the plugin will take
|
|
|
|
// care of that
|
|
|
|
// Null URIs happen when the URL to load is specified via other means than the
|
|
|
|
// data/src attribute, for example via custom <param> elements.
|
|
|
|
if (aURI) {
|
|
|
|
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
|
|
|
|
NS_ASSERTION(secMan, "No security manager!?");
|
|
|
|
nsresult rv =
|
|
|
|
secMan->CheckLoadURIWithPrincipal(thisContent->NodePrincipal(), aURI, 0);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
Fallback(PR_FALSE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; // default permit
|
|
|
|
rv =
|
|
|
|
NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
|
|
|
aURI,
|
2007-08-07 18:16:09 -07:00
|
|
|
doc->NodePrincipal(),
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsIImageLoadingContent*>(this),
|
2007-03-22 10:30:00 -07:00
|
|
|
aTypeHint,
|
|
|
|
nsnull, //extra
|
|
|
|
&shouldLoad,
|
2007-08-07 18:16:09 -07:00
|
|
|
nsContentUtils::GetContentPolicy(),
|
2007-09-14 11:57:59 -07:00
|
|
|
secMan);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
2007-09-14 11:57:59 -07:00
|
|
|
HandleBeingBlockedByContentPolicy(rv, shouldLoad);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = NS_ERROR_UNEXPECTED;
|
|
|
|
// This fallback variable MUST be declared after the notifier variable. Do NOT
|
|
|
|
// change the order of the declarations!
|
|
|
|
AutoFallback fallback(this, &rv);
|
|
|
|
|
|
|
|
PRUint32 caps = GetCapabilities();
|
|
|
|
LOG(("OBJLC [%p]: Capabilities: %04x\n", this, caps));
|
|
|
|
|
2007-07-18 14:48:18 -07:00
|
|
|
nsCAutoString overrideType;
|
|
|
|
if ((caps & eOverrideServerType) &&
|
2008-05-01 15:43:42 -07:00
|
|
|
((!aTypeHint.IsEmpty() && IsSupportedPlugin(aTypeHint)) ||
|
2007-07-18 14:48:18 -07:00
|
|
|
(aURI && IsPluginEnabledByExtension(aURI, overrideType)))) {
|
|
|
|
ObjectType newType;
|
|
|
|
if (overrideType.IsEmpty()) {
|
|
|
|
newType = GetTypeOfContent(aTypeHint);
|
|
|
|
} else {
|
2007-08-06 17:32:14 -07:00
|
|
|
mContentType = overrideType;
|
2007-07-18 14:48:18 -07:00
|
|
|
newType = eType_Plugin;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (newType != mType) {
|
|
|
|
LOG(("OBJLC [%p]: (eOverrideServerType) Changing type from %u to %u\n", this, mType, newType));
|
|
|
|
|
|
|
|
UnloadContent();
|
|
|
|
|
|
|
|
// Must have a frameloader before creating a frame, or the frame will
|
|
|
|
// create its own.
|
|
|
|
if (!mFrameLoader && newType == eType_Document) {
|
2010-08-17 07:13:55 -07:00
|
|
|
mFrameLoader = nsFrameLoader::Create(thisContent, mNetworkCreated);
|
2009-08-19 02:09:26 -07:00
|
|
|
if (!mFrameLoader) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mURI = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Must notify here for plugins
|
|
|
|
// If aNotify is false, we'll just wait until we get a frame and use the
|
|
|
|
// async instantiate path.
|
2007-08-06 17:32:14 -07:00
|
|
|
// XXX is this still needed? (for documents?)
|
2007-03-22 10:30:00 -07:00
|
|
|
mType = newType;
|
|
|
|
if (aNotify)
|
|
|
|
notifier.Notify();
|
|
|
|
}
|
|
|
|
switch (newType) {
|
|
|
|
case eType_Image:
|
|
|
|
// Don't notify, because we will take care of that ourselves.
|
2007-11-07 09:25:57 -08:00
|
|
|
if (aURI) {
|
|
|
|
rv = LoadImage(aURI, aForceLoad, PR_FALSE);
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eType_Plugin:
|
2007-08-06 17:32:14 -07:00
|
|
|
rv = TryInstantiate(mContentType, mURI);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eType_Document:
|
2007-11-07 09:25:57 -08:00
|
|
|
if (aURI) {
|
|
|
|
rv = mFrameLoader->LoadURI(aURI);
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case eType_Loading:
|
|
|
|
NS_NOTREACHED("Should not have a loading type here!");
|
|
|
|
case eType_Null:
|
2008-02-26 16:29:02 -08:00
|
|
|
// No need to load anything, notify of the failure.
|
|
|
|
UpdateFallbackState(thisContent, fallback, aTypeHint);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the class ID specifies a supported plugin, or if we have no explicit URI
|
|
|
|
// but a type, immediately instantiate the plugin.
|
|
|
|
PRBool isSupportedClassID = PR_FALSE;
|
|
|
|
nsCAutoString typeForID; // Will be set iff isSupportedClassID == PR_TRUE
|
|
|
|
PRBool hasID = PR_FALSE;
|
|
|
|
if (caps & eSupportClassID) {
|
|
|
|
nsAutoString classid;
|
|
|
|
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::classid, classid);
|
|
|
|
if (!classid.IsEmpty()) {
|
|
|
|
hasID = PR_TRUE;
|
|
|
|
isSupportedClassID = NS_SUCCEEDED(TypeForClassID(classid, typeForID));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasID && !isSupportedClassID) {
|
|
|
|
// We have a class ID and it's unsupported. Fallback in that case.
|
|
|
|
LOG(("OBJLC [%p]: invalid classid\n", this));
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSupportedClassID ||
|
|
|
|
(!aURI && !aTypeHint.IsEmpty() &&
|
|
|
|
GetTypeOfContent(aTypeHint) == eType_Plugin)) {
|
|
|
|
// No URI, but we have a type. The plugin will handle the load.
|
|
|
|
// Or: supported class id, plugin will handle the load.
|
|
|
|
LOG(("OBJLC [%p]: (classid) Changing type from %u to eType_Plugin\n", this, mType));
|
|
|
|
mType = eType_Plugin;
|
|
|
|
|
|
|
|
// At this point, the stored content type
|
|
|
|
// must be equal to our type hint. Similar,
|
|
|
|
// our URI must be the requested URI.
|
|
|
|
// (->Equals would suffice, but == is cheaper
|
|
|
|
// and handles NULL)
|
|
|
|
NS_ASSERTION(mContentType.Equals(aTypeHint), "mContentType wrong!");
|
|
|
|
NS_ASSERTION(mURI == aURI, "mURI wrong!");
|
|
|
|
|
|
|
|
if (isSupportedClassID) {
|
|
|
|
// Use the classid's type
|
|
|
|
NS_ASSERTION(!typeForID.IsEmpty(), "Must have a real type!");
|
|
|
|
mContentType = typeForID;
|
|
|
|
// XXX(biesi). The plugin instantiation code used to pass the base URI
|
|
|
|
// here instead of the plugin URI for instantiation via class ID, so I
|
|
|
|
// continue to do so. Why that is, no idea...
|
|
|
|
GetObjectBaseURI(thisContent, getter_AddRefs(mURI));
|
|
|
|
if (!mURI) {
|
|
|
|
mURI = aURI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-06 17:32:14 -07:00
|
|
|
rv = TryInstantiate(mContentType, mURI);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aURI) {
|
2008-02-26 16:29:02 -08:00
|
|
|
// No URI and if we have got this far no enabled plugin supports the type
|
2007-03-22 10:30:00 -07:00
|
|
|
LOG(("OBJLC [%p]: no URI\n", this));
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
2008-02-26 16:29:02 -08:00
|
|
|
|
|
|
|
// We should only notify the UI if there is at least a type to go on for
|
2008-04-16 13:07:11 -07:00
|
|
|
// finding a plugin to use, unless it's a supported image or document type.
|
|
|
|
if (!aTypeHint.IsEmpty() && GetTypeOfContent(aTypeHint) == eType_Null) {
|
2008-02-26 16:29:02 -08:00
|
|
|
UpdateFallbackState(thisContent, fallback, aTypeHint);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-26 16:29:02 -08:00
|
|
|
// E.g. mms://
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!CanHandleURI(aURI)) {
|
|
|
|
LOG(("OBJLC [%p]: can't handle URI\n", this));
|
2007-08-06 11:02:14 -07:00
|
|
|
if (aTypeHint.IsEmpty()) {
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-26 16:29:02 -08:00
|
|
|
if (IsSupportedPlugin(aTypeHint)) {
|
|
|
|
mType = eType_Plugin;
|
|
|
|
|
|
|
|
rv = TryInstantiate(aTypeHint, aURI);
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
// No plugin to load, notify of the failure.
|
|
|
|
UpdateFallbackState(thisContent, fallback, aTypeHint);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadGroup> group = doc->GetDocumentLoadGroup();
|
|
|
|
nsCOMPtr<nsIChannel> chan;
|
2010-04-23 12:51:25 -07:00
|
|
|
nsCOMPtr<nsIChannelPolicy> channelPolicy;
|
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
|
|
|
rv = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (csp) {
|
|
|
|
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
|
|
|
|
channelPolicy->SetContentSecurityPolicy(csp);
|
|
|
|
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_OBJECT);
|
|
|
|
}
|
2007-08-20 20:26:12 -07:00
|
|
|
rv = NS_NewChannel(getter_AddRefs(chan), aURI, nsnull, group, this,
|
2010-05-21 14:03:02 -07:00
|
|
|
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
|
|
|
|
nsIChannel::LOAD_CLASSIFY_URI,
|
2010-04-23 12:51:25 -07:00
|
|
|
channelPolicy);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Referrer
|
|
|
|
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
|
|
|
|
if (httpChan) {
|
|
|
|
httpChan->SetReferrer(doc->GetDocumentURI());
|
|
|
|
}
|
|
|
|
|
|
|
|
// MIME Type hint
|
|
|
|
if (!aTypeHint.IsEmpty()) {
|
2010-07-22 14:33:38 -07:00
|
|
|
nsCAutoString typeHint, dummy;
|
|
|
|
NS_ParseContentType(aTypeHint, typeHint, dummy);
|
|
|
|
if (!typeHint.IsEmpty()) {
|
|
|
|
chan->SetContentType(typeHint);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-12-03 13:57:17 -08:00
|
|
|
// Set up the channel's principal and such, like nsDocShell::DoURILoad does
|
|
|
|
PRBool inheritPrincipal;
|
|
|
|
rv = NS_URIChainHasFlags(aURI,
|
|
|
|
nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
|
|
|
|
&inheritPrincipal);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2008-03-22 09:50:47 -07:00
|
|
|
if (inheritPrincipal || IsAboutBlank(aURI) ||
|
|
|
|
(nsContentUtils::URIIsLocalFile(aURI) &&
|
|
|
|
NS_SUCCEEDED(thisContent->NodePrincipal()->CheckMayLoad(aURI,
|
|
|
|
PR_FALSE)))) {
|
2007-12-03 13:57:17 -08:00
|
|
|
chan->SetOwner(thisContent->NodePrincipal());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(chan);
|
|
|
|
if (scriptChannel) {
|
|
|
|
// Allow execution against our context if the principals match
|
|
|
|
scriptChannel->
|
|
|
|
SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// AsyncOpen can fail if a file does not exist.
|
|
|
|
// Show fallback content in that case.
|
|
|
|
rv = chan->AsyncOpen(this, nsnull);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
LOG(("OBJLC [%p]: Channel opened.\n", this));
|
2008-03-12 14:52:47 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
mChannel = chan;
|
|
|
|
mType = eType_Loading;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsObjectLoadingContent::GetCapabilities() const
|
|
|
|
{
|
|
|
|
return eSupportImages |
|
|
|
|
eSupportPlugins |
|
|
|
|
eSupportDocuments
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
| eSupportSVG
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::Fallback(PRBool aNotify)
|
|
|
|
{
|
|
|
|
LOG(("OBJLC [%p]: Falling back (Notify=%i)\n", this, aNotify));
|
|
|
|
|
|
|
|
AutoNotifier notifier(this, aNotify);
|
|
|
|
|
|
|
|
UnloadContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::RemovedFromDocument()
|
|
|
|
{
|
|
|
|
LOG(("OBJLC [%p]: Removed from doc\n", this));
|
|
|
|
if (mFrameLoader) {
|
|
|
|
// XXX This is very temporary and must go away
|
|
|
|
mFrameLoader->Destroy();
|
|
|
|
mFrameLoader = nsnull;
|
|
|
|
|
|
|
|
// Clear the current URI, so that LoadObject doesn't think that we
|
|
|
|
// have already loaded the content.
|
|
|
|
mURI = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::Traverse(nsCycleCollectionTraversalCallback &cb)
|
|
|
|
{
|
2011-01-11 13:34:31 -08:00
|
|
|
cb.NoteXPCOMChild(static_cast<nsIFrameLoader*>(mFrameLoader));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// <private>
|
|
|
|
/* static */ PRBool
|
|
|
|
nsObjectLoadingContent::IsSuccessfulRequest(nsIRequest* aRequest)
|
|
|
|
{
|
|
|
|
nsresult status;
|
|
|
|
nsresult rv = aRequest->GetStatus(&status);
|
|
|
|
if (NS_FAILED(rv) || NS_FAILED(status)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This may still be an error page or somesuch
|
|
|
|
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(aRequest));
|
|
|
|
if (httpChan) {
|
|
|
|
PRBool success;
|
|
|
|
rv = httpChan->GetRequestSucceeded(&success);
|
|
|
|
if (NS_FAILED(rv) || !success) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, the request is successful
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ PRBool
|
|
|
|
nsObjectLoadingContent::CanHandleURI(nsIURI* aURI)
|
|
|
|
{
|
|
|
|
nsCAutoString scheme;
|
|
|
|
if (NS_FAILED(aURI->GetScheme(scheme))) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIIOService* ios = nsContentUtils::GetIOService();
|
|
|
|
if (!ios)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIProtocolHandler> handler;
|
|
|
|
ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
|
|
|
|
if (!handler) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIExternalProtocolHandler> extHandler =
|
|
|
|
do_QueryInterface(handler);
|
|
|
|
// We can handle this URI if its protocol handler is not the external one
|
|
|
|
return extHandler == nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsObjectLoadingContent::IsSupportedDocument(const nsCString& aMimeType)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIWebNavigationInfo> info(
|
|
|
|
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv));
|
|
|
|
PRUint32 supported;
|
|
|
|
if (info) {
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav;
|
|
|
|
nsIDocument* currentDoc = thisContent->GetCurrentDoc();
|
|
|
|
if (currentDoc) {
|
|
|
|
webNav = do_GetInterface(currentDoc->GetScriptGlobalObject());
|
|
|
|
}
|
|
|
|
rv = info->IsTypeSupported(aMimeType, webNav, &supported);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
if (supported == nsIWebNavigationInfo::UNSUPPORTED) {
|
|
|
|
// Try a stream converter
|
|
|
|
// NOTE: We treat any type we can convert from as a supported type. If a
|
|
|
|
// type is not actually supported, the URI loader will detect that and
|
|
|
|
// return an error, and we'll fallback.
|
|
|
|
nsCOMPtr<nsIStreamConverterService> convServ =
|
|
|
|
do_GetService("@mozilla.org/streamConverters;1");
|
|
|
|
PRBool canConvert = PR_FALSE;
|
|
|
|
if (convServ) {
|
|
|
|
rv = convServ->CanConvert(aMimeType.get(), "*/*", &canConvert);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_SUCCEEDED(rv) && canConvert;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't want to support plugins as documents
|
|
|
|
return supported != nsIWebNavigationInfo::PLUGIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::UnloadContent()
|
|
|
|
{
|
|
|
|
// Don't notify in CancelImageRequests. We do it ourselves.
|
|
|
|
CancelImageRequests(PR_FALSE);
|
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
|
|
|
mFrameLoader = nsnull;
|
|
|
|
}
|
|
|
|
mType = eType_Null;
|
2008-09-09 08:43:21 -07:00
|
|
|
mUserDisabled = mSuppressed = PR_FALSE;
|
2010-01-13 08:42:41 -08:00
|
|
|
mFallbackReason = ePluginOtherState;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aOldState, PRBool aSync)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-10-20 09:42:21 -07:00
|
|
|
LOG(("OBJLC [%p]: Notifying about state change: (%u, %llx) -> (%u, %llx) (sync=%i)\n",
|
2010-10-20 04:26:32 -07:00
|
|
|
this, aOldType, aOldState.GetInternalValue(), mType,
|
|
|
|
ObjectState().GetInternalValue(), aSync));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
nsIDocument* doc = thisContent->GetCurrentDoc();
|
|
|
|
if (!doc) {
|
|
|
|
return; // Nothing to do
|
|
|
|
}
|
|
|
|
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates newState = ObjectState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (newState != aOldState) {
|
|
|
|
// This will trigger frame construction
|
|
|
|
NS_ASSERTION(thisContent->IsInDoc(), "Something is confused");
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates changedBits = aOldState ^ newState;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
{
|
|
|
|
mozAutoDocUpdate upd(doc, UPDATE_CONTENT_STATE, PR_TRUE);
|
|
|
|
doc->ContentStatesChanged(thisContent, nsnull, changedBits);
|
|
|
|
}
|
|
|
|
if (aSync) {
|
|
|
|
// Make sure that frames are actually constructed, and do it after
|
|
|
|
// EndUpdate was called.
|
|
|
|
doc->FlushPendingNotifications(Flush_Frames);
|
|
|
|
}
|
|
|
|
} else if (aOldType != mType) {
|
|
|
|
// If our state changed, then we already recreated frames
|
|
|
|
// Otherwise, need to do that here
|
2010-06-25 06:59:57 -07:00
|
|
|
nsCOMPtr<nsIPresShell> shell = doc->GetShell();
|
2010-01-07 02:36:11 -08:00
|
|
|
if (shell) {
|
2007-03-22 10:30:00 -07:00
|
|
|
shell->RecreateFramesFor(thisContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
2007-07-13 17:28:05 -07:00
|
|
|
nsObjectLoadingContent::FirePluginError(nsIContent* thisContent,
|
2008-09-09 08:43:21 -07:00
|
|
|
PluginSupportState state)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-07-13 17:28:05 -07:00
|
|
|
LOG(("OBJLC []: Dispatching nsPluginErrorEvent for content %p\n",
|
2007-03-22 10:30:00 -07:00
|
|
|
thisContent));
|
|
|
|
|
2008-09-09 08:43:21 -07:00
|
|
|
nsCOMPtr<nsIRunnable> ev = new nsPluginErrorEvent(thisContent, state);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv = NS_DispatchToCurrentThread(ev);
|
|
|
|
if (NS_FAILED(rv)) {
|
2007-07-13 17:28:05 -07:00
|
|
|
NS_WARNING("failed to dispatch nsPluginErrorEvent");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsObjectLoadingContent::ObjectType
|
|
|
|
nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType)
|
|
|
|
{
|
|
|
|
PRUint32 caps = GetCapabilities();
|
|
|
|
|
|
|
|
if ((caps & eSupportImages) && IsSupportedImage(aMIMEType)) {
|
|
|
|
return eType_Image;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_SVG
|
|
|
|
PRBool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml");
|
|
|
|
PRBool supportedSVG = isSVG && (caps & eSupportSVG);
|
|
|
|
#else
|
|
|
|
PRBool supportedSVG = PR_FALSE;
|
|
|
|
#endif
|
|
|
|
if (((caps & eSupportDocuments) || supportedSVG) &&
|
|
|
|
IsSupportedDocument(aMIMEType)) {
|
|
|
|
return eType_Document;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((caps & eSupportPlugins) && IsSupportedPlugin(aMIMEType)) {
|
|
|
|
return eType_Plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eType_Null;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::TypeForClassID(const nsAString& aClassID,
|
|
|
|
nsACString& aType)
|
|
|
|
{
|
|
|
|
// Need a plugin host for any class id support
|
2009-06-25 14:06:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!pluginHost) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringBeginsWith(aClassID, NS_LITERAL_STRING("java:"))) {
|
|
|
|
// Supported if we have a java plugin
|
|
|
|
aType.AssignLiteral("application/x-java-vm");
|
|
|
|
nsresult rv = pluginHost->IsPluginEnabledForType("application/x-java-vm");
|
|
|
|
return NS_SUCCEEDED(rv) ? NS_OK : NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If it starts with "clsid:", this is ActiveX content
|
2011-02-08 05:35:25 -08:00
|
|
|
if (StringBeginsWith(aClassID, NS_LITERAL_STRING("clsid:"), nsCaseInsensitiveStringComparator())) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Check if we have a plugin for that
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForType("application/x-oleobject"))) {
|
|
|
|
aType.AssignLiteral("application/x-oleobject");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (NS_SUCCEEDED(pluginHost->IsPluginEnabledForType("application/oleobject"))) {
|
|
|
|
aType.AssignLiteral("application/oleobject");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::GetObjectBaseURI(nsIContent* thisContent, nsIURI** aURI)
|
|
|
|
{
|
|
|
|
// We want to use swap(); since this is just called from this file,
|
|
|
|
// we can assert this (callers use comptrs)
|
|
|
|
NS_PRECONDITION(*aURI == nsnull, "URI must be inited to zero");
|
|
|
|
|
|
|
|
// For plugins, the codebase attribute is the base URI
|
|
|
|
nsCOMPtr<nsIURI> baseURI = thisContent->GetBaseURI();
|
|
|
|
nsAutoString codebase;
|
|
|
|
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::codebase,
|
|
|
|
codebase);
|
|
|
|
if (!codebase.IsEmpty()) {
|
|
|
|
nsContentUtils::NewURIWithDocumentCharset(aURI, codebase,
|
|
|
|
thisContent->GetOwnerDoc(),
|
|
|
|
baseURI);
|
|
|
|
} else {
|
|
|
|
baseURI.swap(*aURI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIObjectFrame*
|
2008-03-14 16:08:57 -07:00
|
|
|
nsObjectLoadingContent::GetExistingFrame(FlushType aFlushType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 00:08:04 -07:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
2007-05-23 12:53:31 -07:00
|
|
|
nsIFrame* frame;
|
|
|
|
do {
|
2009-12-24 13:20:05 -08:00
|
|
|
frame = thisContent->GetPrimaryFrame();
|
2007-05-23 12:53:31 -07:00
|
|
|
if (!frame) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2008-03-14 16:08:57 -07:00
|
|
|
if (aFlushType == eDontFlush) {
|
2007-05-23 12:53:31 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OK, let's flush out and try again. Note that we want to reget
|
|
|
|
// the document, etc, since flushing might run script.
|
2009-12-24 13:20:05 -08:00
|
|
|
nsIDocument* doc = thisContent->GetCurrentDoc();
|
|
|
|
NS_ASSERTION(doc, "Frame but no document?");
|
2007-08-02 10:54:36 -07:00
|
|
|
mozFlushType flushType =
|
2008-03-14 16:08:57 -07:00
|
|
|
aFlushType == eFlushLayout ? Flush_Layout : Flush_ContentAndNotify;
|
2007-08-02 10:54:36 -07:00
|
|
|
doc->FlushPendingNotifications(flushType);
|
2007-05-23 12:53:31 -07:00
|
|
|
|
2008-03-14 16:08:57 -07:00
|
|
|
aFlushType = eDontFlush;
|
2007-05-23 12:53:31 -07:00
|
|
|
} while (1);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIObjectFrame* objFrame = do_QueryFrame(frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
return objFrame;
|
|
|
|
}
|
|
|
|
|
2007-09-14 11:57:59 -07:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::HandleBeingBlockedByContentPolicy(nsresult aStatus,
|
|
|
|
PRInt16 aRetval)
|
|
|
|
{
|
|
|
|
// Must call UnloadContent first, as it overwrites
|
|
|
|
// mSuppressed/mUserDisabled. It also takes care of setting the type to
|
|
|
|
// eType_Null.
|
|
|
|
UnloadContent();
|
|
|
|
if (NS_SUCCEEDED(aStatus)) {
|
|
|
|
if (aRetval == nsIContentPolicy::REJECT_TYPE) {
|
|
|
|
mUserDisabled = PR_TRUE;
|
|
|
|
} else if (aRetval == nsIContentPolicy::REJECT_SERVER) {
|
|
|
|
mSuppressed = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
2007-08-06 17:32:14 -07:00
|
|
|
nsObjectLoadingContent::TryInstantiate(const nsACString& aMIMEType,
|
|
|
|
nsIURI* aURI)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-03-14 16:08:57 -07:00
|
|
|
nsIObjectFrame* frame = GetExistingFrame(eFlushContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!frame) {
|
2007-08-06 17:32:14 -07:00
|
|
|
LOG(("OBJLC [%p]: No frame yet\n", this));
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK; // Not a failure to have no frame
|
|
|
|
}
|
2008-08-15 08:30:26 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPluginInstance> instance;
|
2008-09-23 21:37:56 -07:00
|
|
|
frame->GetPluginInstance(*getter_AddRefs(instance));
|
2008-08-15 08:30:26 -07:00
|
|
|
|
|
|
|
if (!instance) {
|
|
|
|
// The frame has no plugin instance yet. If the frame hasn't been
|
2009-07-27 01:46:59 -07:00
|
|
|
// reflowed yet, do nothing as once the reflow happens we'll end up
|
2008-08-15 08:30:26 -07:00
|
|
|
// instantiating the plugin with the correct size n' all (which
|
|
|
|
// isn't known until we've done the first reflow). But if the
|
|
|
|
// frame does have a plugin instance already, be sure to
|
|
|
|
// re-instantiate the plugin as its source or whatnot might have
|
|
|
|
// chanced since it was instantiated.
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIFrame* iframe = do_QueryFrame(frame);
|
2008-08-15 08:30:26 -07:00
|
|
|
if (iframe->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2009-07-27 01:46:59 -07:00
|
|
|
LOG(("OBJLC [%p]: Frame hasn't been reflowed yet\n", this));
|
2008-08-15 08:30:26 -07:00
|
|
|
return NS_OK; // Not a failure to have no frame
|
|
|
|
}
|
2007-08-06 17:32:14 -07:00
|
|
|
}
|
2008-08-15 08:30:26 -07:00
|
|
|
|
2007-08-06 17:32:14 -07:00
|
|
|
return Instantiate(frame, aMIMEType, aURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::Instantiate(nsIObjectFrame* aFrame,
|
|
|
|
const nsACString& aMIMEType,
|
|
|
|
nsIURI* aURI)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFrame, "Must have a frame here");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-05-06 13:49:30 -07:00
|
|
|
// We're instantiating now, invalidate any pending async instantiate
|
|
|
|
// calls.
|
|
|
|
mPendingInstantiateEvent = nsnull;
|
|
|
|
|
|
|
|
// Mark that we're instantiating now so that we don't end up
|
|
|
|
// re-entering instantiation code.
|
|
|
|
PRBool oldInstantiatingValue = mInstantiating;
|
|
|
|
mInstantiating = PR_TRUE;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString typeToUse(aMIMEType);
|
|
|
|
if (typeToUse.IsEmpty() && aURI) {
|
2007-07-18 14:48:18 -07:00
|
|
|
IsPluginEnabledByExtension(aURI, typeToUse);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-10-02 04:26:04 -07:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIURI> baseURI;
|
|
|
|
if (!aURI) {
|
|
|
|
// We need some URI. If we have nothing else, use the base URI.
|
|
|
|
// XXX(biesi): The code used to do this. Not sure why this is correct...
|
|
|
|
GetObjectBaseURI(thisContent, getter_AddRefs(baseURI));
|
|
|
|
aURI = baseURI;
|
|
|
|
}
|
|
|
|
|
2009-12-12 13:15:25 -08:00
|
|
|
nsIFrame *nsiframe = do_QueryFrame(aFrame);
|
|
|
|
nsWeakFrame weakFrame(nsiframe);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// We'll always have a type or a URI by the time we get here
|
|
|
|
NS_ASSERTION(aURI || !typeToUse.IsEmpty(), "Need a URI or a type");
|
2007-08-06 17:32:14 -07:00
|
|
|
LOG(("OBJLC [%p]: Calling [%p]->Instantiate(<%s>, %p)\n", this, aFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
typeToUse.get(), aURI));
|
2008-05-06 13:49:30 -07:00
|
|
|
nsresult rv = aFrame->Instantiate(typeToUse.get(), aURI);
|
|
|
|
|
|
|
|
mInstantiating = oldInstantiatingValue;
|
|
|
|
|
2009-10-02 04:26:04 -07:00
|
|
|
nsCOMPtr<nsIPluginInstance> pluginInstance;
|
2009-12-12 13:15:25 -08:00
|
|
|
if (weakFrame.IsAlive()) {
|
|
|
|
aFrame->GetPluginInstance(*getter_AddRefs(pluginInstance));
|
|
|
|
}
|
2009-10-02 04:26:04 -07:00
|
|
|
if (pluginInstance) {
|
|
|
|
nsCOMPtr<nsIPluginTag> pluginTag;
|
|
|
|
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
|
|
|
host->GetPluginTagForInstance(pluginInstance, getter_AddRefs(pluginTag));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBlocklistService> blocklist =
|
|
|
|
do_GetService("@mozilla.org/extensions/blocklist;1");
|
|
|
|
if (blocklist) {
|
|
|
|
PRUint32 blockState = nsIBlocklistService::STATE_NOT_BLOCKED;
|
|
|
|
blocklist->GetPluginBlocklistState(pluginTag, EmptyString(),
|
|
|
|
EmptyString(), &blockState);
|
|
|
|
if (blockState == nsIBlocklistService::STATE_OUTDATED)
|
|
|
|
FirePluginError(thisContent, ePluginOutdated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 13:49:30 -07:00
|
|
|
return rv;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-09-09 08:43:21 -07:00
|
|
|
/* static */ PluginSupportState
|
2007-03-22 10:30:00 -07:00
|
|
|
nsObjectLoadingContent::GetPluginSupportState(nsIContent* aContent,
|
|
|
|
const nsCString& aContentType)
|
|
|
|
{
|
2009-08-24 13:02:07 -07:00
|
|
|
if (!aContent->IsHTML()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return ePluginOtherState;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aContent->Tag() == nsGkAtoms::embed ||
|
|
|
|
aContent->Tag() == nsGkAtoms::applet) {
|
|
|
|
return GetPluginDisabledState(aContentType);
|
|
|
|
}
|
|
|
|
|
2008-03-26 16:04:57 -07:00
|
|
|
PRBool hasAlternateContent = PR_FALSE;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Search for a child <param> with a pluginurl name
|
|
|
|
PRUint32 count = aContent->GetChildCount();
|
|
|
|
for (PRUint32 i = 0; i < count; ++i) {
|
|
|
|
nsIContent* child = aContent->GetChildAt(i);
|
|
|
|
NS_ASSERTION(child, "GetChildCount lied!");
|
|
|
|
|
2009-08-24 13:02:07 -07:00
|
|
|
if (child->IsHTML() &&
|
2008-03-26 16:04:57 -07:00
|
|
|
child->Tag() == nsGkAtoms::param) {
|
|
|
|
if (child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
|
|
|
NS_LITERAL_STRING("pluginurl"), eIgnoreCase)) {
|
|
|
|
return GetPluginDisabledState(aContentType);
|
|
|
|
}
|
|
|
|
} else if (!hasAlternateContent) {
|
|
|
|
hasAlternateContent =
|
|
|
|
nsStyleUtil::IsSignificantChild(child, PR_TRUE, PR_FALSE);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2008-03-26 16:04:57 -07:00
|
|
|
|
|
|
|
return hasAlternateContent ? ePluginOtherState :
|
|
|
|
GetPluginDisabledState(aContentType);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-09-09 08:43:21 -07:00
|
|
|
/* static */ PluginSupportState
|
2007-03-22 10:30:00 -07:00
|
|
|
nsObjectLoadingContent::GetPluginDisabledState(const nsCString& aContentType)
|
|
|
|
{
|
2009-06-25 14:06:54 -07:00
|
|
|
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!host) {
|
|
|
|
return ePluginUnsupported;
|
|
|
|
}
|
|
|
|
nsresult rv = host->IsPluginEnabledForType(aContentType.get());
|
2007-07-13 17:28:05 -07:00
|
|
|
if (rv == NS_ERROR_PLUGIN_DISABLED)
|
|
|
|
return ePluginDisabled;
|
|
|
|
if (rv == NS_ERROR_PLUGIN_BLOCKLISTED)
|
|
|
|
return ePluginBlocklisted;
|
|
|
|
return ePluginUnsupported;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-11-20 08:26:10 -08:00
|
|
|
|
2009-12-10 20:02:13 -08:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::CreateStaticClone(nsObjectLoadingContent* aDest) const
|
|
|
|
{
|
|
|
|
nsImageLoadingContent::CreateStaticImageClone(aDest);
|
|
|
|
|
|
|
|
aDest->mType = mType;
|
|
|
|
nsObjectLoadingContent* thisObj = const_cast<nsObjectLoadingContent*>(this);
|
|
|
|
if (thisObj->mPrintFrame.IsAlive()) {
|
|
|
|
aDest->mPrintFrame = thisObj->mPrintFrame;
|
|
|
|
} else {
|
|
|
|
nsIObjectFrame* frame =
|
|
|
|
const_cast<nsObjectLoadingContent*>(this)->GetExistingFrame(eDontFlush);
|
|
|
|
nsIFrame* f = do_QueryFrame(frame);
|
|
|
|
aDest->mPrintFrame = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFrameLoader) {
|
|
|
|
nsCOMPtr<nsIContent> content =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>((aDest)));
|
2010-08-17 07:13:55 -07:00
|
|
|
nsFrameLoader* fl = nsFrameLoader::Create(content, PR_FALSE);
|
2009-12-10 20:02:13 -08:00
|
|
|
if (fl) {
|
|
|
|
aDest->mFrameLoader = fl;
|
|
|
|
mFrameLoader->CreateStaticClone(fl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetPrintFrame(nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
*aFrame = mPrintFrame.GetFrame();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-11-20 08:26:10 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::SetAbsoluteScreenPosition(nsIDOMElement* element,
|
|
|
|
nsIDOMClientRect* position,
|
|
|
|
nsIDOMClientRect* clip)
|
|
|
|
{
|
|
|
|
nsIObjectFrame* frame = GetExistingFrame(eFlushLayout);
|
|
|
|
if (!frame)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
return frame->SetAbsoluteScreenPosition(element, position, clip);
|
|
|
|
}
|
|
|
|
|
2010-01-13 08:42:41 -08:00
|
|
|
NS_IMETHODIMP
|
2010-03-16 22:10:08 -07:00
|
|
|
nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
|
2010-03-24 14:22:04 -07:00
|
|
|
const nsAString& pluginDumpID,
|
|
|
|
const nsAString& browserDumpID,
|
2010-02-09 17:05:31 -08:00
|
|
|
PRBool submittedCrashReport)
|
2010-01-13 08:42:41 -08:00
|
|
|
{
|
2010-02-09 17:05:31 -08:00
|
|
|
AutoNotifier notifier(this, PR_TRUE);
|
2010-01-13 08:42:41 -08:00
|
|
|
UnloadContent();
|
|
|
|
mFallbackReason = ePluginCrashed;
|
|
|
|
nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2010-03-16 22:10:08 -07:00
|
|
|
|
|
|
|
// Note that aPluginTag in invalidated after we're called, so copy
|
|
|
|
// out any data we need now.
|
|
|
|
nsCAutoString pluginName;
|
|
|
|
aPluginTag->GetName(pluginName);
|
2010-04-08 00:45:00 -07:00
|
|
|
nsCAutoString pluginFilename;
|
|
|
|
aPluginTag->GetFilename(pluginFilename);
|
2010-03-16 22:10:08 -07:00
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
nsCOMPtr<nsIRunnable> ev = new nsPluginCrashedEvent(thisContent,
|
2010-03-24 14:22:04 -07:00
|
|
|
pluginDumpID,
|
|
|
|
browserDumpID,
|
2010-03-16 22:10:08 -07:00
|
|
|
NS_ConvertUTF8toUTF16(pluginName),
|
2010-04-08 00:45:00 -07:00
|
|
|
NS_ConvertUTF8toUTF16(pluginFilename),
|
2010-02-09 17:05:31 -08:00
|
|
|
submittedCrashReport);
|
|
|
|
nsresult rv = NS_DispatchToCurrentThread(ev);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed to dispatch nsPluginCrashedEvent");
|
|
|
|
}
|
2010-01-13 08:42:41 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|