2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-31 12:00:42 +04:00
|
|
|
/*
|
2007-07-19 01:48:18 +04:00
|
|
|
* A base class implementing nsIObjectLoadingContent for use by
|
2006-03-31 12:20:34 +04:00
|
|
|
* various content nodes that want to provide plugin/document/image
|
2017-07-28 05:21:18 +03:00
|
|
|
* loading functionality (eg <embed>, <object>, etc).
|
2006-03-31 12:00:42 +04:00
|
|
|
*/
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// Interface headers
|
2012-10-04 00:17:40 +04:00
|
|
|
#include "imgLoader.h"
|
2017-05-05 08:59:42 +03:00
|
|
|
#include "nsIClassOfService.h"
|
2016-04-23 02:00:43 +03:00
|
|
|
#include "nsIConsoleService.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIContent.h"
|
2014-08-16 01:17:35 +04:00
|
|
|
#include "nsIContentInlines.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIDocShell.h"
|
2015-05-20 16:30:05 +03:00
|
|
|
#include "nsIDocShellLoadInfo.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIDocument.h"
|
2014-03-21 08:00:00 +04:00
|
|
|
#include "nsIDOMCustomEvent.h"
|
2011-05-23 20:46:36 +04:00
|
|
|
#include "nsIDOMDocument.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIExternalProtocolHandler.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIObjectFrame.h"
|
2017-07-26 13:51:17 +03:00
|
|
|
#include "nsIOService.h"
|
2012-04-18 22:40:55 +04:00
|
|
|
#include "nsIPermissionManager.h"
|
2011-05-18 05:48:34 +04:00
|
|
|
#include "nsPluginHost.h"
|
2013-08-27 09:05:29 +04:00
|
|
|
#include "nsPluginInstanceOwner.h"
|
2013-03-15 05:23:31 +04:00
|
|
|
#include "nsJSNPRuntime.h"
|
2014-04-25 14:19:21 +04:00
|
|
|
#include "nsINestedURI.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIPresShell.h"
|
2013-04-05 01:08:46 +04:00
|
|
|
#include "nsScriptSecurityManager.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2005-12-17 21:31:02 +03:00
|
|
|
#include "nsIStreamConverterService.h"
|
|
|
|
#include "nsIURILoader.h"
|
2005-10-29 16:56:44 +04:00
|
|
|
#include "nsIURL.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsIWebNavigation.h"
|
|
|
|
#include "nsIWebNavigationInfo.h"
|
2007-12-04 00:57:17 +03:00
|
|
|
#include "nsIScriptChannel.h"
|
2009-10-02 15:26:04 +04:00
|
|
|
#include "nsIBlocklistService.h"
|
2010-08-05 06:15:55 +04:00
|
|
|
#include "nsIAsyncVerifyRedirectCallback.h"
|
2012-02-01 01:55:54 +04:00
|
|
|
#include "nsIAppShell.h"
|
2015-04-27 02:55:39 +03:00
|
|
|
#include "nsIXULRuntime.h"
|
2016-02-26 02:49:18 +03:00
|
|
|
#include "nsIScriptError.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2006-08-12 06:13:24 +04:00
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// Util headers
|
2012-07-26 08:44:11 +04:00
|
|
|
#include "prenv.h"
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2005-12-17 21:31:02 +03:00
|
|
|
#include "nsCURILoader.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsContentPolicyUtils.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsDocShellCID.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
#include "nsNetUtil.h"
|
2007-08-21 07:26:12 +04:00
|
|
|
#include "nsMimeTypes.h"
|
2008-03-27 02:04:57 +03:00
|
|
|
#include "nsStyleUtil.h"
|
2011-02-08 16:35:25 +03:00
|
|
|
#include "nsUnicharUtils.h"
|
2013-06-24 16:51:07 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-08-06 14:01:23 +04:00
|
|
|
#include "nsSandboxFlags.h"
|
2005-09-21 23:14:30 +04:00
|
|
|
|
|
|
|
// Concrete classes
|
|
|
|
#include "nsFrameLoader.h"
|
|
|
|
|
|
|
|
#include "nsObjectLoadingContent.h"
|
2008-04-11 21:29:06 +04:00
|
|
|
#include "mozAutoDocUpdate.h"
|
2010-04-23 23:51:25 +04:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
2013-03-18 18:25:50 +04:00
|
|
|
#include "GeckoProfiler.h"
|
2014-09-24 08:33:00 +04:00
|
|
|
#include "nsPluginFrame.h"
|
2012-02-01 01:55:54 +04:00
|
|
|
#include "nsDOMClassInfo.h"
|
2013-03-04 23:08:23 +04:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2013-08-15 22:17:48 +04:00
|
|
|
#include "nsDOMJSUtils.h"
|
2012-02-01 01:55:54 +04:00
|
|
|
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsContentCID.h"
|
2013-10-22 17:27:36 +04:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2013-03-04 23:08:23 +04:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
#include "mozilla/dom/Event.h"
|
2014-07-15 15:34:42 +04:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2014-10-22 07:40:12 +04:00
|
|
|
#include "mozilla/dom/PluginCrashedEvent.h"
|
2016-06-23 07:32:23 +03:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2017-05-05 08:59:42 +03:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2017-08-03 22:07:14 +03:00
|
|
|
#include "mozilla/IMEStateManager.h"
|
|
|
|
#include "mozilla/widget/IMEData.h"
|
2016-12-16 06:16:31 +03:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2014-08-16 01:17:35 +04:00
|
|
|
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
2017-07-29 07:35:43 +03:00
|
|
|
#include "mozilla/dom/HTMLEmbedElement.h"
|
2017-02-09 02:19:01 +03:00
|
|
|
#include "mozilla/dom/HTMLObjectElement.h"
|
2016-04-23 02:00:43 +03:00
|
|
|
#include "nsChannelClassifier.h"
|
2017-08-03 22:07:14 +03:00
|
|
|
#include "nsFocusManager.h"
|
2013-03-04 23:08:23 +04:00
|
|
|
|
2013-08-22 22:32:52 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
// Thanks so much, Microsoft! :(
|
|
|
|
#ifdef CreateEvent
|
|
|
|
#undef CreateEvent
|
|
|
|
#endif
|
|
|
|
#endif // XP_WIN
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2016-01-06 11:01:59 +03:00
|
|
|
static const char *kPrefYoutubeRewrite = "plugins.rewrite_youtube_embeds";
|
2016-04-23 02:00:43 +03:00
|
|
|
static const char *kPrefBlockURIs = "browser.safebrowsing.blockedURIs.enabled";
|
2017-01-24 08:07:41 +03:00
|
|
|
static const char *kPrefFavorFallbackMode = "plugins.favorfallback.mode";
|
2017-01-24 08:08:04 +03:00
|
|
|
static const char *kPrefFavorFallbackRules = "plugins.favorfallback.rules";
|
2014-02-11 03:50:53 +04:00
|
|
|
|
2013-03-04 23:08:24 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
2016-05-19 05:02:57 +03:00
|
|
|
using namespace mozilla::net;
|
2013-03-04 23:08:24 +04:00
|
|
|
|
2015-11-23 22:09:25 +03:00
|
|
|
static LogModule*
|
2012-10-30 03:32:10 +04:00
|
|
|
GetObjectLog()
|
|
|
|
{
|
2015-11-23 22:09:25 +03:00
|
|
|
static LazyLogModule sLog("objlc");
|
2012-10-30 03:32:10 +04:00
|
|
|
return sLog;
|
|
|
|
}
|
2005-10-31 21:28:56 +03:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
#define LOG(args) MOZ_LOG(GetObjectLog(), mozilla::LogLevel::Debug, args)
|
|
|
|
#define LOG_ENABLED() MOZ_LOG_TEST(GetObjectLog(), mozilla::LogLevel::Debug)
|
2005-10-31 21:28:56 +03:00
|
|
|
|
2016-06-17 13:05:42 +03:00
|
|
|
static bool
|
|
|
|
IsFlashMIME(const nsACString & aMIMEType)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
nsPluginHost::GetSpecialType(aMIMEType) == nsPluginHost::eSpecialType_Flash;
|
|
|
|
}
|
|
|
|
|
2012-07-06 04:56:25 +04:00
|
|
|
static bool
|
|
|
|
InActiveDocument(nsIContent *aContent)
|
|
|
|
{
|
2015-02-24 17:41:43 +03:00
|
|
|
if (!aContent->IsInComposedDoc()) {
|
2012-07-06 04:56:25 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsIDocument *doc = aContent->OwnerDoc();
|
|
|
|
return (doc && doc->IsActive());
|
|
|
|
}
|
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
static bool
|
|
|
|
IsPluginType(nsObjectLoadingContent::ObjectType type)
|
|
|
|
{
|
|
|
|
return type == nsObjectLoadingContent::eType_Plugin ||
|
|
|
|
type == nsObjectLoadingContent::eType_FakePlugin;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
///
|
|
|
|
/// Runnables and helper classes
|
|
|
|
///
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsAsyncInstantiateEvent : public Runnable {
|
2006-05-10 21:30:15 +04:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit nsAsyncInstantiateEvent(nsObjectLoadingContent* aContent)
|
2017-05-10 02:19:37 +03:00
|
|
|
: Runnable("nsAsyncInstantiateEvent"), mContent(aContent) {}
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
~nsAsyncInstantiateEvent() override = default;
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2012-07-06 01:07:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIObjectLoadingContent> mContent;
|
2005-09-21 23:14:30 +04:00
|
|
|
};
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAsyncInstantiateEvent::Run()
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
nsObjectLoadingContent *objLC =
|
|
|
|
static_cast<nsObjectLoadingContent *>(mContent.get());
|
|
|
|
|
2013-03-13 03:13:46 +04:00
|
|
|
// If objLC is no longer tracking this event, we've been canceled or
|
2013-07-23 02:08:09 +04:00
|
|
|
// superseded
|
2012-07-06 01:07:46 +04:00
|
|
|
if (objLC->mPendingInstantiateEvent != this) {
|
2006-05-10 21:30:15 +04:00
|
|
|
return NS_OK;
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
objLC->mPendingInstantiateEvent = nullptr;
|
2006-05-10 21:30:15 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return objLC->SyncStartPluginInstance();
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
2011-08-29 11:09:22 +04:00
|
|
|
|
2012-09-07 04:16:02 +04:00
|
|
|
// Checks to see if the content for a plugin instance should be unloaded
|
|
|
|
// (outside an active document) or stopped (in a document but unrendered). This
|
|
|
|
// is used to allow scripts to move a plugin around the document hierarchy
|
|
|
|
// without re-instantiating it.
|
2016-04-26 03:23:21 +03:00
|
|
|
class CheckPluginStopEvent : public Runnable {
|
2012-02-01 01:55:54 +04:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit CheckPluginStopEvent(nsObjectLoadingContent* aContent)
|
2017-02-11 09:11:48 +03:00
|
|
|
: Runnable("CheckPluginStopEvent"), mContent(aContent) {}
|
2012-02-01 01:55:54 +04:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
~CheckPluginStopEvent() override = default;
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2012-07-06 01:07:46 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIObjectLoadingContent> mContent;
|
2012-02-01 01:55:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-09-07 04:16:02 +04:00
|
|
|
CheckPluginStopEvent::Run()
|
2012-02-01 01:55:54 +04:00
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
nsObjectLoadingContent *objLC =
|
|
|
|
static_cast<nsObjectLoadingContent *>(mContent.get());
|
|
|
|
|
2012-09-07 04:16:02 +04:00
|
|
|
// If objLC is no longer tracking this event, we've been canceled or
|
2013-07-23 02:08:09 +04:00
|
|
|
// superseded. We clear this before we finish - either by calling
|
|
|
|
// UnloadObject/StopPluginInstance, or directly if we took no action.
|
2012-09-07 04:16:02 +04:00
|
|
|
if (objLC->mPendingCheckPluginStopEvent != this) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-21 22:30:20 +04:00
|
|
|
// CheckPluginStopEvent is queued when we either lose our frame, are removed
|
|
|
|
// from the document, or the document goes inactive. To avoid stopping the
|
|
|
|
// plugin when script is reparenting us or layout is rebuilding, we wait until
|
|
|
|
// this event to decide to stop.
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCOMPtr<nsIContent> content =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent *>(objLC));
|
2012-07-06 04:56:25 +04:00
|
|
|
if (!InActiveDocument(content)) {
|
2012-09-07 04:16:02 +04:00
|
|
|
LOG(("OBJLC [%p]: Unloading plugin outside of document", this));
|
2014-07-21 22:30:20 +04:00
|
|
|
objLC->StopPluginInstance();
|
2012-09-07 04:16:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-21 22:30:20 +04:00
|
|
|
if (content->GetPrimaryFrame()) {
|
|
|
|
LOG(("OBJLC [%p]: CheckPluginStopEvent - in active document with frame"
|
|
|
|
", no action", this));
|
|
|
|
objLC->mPendingCheckPluginStopEvent = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In an active document, but still no frame. Flush layout to see if we can
|
|
|
|
// regain a frame now.
|
|
|
|
LOG(("OBJLC [%p]: CheckPluginStopEvent - No frame, flushing layout", this));
|
2014-10-02 22:45:44 +04:00
|
|
|
nsIDocument* composedDoc = content->GetComposedDoc();
|
|
|
|
if (composedDoc) {
|
2017-01-05 10:31:56 +03:00
|
|
|
composedDoc->FlushPendingNotifications(FlushType::Layout);
|
2014-07-21 22:30:20 +04:00
|
|
|
if (objLC->mPendingCheckPluginStopEvent != this) {
|
|
|
|
LOG(("OBJLC [%p]: CheckPluginStopEvent - superseded in layout flush",
|
|
|
|
this));
|
|
|
|
return NS_OK;
|
2017-02-09 17:44:02 +03:00
|
|
|
}
|
|
|
|
if (content->GetPrimaryFrame()) {
|
2014-07-21 22:30:20 +04:00
|
|
|
LOG(("OBJLC [%p]: CheckPluginStopEvent - frame gained in layout flush",
|
|
|
|
this));
|
|
|
|
objLC->mPendingCheckPluginStopEvent = nullptr;
|
|
|
|
return NS_OK;
|
2013-07-23 02:08:09 +04:00
|
|
|
}
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
2013-07-23 02:08:09 +04:00
|
|
|
|
2014-07-21 22:30:20 +04:00
|
|
|
// Still no frame, suspend plugin. HasNewFrame will restart us when we
|
|
|
|
// become rendered again
|
|
|
|
LOG(("OBJLC [%p]: Stopping plugin that lost frame", this));
|
|
|
|
objLC->StopPluginInstance();
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
return NS_OK;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2005-11-11 23:12:35 +03:00
|
|
|
/**
|
2012-12-08 02:50:10 +04:00
|
|
|
* Helper task for firing simple events
|
2005-11-11 23:12:35 +03:00
|
|
|
*/
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsSimplePluginEvent : public Runnable {
|
2006-05-10 21:30:15 +04:00
|
|
|
public:
|
2013-07-19 18:02:48 +04:00
|
|
|
nsSimplePluginEvent(nsIContent* aTarget, const nsAString &aEvent)
|
2017-05-10 02:19:37 +03:00
|
|
|
: Runnable("nsSimplePluginEvent")
|
|
|
|
, mTarget(aTarget)
|
2014-10-02 22:45:44 +04:00
|
|
|
, mDocument(aTarget->GetComposedDoc())
|
2013-07-19 18:02:48 +04:00
|
|
|
, mEvent(aEvent)
|
|
|
|
{
|
2013-11-06 01:43:53 +04:00
|
|
|
MOZ_ASSERT(aTarget && mDocument);
|
2013-07-19 18:02:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSimplePluginEvent(nsIDocument* aTarget, const nsAString& aEvent)
|
2017-06-12 22:34:10 +03:00
|
|
|
: mozilla::Runnable("nsSimplePluginEvent")
|
|
|
|
, mTarget(aTarget)
|
2013-07-19 18:02:48 +04:00
|
|
|
, mDocument(aTarget)
|
|
|
|
, mEvent(aEvent)
|
|
|
|
{
|
2013-11-06 01:43:53 +04:00
|
|
|
MOZ_ASSERT(aTarget);
|
2013-07-19 18:02:48 +04:00
|
|
|
}
|
2005-11-11 23:12:35 +03:00
|
|
|
|
2014-02-22 04:37:06 +04:00
|
|
|
nsSimplePluginEvent(nsIContent* aTarget,
|
|
|
|
nsIDocument* aDocument,
|
|
|
|
const nsAString& aEvent)
|
2017-06-12 22:34:10 +03:00
|
|
|
: mozilla::Runnable("nsSimplePluginEvent")
|
|
|
|
, mTarget(aTarget)
|
2014-02-22 04:37:06 +04:00
|
|
|
, mDocument(aDocument)
|
|
|
|
, mEvent(aEvent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aTarget && aDocument);
|
|
|
|
}
|
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
~nsSimplePluginEvent() override = default;
|
2005-11-11 23:12:35 +03:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2012-07-06 00:47:39 +04:00
|
|
|
|
|
|
|
private:
|
2013-07-19 18:02:48 +04:00
|
|
|
nsCOMPtr<nsISupports> mTarget;
|
|
|
|
nsCOMPtr<nsIDocument> mDocument;
|
2012-12-08 02:50:10 +04:00
|
|
|
nsString mEvent;
|
2005-11-11 23:12:35 +03:00
|
|
|
};
|
|
|
|
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_IMETHODIMP
|
2012-12-08 02:50:10 +04:00
|
|
|
nsSimplePluginEvent::Run()
|
2005-11-11 23:12:35 +03:00
|
|
|
{
|
2013-11-25 21:08:37 +04:00
|
|
|
if (mDocument && mDocument->IsActive()) {
|
2013-11-06 01:43:53 +04:00
|
|
|
LOG(("OBJLC [%p]: nsSimplePluginEvent firing event \"%s\"", mTarget.get(),
|
|
|
|
NS_ConvertUTF16toUTF8(mEvent).get()));
|
|
|
|
nsContentUtils::DispatchTrustedEvent(mDocument, mTarget,
|
|
|
|
mEvent, true, true);
|
|
|
|
}
|
2006-05-10 21:30:15 +04:00
|
|
|
return NS_OK;
|
2005-11-11 23:12:35 +03:00
|
|
|
}
|
|
|
|
|
2010-02-10 04:05:31 +03:00
|
|
|
/**
|
|
|
|
* A task for firing PluginCrashed DOM Events.
|
|
|
|
*/
|
2016-04-26 03:23:21 +03:00
|
|
|
class nsPluginCrashedEvent : public Runnable {
|
2010-02-10 04:05:31 +03:00
|
|
|
public:
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2010-03-25 00:22:04 +03:00
|
|
|
nsString mPluginDumpID;
|
|
|
|
nsString mBrowserDumpID;
|
2010-02-10 04:05:31 +03:00
|
|
|
nsString mPluginName;
|
2010-04-08 11:45:00 +04:00
|
|
|
nsString mPluginFilename;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mSubmittedCrashReport;
|
2010-02-10 04:05:31 +03:00
|
|
|
|
|
|
|
nsPluginCrashedEvent(nsIContent* aContent,
|
2010-03-25 00:22:04 +03:00
|
|
|
const nsAString& aPluginDumpID,
|
|
|
|
const nsAString& aBrowserDumpID,
|
2010-02-10 04:05:31 +03:00
|
|
|
const nsAString& aPluginName,
|
2010-04-08 11:45:00 +04:00
|
|
|
const nsAString& aPluginFilename,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool submittedCrashReport)
|
2017-05-10 02:19:37 +03:00
|
|
|
: Runnable("nsPluginCrashedEvent"),
|
|
|
|
mContent(aContent),
|
2010-03-25 00:22:04 +03:00
|
|
|
mPluginDumpID(aPluginDumpID),
|
|
|
|
mBrowserDumpID(aBrowserDumpID),
|
2010-02-10 04:05:31 +03:00
|
|
|
mPluginName(aPluginName),
|
2010-04-08 11:45:00 +04:00
|
|
|
mPluginFilename(aPluginFilename),
|
2010-02-10 04:05:31 +03:00
|
|
|
mSubmittedCrashReport(submittedCrashReport)
|
|
|
|
{}
|
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
~nsPluginCrashedEvent() override = default;
|
2010-02-10 04:05:31 +03:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2010-02-10 04:05:31 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginCrashedEvent::Run()
|
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: Firing plugin crashed event\n",
|
2010-02-10 04:05:31 +03:00
|
|
|
mContent.get()));
|
|
|
|
|
2014-08-23 00:11:27 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
|
2014-01-15 18:26:51 +04:00
|
|
|
if (!doc) {
|
2010-02-10 04:05:31 +03:00
|
|
|
NS_WARNING("Couldn't get document for PluginCrashed event!");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-22 07:40:12 +04:00
|
|
|
PluginCrashedEventInit init;
|
|
|
|
init.mPluginDumpID = mPluginDumpID;
|
|
|
|
init.mBrowserDumpID = mBrowserDumpID;
|
|
|
|
init.mPluginName = mPluginName;
|
|
|
|
init.mPluginFilename = mPluginFilename;
|
|
|
|
init.mSubmittedCrashReport = mSubmittedCrashReport;
|
|
|
|
init.mBubbles = true;
|
|
|
|
init.mCancelable = true;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PluginCrashedEvent> event =
|
2014-10-22 07:40:12 +04:00
|
|
|
PluginCrashedEvent::Constructor(doc, NS_LITERAL_STRING("PluginCrashed"), init);
|
2010-02-10 04:05:31 +03:00
|
|
|
|
2014-03-21 08:00:00 +04:00
|
|
|
event->SetTrusted(true);
|
2016-02-12 18:40:07 +03:00
|
|
|
event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
|
2010-03-25 00:22:04 +03:00
|
|
|
|
2014-03-18 08:48:21 +04:00
|
|
|
EventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr);
|
2010-02-10 04:05:31 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// You can't take the address of bitfield members, so we have two separate
|
|
|
|
// classes for these :-/
|
|
|
|
|
|
|
|
// Sets a object's mInstantiating bit to false when destroyed
|
2012-07-26 00:39:01 +04:00
|
|
|
class AutoSetInstantiatingToFalse {
|
2012-07-06 01:07:46 +04:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit AutoSetInstantiatingToFalse(nsObjectLoadingContent* aContent)
|
2012-07-06 01:07:46 +04:00
|
|
|
: mContent(aContent) {}
|
|
|
|
~AutoSetInstantiatingToFalse() { mContent->mInstantiating = false; }
|
|
|
|
private:
|
|
|
|
nsObjectLoadingContent* mContent;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Sets a object's mInstantiating bit to false when destroyed
|
|
|
|
class AutoSetLoadingToFalse {
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit AutoSetLoadingToFalse(nsObjectLoadingContent* aContent)
|
2012-07-06 01:07:46 +04:00
|
|
|
: mContent(aContent) {}
|
|
|
|
~AutoSetLoadingToFalse() { mContent->mIsLoading = false; }
|
|
|
|
private:
|
|
|
|
nsObjectLoadingContent* mContent;
|
2012-07-26 00:39:01 +04:00
|
|
|
};
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
///
|
|
|
|
/// Helper functions
|
|
|
|
///
|
|
|
|
|
|
|
|
static bool
|
2016-06-17 13:05:42 +03:00
|
|
|
IsSuccessfulRequest(nsIRequest* aRequest, nsresult* aStatus)
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
2016-06-17 13:05:42 +03:00
|
|
|
nsresult rv = aRequest->GetStatus(aStatus);
|
|
|
|
if (NS_FAILED(rv) || NS_FAILED(*aStatus)) {
|
2012-07-06 01:07:46 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This may still be an error page or somesuch
|
|
|
|
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(aRequest));
|
|
|
|
if (httpChan) {
|
|
|
|
bool success;
|
|
|
|
rv = httpChan->GetRequestSucceeded(&success);
|
|
|
|
if (NS_FAILED(rv) || !success) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, the request is successful
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
CanHandleURI(nsIURI* aURI)
|
|
|
|
{
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString scheme;
|
2012-07-06 01:07:46 +04:00
|
|
|
if (NS_FAILED(aURI->GetScheme(scheme))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIIOService* ios = nsContentUtils::GetIOService();
|
|
|
|
if (!ios)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIProtocolHandler> handler;
|
|
|
|
ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
|
|
|
|
if (!handler) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIExternalProtocolHandler> extHandler =
|
|
|
|
do_QueryInterface(handler);
|
|
|
|
// We can handle this URI if its protocol handler is not the external one
|
|
|
|
return extHandler == nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper for tedious URI equality syntax when one or both arguments may be
|
|
|
|
// null and URIEquals(null, null) should be true
|
|
|
|
static bool inline
|
|
|
|
URIEquals(nsIURI *a, nsIURI *b)
|
|
|
|
{
|
|
|
|
bool equal;
|
|
|
|
return (!a && !b) || (a && b && NS_SUCCEEDED(a->Equals(b, &equal)) && equal);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
GetExtensionFromURI(nsIURI* uri, nsCString& ext)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
|
|
|
if (url) {
|
|
|
|
url->GetFileExtension(ext);
|
|
|
|
} else {
|
|
|
|
nsCString spec;
|
2016-09-08 07:17:58 +03:00
|
|
|
nsresult rv = uri->GetSpec(spec);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// This means we could incorrectly think a plugin is not enabled for
|
|
|
|
// the URI when it is, but that's not so bad.
|
|
|
|
ext.Truncate();
|
|
|
|
return;
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t offset = spec.RFindChar('.');
|
2012-07-06 01:07:46 +04:00
|
|
|
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.
|
|
|
|
*/
|
2012-07-06 00:47:39 +04:00
|
|
|
bool
|
|
|
|
IsPluginEnabledByExtension(nsIURI* uri, nsCString& mimeType)
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString ext;
|
2012-07-06 01:07:46 +04:00
|
|
|
GetExtensionFromURI(uri, ext);
|
|
|
|
|
|
|
|
if (ext.IsEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-02 19:09:45 +03:00
|
|
|
// Disables any native PDF plugins, when internal PDF viewer is enabled.
|
|
|
|
if (ext.EqualsIgnoreCase("pdf") && nsContentUtils::IsPDFJSEnabled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-07-26 00:39:01 +04:00
|
|
|
if (!pluginHost) {
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_NOTREACHED("No pluginhost");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-25 19:36:39 +03:00
|
|
|
return pluginHost->HavePluginForExtension(ext, mimeType);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
///
|
|
|
|
/// Member Functions
|
|
|
|
///
|
|
|
|
|
2013-03-19 04:34:27 +04:00
|
|
|
// Helper to queue a CheckPluginStopEvent for a OBJLC object
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::QueueCheckPluginStopEvent()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIRunnable> event = new CheckPluginStopEvent(this);
|
|
|
|
mPendingCheckPluginStopEvent = event;
|
|
|
|
|
2015-04-30 23:54:09 +03:00
|
|
|
NS_DispatchToCurrentThread(event);
|
2013-03-19 04:34:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-07 03:10:54 +04:00
|
|
|
// Tedious syntax to create a plugin stream listener with checks and put it in
|
|
|
|
// mFinalListener
|
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::MakePluginListener()
|
|
|
|
{
|
|
|
|
if (!mInstanceOwner) {
|
|
|
|
NS_NOTREACHED("expecting a spawned plugin");
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2012-12-07 03:10:54 +04:00
|
|
|
if (!pluginHost) {
|
|
|
|
NS_NOTREACHED("No pluginHost");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(!mFinalListener, "overwriting a final listener");
|
|
|
|
nsresult rv;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> inst;
|
2012-12-07 03:10:54 +04:00
|
|
|
nsCOMPtr<nsIStreamListener> finalListener;
|
|
|
|
rv = mInstanceOwner->GetInstance(getter_AddRefs(inst));
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2012-12-13 04:12:41 +04:00
|
|
|
rv = pluginHost->NewPluginStreamListener(mURI, inst,
|
|
|
|
getter_AddRefs(finalListener));
|
2012-12-07 03:10:54 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
mFinalListener = finalListener;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-05-29 13:38:46 +03:00
|
|
|
// Helper to spawn the frameloader.
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::SetupFrameLoader(int32_t aJSPluginId)
|
2015-05-20 16:30:05 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
mFrameLoader = nsFrameLoader::Create(thisContent->AsElement(),
|
|
|
|
/* aOpener = */ nullptr,
|
2017-05-29 13:38:46 +03:00
|
|
|
mNetworkCreated, aJSPluginId);
|
2015-05-20 16:30:05 +03:00
|
|
|
if (!mFrameLoader) {
|
|
|
|
NS_NOTREACHED("nsFrameLoader::Create failed");
|
2017-05-29 13:38:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper to spawn the frameloader and return a pointer to its docshell.
|
|
|
|
already_AddRefed<nsIDocShell>
|
|
|
|
nsObjectLoadingContent::SetupDocShell(nsIURI* aRecursionCheckURI)
|
|
|
|
{
|
|
|
|
SetupFrameLoader(nsFakePluginTag::NOT_JSPLUGIN);
|
|
|
|
if (!mFrameLoader) {
|
2015-05-20 16:30:05 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
|
|
|
|
|
|
|
if (aRecursionCheckURI) {
|
|
|
|
nsresult rv = mFrameLoader->CheckForRecursiveLoad(aRecursionCheckURI);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = mFrameLoader->GetDocShell(getter_AddRefs(docShell));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_NOTREACHED("Could not get DocShell from mFrameLoader?");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOG(("OBJLC [%p]: Aborting recursive load", this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!docShell) {
|
|
|
|
mFrameLoader->Destroy();
|
|
|
|
mFrameLoader = nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return docShell.forget();
|
|
|
|
}
|
2012-12-07 03:10:54 +04:00
|
|
|
|
2012-03-28 19:53:56 +04:00
|
|
|
nsresult
|
2012-07-06 01:07:46 +04:00
|
|
|
nsObjectLoadingContent::BindToTree(nsIDocument* aDocument,
|
2012-08-14 02:11:50 +04:00
|
|
|
nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2012-03-28 19:53:56 +04:00
|
|
|
{
|
2012-08-14 02:11:50 +04:00
|
|
|
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
|
2012-03-28 19:53:56 +04:00
|
|
|
if (aDocument) {
|
|
|
|
return aDocument->AddPlugin(this);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-14 02:11:50 +04:00
|
|
|
nsObjectLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
|
2012-03-28 19:53:56 +04:00
|
|
|
{
|
2012-08-14 02:11:50 +04:00
|
|
|
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
2012-03-28 19:53:56 +04:00
|
|
|
MOZ_ASSERT(thisContent);
|
|
|
|
nsIDocument* ownerDoc = thisContent->OwnerDoc();
|
|
|
|
ownerDoc->RemovePlugin(this);
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
/// XXX(johns): Do we want to somehow propogate the reparenting behavior to
|
|
|
|
/// FakePlugin types as well?
|
2014-02-21 01:34:06 +04:00
|
|
|
if (mType == eType_Plugin && (mInstanceOwner || mInstantiating)) {
|
2012-07-06 01:07:46 +04:00
|
|
|
// we'll let the plugin continue to run at least until we get back to
|
|
|
|
// the event loop. If we get back to the event loop and the node
|
|
|
|
// has still not been added back to the document then we tear down the
|
|
|
|
// plugin
|
2013-03-19 04:34:27 +04:00
|
|
|
QueueCheckPluginStopEvent();
|
2012-08-14 21:15:45 +04:00
|
|
|
} else if (mType != eType_Image) {
|
|
|
|
// nsImageLoadingContent handles the image case.
|
2012-07-06 04:56:25 +04:00
|
|
|
// Reset state and clear pending events
|
2012-07-06 01:07:46 +04:00
|
|
|
/// XXX(johns): The implementation for GenericFrame notes that ideally we
|
|
|
|
/// would keep the docshell around, but trash the frameloader
|
2012-07-06 00:47:39 +04:00
|
|
|
UnloadObject();
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2016-12-15 18:42:10 +03:00
|
|
|
if (mType == eType_Plugin) {
|
|
|
|
nsIDocument* doc = thisContent->GetComposedDoc();
|
|
|
|
if (doc && doc->IsActive()) {
|
|
|
|
nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(doc,
|
|
|
|
NS_LITERAL_STRING("PluginRemoved"));
|
|
|
|
NS_DispatchToCurrentThread(ev);
|
|
|
|
}
|
2013-11-06 01:43:53 +04:00
|
|
|
}
|
2012-03-28 19:53:56 +04:00
|
|
|
}
|
|
|
|
|
2005-10-31 21:28:56 +03:00
|
|
|
nsObjectLoadingContent::nsObjectLoadingContent()
|
2016-01-14 20:59:06 +03:00
|
|
|
: mType(eType_Loading)
|
2012-07-06 00:47:39 +04:00
|
|
|
, mFallbackType(eFallbackAlternate)
|
2015-03-17 20:28:32 +03:00
|
|
|
, mRunID(0)
|
|
|
|
, mHasRunID(false)
|
2012-07-06 01:07:46 +04:00
|
|
|
, mChannelLoaded(false)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mInstantiating(false)
|
|
|
|
, mNetworkCreated(true)
|
2012-07-06 01:07:46 +04:00
|
|
|
, mActivated(false)
|
2017-02-07 00:40:00 +03:00
|
|
|
, mContentBlockingEnabled(false)
|
2015-05-20 16:30:05 +03:00
|
|
|
, mSkipFakePlugins(false)
|
2012-05-26 02:34:11 +04:00
|
|
|
, mIsStopping(false)
|
2012-07-06 01:07:46 +04:00
|
|
|
, mIsLoading(false)
|
2016-06-24 13:12:53 +03:00
|
|
|
, mScriptRequested(false)
|
2017-01-24 08:07:51 +03:00
|
|
|
, mRewrittenYoutubeEmbed(false)
|
|
|
|
, mPreferFallback(false)
|
|
|
|
, mPreferFallbackKnown(false) {}
|
2005-09-21 23:14:30 +04:00
|
|
|
|
|
|
|
nsObjectLoadingContent::~nsObjectLoadingContent()
|
|
|
|
{
|
2013-03-19 04:34:27 +04:00
|
|
|
// Should have been unbound from the tree at this point, and
|
|
|
|
// CheckPluginStopEvent keeps us alive
|
2005-09-21 23:14:30 +04:00
|
|
|
if (mFrameLoader) {
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_NOTREACHED("Should not be tearing down frame loaders at this point");
|
2005-09-21 23:14:30 +04:00
|
|
|
mFrameLoader->Destroy();
|
|
|
|
}
|
2014-02-21 01:34:06 +04:00
|
|
|
if (mInstanceOwner || mInstantiating) {
|
2012-07-06 01:07:46 +04:00
|
|
|
// This is especially bad as delayed stop will try to hold on to this
|
|
|
|
// object...
|
|
|
|
NS_NOTREACHED("Should not be tearing down a plugin at this point!");
|
|
|
|
StopPluginInstance();
|
|
|
|
}
|
|
|
|
DestroyImageLoadingContent();
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
nsresult
|
2012-12-07 03:10:54 +04:00
|
|
|
nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
|
2012-02-01 01:55:54 +04:00
|
|
|
{
|
2012-12-07 03:10:54 +04:00
|
|
|
if (mInstanceOwner || mType != eType_Plugin || (mIsLoading != aIsLoading) ||
|
|
|
|
mInstantiating) {
|
|
|
|
// If we hit this assertion it's probably because LoadObject re-entered :(
|
|
|
|
//
|
|
|
|
// XXX(johns): This hackiness will go away in bug 767635
|
|
|
|
NS_ASSERTION(mIsLoading || !aIsLoading,
|
|
|
|
"aIsLoading should only be true inside LoadObject");
|
2012-09-07 06:03:22 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-12-07 03:10:54 +04:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
mInstantiating = true;
|
|
|
|
AutoSetInstantiatingToFalse autoInstantiating(this);
|
|
|
|
|
2012-09-07 06:03:22 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent *>(this));
|
2012-08-31 21:52:50 +04:00
|
|
|
|
2014-10-02 22:45:44 +04:00
|
|
|
nsCOMPtr<nsIDocument> doc = thisContent->GetComposedDoc();
|
2012-08-31 21:52:50 +04:00
|
|
|
if (!doc || !InActiveDocument(thisContent)) {
|
2012-09-07 06:03:22 +04:00
|
|
|
NS_ERROR("Shouldn't be calling "
|
2012-08-31 21:52:50 +04:00
|
|
|
"InstantiatePluginInstance without an active document");
|
2012-09-07 06:03:22 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-08-31 21:52:50 +04:00
|
|
|
// Instantiating an instance can result in script execution, which
|
|
|
|
// can destroy this DOM object. Don't allow that for the scope
|
|
|
|
// of this method.
|
|
|
|
nsCOMPtr<nsIObjectLoadingContent> kungFuDeathGrip = this;
|
|
|
|
|
|
|
|
// Flush layout so that the frame is created if possible and the plugin is
|
|
|
|
// initialized with the latest information.
|
2017-01-05 10:31:56 +03:00
|
|
|
doc->FlushPendingNotifications(FlushType::Layout);
|
2013-04-18 04:11:58 +04:00
|
|
|
// Flushing layout may have re-entered and loaded something underneath us
|
|
|
|
NS_ENSURE_TRUE(mInstantiating, NS_OK);
|
2012-12-07 03:09:10 +04:00
|
|
|
|
2012-08-31 21:52:50 +04:00
|
|
|
if (!thisContent->GetPrimaryFrame()) {
|
|
|
|
LOG(("OBJLC [%p]: Not instantiating plugin with no frame", this));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-12-07 03:09:10 +04:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2012-07-06 01:07:46 +04:00
|
|
|
|
|
|
|
if (!pluginHost) {
|
|
|
|
NS_NOTREACHED("No pluginhost");
|
2012-08-13 15:41:53 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-07-26 00:39:01 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
// If you add early return(s), be sure to balance this call to
|
|
|
|
// appShell->SuspendNative() with additional call(s) to
|
|
|
|
// appShell->ReturnNative().
|
|
|
|
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
|
|
|
|
if (appShell) {
|
|
|
|
appShell->SuspendNative();
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginInstanceOwner> newOwner;
|
2015-02-25 19:36:39 +03:00
|
|
|
rv = pluginHost->InstantiatePluginInstance(mContentType,
|
2012-12-13 04:12:41 +04:00
|
|
|
mURI.get(), this,
|
2013-04-18 04:11:58 +04:00
|
|
|
getter_AddRefs(newOwner));
|
|
|
|
|
|
|
|
// XXX(johns): We don't suspend native inside stopping plugins...
|
|
|
|
if (appShell) {
|
|
|
|
appShell->ResumeNative();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mInstantiating || NS_FAILED(rv)) {
|
|
|
|
LOG(("OBJLC [%p]: Plugin instantiation failed or re-entered, "
|
|
|
|
"killing old instance", this));
|
|
|
|
// XXX(johns): This needs to be de-duplicated with DoStopPlugin, but we
|
|
|
|
// don't want to touch the protochain or delayed stop.
|
|
|
|
// (Bug 767635)
|
|
|
|
if (newOwner) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> inst;
|
2013-04-18 04:11:58 +04:00
|
|
|
newOwner->GetInstance(getter_AddRefs(inst));
|
|
|
|
newOwner->SetFrame(nullptr);
|
|
|
|
if (inst) {
|
|
|
|
pluginHost->StopPluginInstance(inst);
|
|
|
|
}
|
|
|
|
newOwner->Destroy();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mInstanceOwner = newOwner;
|
|
|
|
|
2015-03-17 20:28:32 +03:00
|
|
|
if (mInstanceOwner) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> inst;
|
2015-03-17 20:28:32 +03:00
|
|
|
rv = mInstanceOwner->GetInstance(getter_AddRefs(inst));
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = inst->GetRunID(&mRunID);
|
|
|
|
mHasRunID = NS_SUCCEEDED(rv);
|
|
|
|
}
|
|
|
|
|
2013-04-18 02:11:21 +04:00
|
|
|
// Ensure the frame did not change during instantiation re-entry (common).
|
|
|
|
// HasNewFrame would not have mInstanceOwner yet, so the new frame would be
|
|
|
|
// dangling. (Bug 854082)
|
|
|
|
nsIFrame* frame = thisContent->GetPrimaryFrame();
|
|
|
|
if (frame && mInstanceOwner) {
|
2014-09-24 08:34:00 +04:00
|
|
|
mInstanceOwner->SetFrame(static_cast<nsPluginFrame*>(frame));
|
2013-05-11 01:28:39 +04:00
|
|
|
|
|
|
|
// Bug 870216 - Adobe Reader renders with incorrect dimensions until it gets
|
|
|
|
// a second SetWindow call. This is otherwise redundant.
|
|
|
|
mInstanceOwner->CallSetWindow();
|
2013-04-18 02:11:21 +04:00
|
|
|
}
|
2013-04-18 04:11:58 +04:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
// Set up scripting interfaces.
|
|
|
|
NotifyContentObjectWrapper();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pluginInstance;
|
2012-02-01 01:55:54 +04:00
|
|
|
GetPluginInstance(getter_AddRefs(pluginInstance));
|
|
|
|
if (pluginInstance) {
|
|
|
|
nsCOMPtr<nsIPluginTag> pluginTag;
|
2012-07-06 01:07:46 +04:00
|
|
|
pluginHost->GetPluginTagForInstance(pluginInstance,
|
|
|
|
getter_AddRefs(pluginTag));
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
nsCOMPtr<nsIBlocklistService> blocklist =
|
2012-07-06 01:07:46 +04:00
|
|
|
do_GetService("@mozilla.org/extensions/blocklist;1");
|
2012-02-01 01:55:54 +04:00
|
|
|
if (blocklist) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t blockState = nsIBlocklistService::STATE_NOT_BLOCKED;
|
2012-02-01 01:55:54 +04:00
|
|
|
blocklist->GetPluginBlocklistState(pluginTag, EmptyString(),
|
|
|
|
EmptyString(), &blockState);
|
2012-11-08 01:59:15 +04:00
|
|
|
if (blockState == nsIBlocklistService::STATE_OUTDATED) {
|
|
|
|
// Fire plugin outdated event if necessary
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("OBJLC [%p]: Dispatching plugin outdated event for content\n",
|
2012-11-08 01:59:15 +04:00
|
|
|
this));
|
2012-12-08 02:50:10 +04:00
|
|
|
nsCOMPtr<nsIRunnable> ev = new nsSimplePluginEvent(thisContent,
|
|
|
|
NS_LITERAL_STRING("PluginOutdated"));
|
2012-11-08 01:59:15 +04:00
|
|
|
nsresult rv = NS_DispatchToCurrentThread(ev);
|
|
|
|
if (NS_FAILED(rv)) {
|
2012-12-08 02:50:10 +04:00
|
|
|
NS_WARNING("failed to dispatch nsSimplePluginEvent");
|
2012-11-08 01:59:15 +04:00
|
|
|
}
|
|
|
|
}
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
2012-12-07 03:10:54 +04:00
|
|
|
|
|
|
|
// If we have a URI but didn't open a channel yet (eAllowPluginSkipChannel)
|
|
|
|
// or we did load with a channel but are re-instantiating, re-open the
|
|
|
|
// channel. OpenChannel() performs security checks, and this plugin has
|
|
|
|
// already passed content policy in LoadObject.
|
|
|
|
if ((mURI && !mChannelLoaded) || (mChannelLoaded && !aIsLoading)) {
|
|
|
|
NS_ASSERTION(!mChannel, "should not have an existing channel here");
|
2013-01-18 02:50:25 +04:00
|
|
|
// We intentionally ignore errors here, leaving it up to the plugin to
|
|
|
|
// deal with not having an initial stream.
|
|
|
|
OpenChannel();
|
2012-12-07 03:10:54 +04:00
|
|
|
}
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
|
|
|
|
2014-02-22 04:37:06 +04:00
|
|
|
nsCOMPtr<nsIRunnable> ev = \
|
|
|
|
new nsSimplePluginEvent(thisContent,
|
|
|
|
doc,
|
|
|
|
NS_LITERAL_STRING("PluginInstantiated"));
|
2013-06-24 16:51:07 +04:00
|
|
|
NS_DispatchToCurrentThread(ev);
|
|
|
|
|
2015-03-27 03:38:13 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
HTMLObjectElement::HandlePluginInstantiated(thisContent->AsElement());
|
|
|
|
#endif
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-16 01:17:35 +04:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::GetPluginAttributes(nsTArray<MozPluginParameter>& aAttributes)
|
|
|
|
{
|
|
|
|
aAttributes = mCachedAttributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::GetPluginParameters(nsTArray<MozPluginParameter>& aParameters)
|
|
|
|
{
|
|
|
|
aParameters = mCachedParameters;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-07-28 05:21:18 +03:00
|
|
|
nsObjectLoadingContent::GetNestedParams(nsTArray<MozPluginParameter>& aParams)
|
2014-08-16 01:17:35 +04:00
|
|
|
{
|
2017-02-02 18:32:58 +03:00
|
|
|
nsCOMPtr<Element> ourElement =
|
2014-08-16 01:17:35 +04:00
|
|
|
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
|
|
|
|
2017-02-02 18:32:58 +03:00
|
|
|
nsCOMPtr<nsIHTMLCollection> allParams;
|
2014-08-16 01:17:35 +04:00
|
|
|
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
|
2017-02-02 18:32:58 +03:00
|
|
|
ErrorResult rv;
|
|
|
|
allParams = ourElement->GetElementsByTagNameNS(xhtml_ns,
|
|
|
|
NS_LITERAL_STRING("param"),
|
|
|
|
rv);
|
|
|
|
if (rv.Failed()) {
|
2014-08-16 01:17:35 +04:00
|
|
|
return;
|
2017-02-02 18:32:58 +03:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(allParams);
|
2014-08-16 01:17:35 +04:00
|
|
|
|
2017-02-02 18:32:58 +03:00
|
|
|
uint32_t numAllParams = allParams->Length();
|
2014-08-16 01:17:35 +04:00
|
|
|
for (uint32_t i = 0; i < numAllParams; i++) {
|
2017-02-02 18:32:58 +03:00
|
|
|
RefPtr<Element> element = allParams->Item(i);
|
2014-08-16 01:17:35 +04:00
|
|
|
|
|
|
|
nsAutoString name;
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("name"), name);
|
|
|
|
|
|
|
|
if (name.IsEmpty())
|
|
|
|
continue;
|
|
|
|
|
2017-02-02 18:32:58 +03:00
|
|
|
nsCOMPtr<nsIContent> parent = element->GetParent();
|
2017-09-23 03:05:12 +03:00
|
|
|
RefPtr<HTMLObjectElement> objectElement;
|
|
|
|
while (!objectElement && parent) {
|
|
|
|
objectElement = HTMLObjectElement::FromContent(parent);
|
2017-02-02 18:32:58 +03:00
|
|
|
parent = parent->GetParent();
|
2014-08-16 01:17:35 +04:00
|
|
|
}
|
|
|
|
|
2017-09-23 03:05:12 +03:00
|
|
|
if (objectElement) {
|
|
|
|
parent = objectElement;
|
2014-08-16 01:17:35 +04:00
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:32:58 +03:00
|
|
|
if (parent == ourElement) {
|
2014-08-16 01:17:35 +04:00
|
|
|
MozPluginParameter param;
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("name"), param.mName);
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("value"), param.mValue);
|
|
|
|
|
|
|
|
param.mName.Trim(" \n\r\t\b", true, true, false);
|
|
|
|
param.mValue.Trim(" \n\r\t\b", true, true, false);
|
|
|
|
|
|
|
|
aParams.AppendElement(param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-08 07:17:58 +03:00
|
|
|
nsresult
|
2014-08-16 01:17:35 +04:00
|
|
|
nsObjectLoadingContent::BuildParametersArray()
|
|
|
|
{
|
|
|
|
if (mCachedAttributes.Length() || mCachedParameters.Length()) {
|
|
|
|
MOZ_ASSERT(false, "Parameters array should be empty.");
|
2016-09-08 07:17:58 +03:00
|
|
|
return NS_OK;
|
2014-08-16 01:17:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
|
2016-10-14 00:52:55 +03:00
|
|
|
for (uint32_t i = 0; i != content->GetAttrCount(); i += 1) {
|
2014-08-16 01:17:35 +04:00
|
|
|
MozPluginParameter param;
|
|
|
|
const nsAttrName* attrName = content->GetAttrNameAt(i);
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* atom = attrName->LocalName();
|
2014-08-16 01:17:35 +04:00
|
|
|
content->GetAttr(attrName->NamespaceID(), atom, param.mValue);
|
|
|
|
atom->ToString(param.mName);
|
|
|
|
mCachedAttributes.AppendElement(param);
|
|
|
|
}
|
|
|
|
|
2017-07-31 13:13:28 +03:00
|
|
|
nsAutoCString wmodeOverride;
|
|
|
|
Preferences::GetCString("plugins.force.wmode", wmodeOverride);
|
|
|
|
|
2014-08-16 01:17:35 +04:00
|
|
|
for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
|
|
|
|
if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
|
|
|
|
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
|
|
|
|
wmodeOverride.Truncate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wmodeOverride.IsEmpty()) {
|
|
|
|
MozPluginParameter param;
|
|
|
|
param.mName = NS_LITERAL_STRING("wmode");
|
|
|
|
CopyASCIItoUTF16(wmodeOverride, param.mValue);
|
|
|
|
mCachedAttributes.AppendElement(param);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some plugins were never written to understand the "data" attribute of the OBJECT tag.
|
|
|
|
// Real and WMP will not play unless they find a "src" attribute, see bug 152334.
|
|
|
|
// Nav 4.x would simply replace the "data" with "src". Because some plugins correctly
|
|
|
|
// look for "data", lets instead copy the "data" attribute and add another entry
|
|
|
|
// to the bottom of the array if there isn't already a "src" specified.
|
2015-03-03 14:09:00 +03:00
|
|
|
if (content->IsHTMLElement(nsGkAtoms::object) &&
|
2014-08-16 01:17:35 +04:00
|
|
|
!content->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
|
|
|
|
MozPluginParameter param;
|
|
|
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::data, param.mValue);
|
|
|
|
if (!param.mValue.IsEmpty()) {
|
|
|
|
param.mName = NS_LITERAL_STRING("SRC");
|
|
|
|
mCachedAttributes.AppendElement(param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:21:18 +03:00
|
|
|
GetNestedParams(mCachedParameters);
|
2016-09-08 07:17:58 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
2014-08-16 01:17:35 +04:00
|
|
|
}
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::NotifyOwnerDocumentActivityChanged()
|
|
|
|
{
|
2013-03-19 04:34:43 +04:00
|
|
|
// XXX(johns): We cannot touch plugins or run arbitrary script from this call,
|
|
|
|
// as nsDocument is in a non-reentrant state.
|
2012-02-01 01:55:54 +04:00
|
|
|
|
2013-03-19 04:34:27 +04:00
|
|
|
// If we have a plugin we want to queue an event to stop it unless we are
|
|
|
|
// moved into an active document before returning to the event loop.
|
2014-07-21 22:30:20 +04:00
|
|
|
if (mInstanceOwner || mInstantiating) {
|
2013-03-19 04:34:27 +04:00
|
|
|
QueueCheckPluginStopEvent();
|
2014-07-21 22:30:20 +04:00
|
|
|
}
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// nsIRequestObserver
|
|
|
|
NS_IMETHODIMP
|
2008-03-28 02:12:18 +03:00
|
|
|
nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL("nsObjectLoadingContent::OnStartRequest", NETWORK);
|
2012-02-01 01:55:54 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: Channel OnStartRequest", this));
|
|
|
|
|
2011-11-04 09:23:26 +04:00
|
|
|
if (aRequest != mChannel || !aRequest) {
|
2012-07-06 01:07:46 +04:00
|
|
|
// happens when a new load starts before the previous one got here
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
2012-12-07 03:10:54 +04:00
|
|
|
// If we already switched to type plugin, this channel can just be passed to
|
|
|
|
// the final listener.
|
|
|
|
if (mType == eType_Plugin) {
|
2013-01-18 02:50:25 +04:00
|
|
|
if (!mInstanceOwner) {
|
2012-12-07 03:10:54 +04:00
|
|
|
// We drop mChannel when stopping plugins, so something is wrong
|
|
|
|
NS_NOTREACHED("Opened a channel in plugin mode, but don't have a plugin");
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
2013-01-18 02:50:25 +04:00
|
|
|
if (MakePluginListener()) {
|
|
|
|
return mFinalListener->OnStartRequest(aRequest, nullptr);
|
|
|
|
}
|
2017-02-09 17:44:02 +03:00
|
|
|
NS_NOTREACHED("Failed to create PluginStreamListener, aborting channel");
|
|
|
|
return NS_BINDING_ABORTED;
|
2012-12-07 03:10:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise we should be state loading, and call LoadObject with the channel
|
|
|
|
if (mType != eType_Loading) {
|
|
|
|
NS_NOTREACHED("Should be type loading at this point");
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
2013-07-23 02:08:09 +04:00
|
|
|
NS_ASSERTION(!mChannelLoaded, "mChannelLoaded set already?");
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_ASSERTION(!mFinalListener, "mFinalListener exists already?");
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
mChannelLoaded = true;
|
2005-09-21 23:14:30 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
|
|
|
|
NS_ASSERTION(chan, "Why is our request not a channel?");
|
|
|
|
|
2017-02-07 00:40:00 +03:00
|
|
|
nsresult status = NS_OK;
|
2016-06-17 13:05:42 +03:00
|
|
|
bool success = IsSuccessfulRequest(aRequest, &status);
|
|
|
|
|
|
|
|
if (status == NS_ERROR_BLOCKED_URI) {
|
|
|
|
nsCOMPtr<nsIConsoleService> console(
|
|
|
|
do_GetService("@mozilla.org/consoleservice;1"));
|
|
|
|
if (console) {
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
chan->GetURI(getter_AddRefs(uri));
|
|
|
|
nsString message = NS_LITERAL_STRING("Blocking ") +
|
2016-08-26 09:02:31 +03:00
|
|
|
NS_ConvertASCIItoUTF16(uri->GetSpecOrDefault().get()) +
|
2016-06-17 13:05:42 +03:00
|
|
|
NS_LITERAL_STRING(" since it was found on an internal Firefox blocklist.");
|
|
|
|
console->LogStringMessage(message.get());
|
|
|
|
}
|
2017-02-07 00:40:00 +03:00
|
|
|
mContentBlockingEnabled = true;
|
2016-06-17 13:05:42 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2017-02-09 17:44:02 +03:00
|
|
|
}
|
2017-04-06 01:26:52 +03:00
|
|
|
|
2017-02-09 17:44:02 +03:00
|
|
|
if (status == NS_ERROR_TRACKING_URI) {
|
2017-02-07 00:40:00 +03:00
|
|
|
mContentBlockingEnabled = true;
|
2016-06-17 13:05:42 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2007-08-21 07:26:12 +04:00
|
|
|
}
|
|
|
|
|
2016-06-17 13:05:42 +03:00
|
|
|
if (!success) {
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: OnStartRequest: Request failed\n", this));
|
|
|
|
// If the request fails, we still call LoadObject() to handle fallback
|
|
|
|
// content and notifying of failure. (mChannelLoaded && !mChannel) indicates
|
|
|
|
// the bad state.
|
|
|
|
mChannel = nullptr;
|
|
|
|
LoadObject(true, false);
|
2012-04-25 00:25:21 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2008-03-28 02:12:18 +03:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return LoadObject(true, false, aRequest);
|
2012-07-26 00:39:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::OnStopRequest(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsresult aStatusCode)
|
|
|
|
{
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL("nsObjectLoadingContent::OnStopRequest", NETWORK);
|
2014-05-24 01:12:29 +04:00
|
|
|
|
2014-08-09 02:16:41 +04:00
|
|
|
// Handle object not loading error because source was a tracking URL.
|
|
|
|
// We make a note of this object node by including it in a dedicated
|
|
|
|
// array of blocked tracking nodes under its parent document.
|
|
|
|
if (aStatusCode == NS_ERROR_TRACKING_URI) {
|
|
|
|
nsCOMPtr<nsIContent> thisNode =
|
|
|
|
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
2014-10-02 22:45:44 +04:00
|
|
|
if (thisNode && thisNode->IsInComposedDoc()) {
|
|
|
|
thisNode->GetComposedDoc()->AddBlockedTrackingNode(thisNode);
|
2014-08-09 02:16:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-26 00:39:01 +04:00
|
|
|
if (aRequest != mChannel) {
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mChannel = nullptr;
|
2012-07-26 00:39:01 +04:00
|
|
|
|
|
|
|
if (mFinalListener) {
|
2012-10-05 00:50:49 +04:00
|
|
|
// This may re-enter in the case of plugin listeners
|
|
|
|
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
|
2012-07-30 18:20:58 +04:00
|
|
|
mFinalListener = nullptr;
|
2012-10-05 00:50:49 +04:00
|
|
|
listenerGrip->OnStopRequest(aRequest, aContext, aStatusCode);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return value doesn't matter
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// nsIStreamListener
|
|
|
|
NS_IMETHODIMP
|
2011-11-04 09:23:26 +04:00
|
|
|
nsObjectLoadingContent::OnDataAvailable(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsIInputStream *aInputStream,
|
2012-09-06 06:41:02 +04:00
|
|
|
uint64_t aOffset, uint32_t aCount)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
|
|
|
if (aRequest != mChannel) {
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFinalListener) {
|
2012-10-05 00:50:49 +04:00
|
|
|
// This may re-enter in the case of plugin listeners
|
|
|
|
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
|
|
|
|
return listenerGrip->OnDataAvailable(aRequest, aContext, aInputStream,
|
|
|
|
aOffset, aCount);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// We shouldn't have a connected channel with no final listener
|
|
|
|
NS_NOTREACHED("Got data for channel with no connected final listener");
|
|
|
|
mChannel = nullptr;
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIFrameLoaderOwner
|
|
|
|
NS_IMETHODIMP
|
2016-08-11 19:09:22 +03:00
|
|
|
nsObjectLoadingContent::GetFrameLoaderXPCOM(nsIFrameLoader** aFrameLoader)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_IF_ADDREF(*aFrameLoader = mFrameLoader);
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-21 01:33:59 +04:00
|
|
|
NS_IMETHODIMP_(already_AddRefed<nsFrameLoader>)
|
|
|
|
nsObjectLoadingContent::GetFrameLoader()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameLoader> loader = mFrameLoader;
|
2013-04-22 15:15:59 +04:00
|
|
|
return loader.forget();
|
2009-10-21 01:33:59 +04:00
|
|
|
}
|
|
|
|
|
2016-10-07 21:59:59 +03:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
|
2015-01-05 22:16:09 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::SetIsPrerendered()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2016-10-17 17:37:50 +03:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::InternalSetFrameLoader(nsIFrameLoader* aNewFrameLoader)
|
|
|
|
{
|
|
|
|
MOZ_CRASH("You shouldn't be calling this function, it doesn't make any sense on this type.");
|
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetActualType(nsACString& aType)
|
|
|
|
{
|
|
|
|
aType = mContentType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsObjectLoadingContent::GetDisplayedType(uint32_t* aType)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2013-03-04 23:08:24 +04:00
|
|
|
*aType = DisplayedType();
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-12-03 14:27:42 +03:00
|
|
|
NS_IMETHODIMP
|
2012-02-01 01:55:54 +04:00
|
|
|
nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
|
2005-12-03 14:27:42 +03:00
|
|
|
{
|
2012-09-07 04:16:02 +04:00
|
|
|
if (mType != eType_Plugin) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aFrame) {
|
|
|
|
// Lost our frame. If we aren't going to be getting a new frame, e.g. we've
|
|
|
|
// become display:none, we'll want to stop the plugin. Queue a
|
|
|
|
// CheckPluginStopEvent
|
2014-02-21 01:34:06 +04:00
|
|
|
if (mInstanceOwner || mInstantiating) {
|
|
|
|
if (mInstanceOwner) {
|
|
|
|
mInstanceOwner->SetFrame(nullptr);
|
|
|
|
}
|
2013-03-19 04:34:27 +04:00
|
|
|
QueueCheckPluginStopEvent();
|
2012-09-07 04:16:02 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-07-26 00:39:01 +04:00
|
|
|
|
2012-09-07 04:16:02 +04:00
|
|
|
// Have a new frame
|
2011-08-30 10:09:56 +04:00
|
|
|
|
2012-09-07 04:16:02 +04:00
|
|
|
if (!mInstanceOwner) {
|
|
|
|
// We are successfully setup as type plugin, but have not spawned an
|
|
|
|
// instance due to a lack of a frame.
|
|
|
|
AsyncStartPluginInstance();
|
|
|
|
return NS_OK;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-09-07 04:16:02 +04:00
|
|
|
|
|
|
|
// Otherwise, we're just changing frames
|
|
|
|
// Set up relationship between instance owner and frame.
|
2014-09-24 08:34:00 +04:00
|
|
|
nsPluginFrame *objFrame = static_cast<nsPluginFrame*>(aFrame);
|
2012-09-07 04:16:02 +04:00
|
|
|
mInstanceOwner->SetFrame(objFrame);
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
return NS_OK;
|
2005-12-03 14:27:42 +03:00
|
|
|
}
|
|
|
|
|
2008-03-15 02:08:57 +03:00
|
|
|
NS_IMETHODIMP
|
2011-05-18 05:48:34 +04:00
|
|
|
nsObjectLoadingContent::GetPluginInstance(nsNPAPIPluginInstance** aInstance)
|
2008-03-15 02:08:57 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aInstance = nullptr;
|
2008-03-15 02:08:57 +03:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
if (!mInstanceOwner) {
|
2008-03-15 02:08:57 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
return mInstanceOwner->GetInstance(aInstance);
|
2008-03-15 02:08:57 +03:00
|
|
|
}
|
|
|
|
|
2006-04-24 23:56:18 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetContentTypeForMIMEType(const nsACString& aMIMEType,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t* aType)
|
2006-04-24 23:56:18 +04:00
|
|
|
{
|
2015-05-20 16:30:05 +03:00
|
|
|
*aType = GetTypeOfContent(PromiseFlatCString(aMIMEType), false);
|
2006-04-24 23:56:18 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-22 05:02:23 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetBaseURI(nsIURI **aResult)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*aResult = mBaseURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
// nsIInterfaceRequestor
|
2013-06-19 18:24:37 +04:00
|
|
|
// We use a shim class to implement this so that JS consumers still
|
|
|
|
// see an interface requestor even though WebIDL bindings don't expose
|
|
|
|
// that stuff.
|
2015-03-21 19:28:04 +03:00
|
|
|
class ObjectInterfaceRequestorShim final : public nsIInterfaceRequestor,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIChannelEventSink,
|
|
|
|
public nsIStreamListener
|
2013-06-19 18:24:37 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ObjectInterfaceRequestorShim,
|
|
|
|
nsIInterfaceRequestor)
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
2015-10-18 08:24:48 +03:00
|
|
|
// RefPtr<nsObjectLoadingContent> fails due to ambiguous AddRef/Release,
|
2013-07-10 21:39:46 +04:00
|
|
|
// hence the ugly static cast :(
|
|
|
|
NS_FORWARD_NSICHANNELEVENTSINK(static_cast<nsObjectLoadingContent *>
|
|
|
|
(mContent.get())->)
|
|
|
|
NS_FORWARD_NSISTREAMLISTENER (static_cast<nsObjectLoadingContent *>
|
|
|
|
(mContent.get())->)
|
|
|
|
NS_FORWARD_NSIREQUESTOBSERVER (static_cast<nsObjectLoadingContent *>
|
|
|
|
(mContent.get())->)
|
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit ObjectInterfaceRequestorShim(nsIObjectLoadingContent* aContent)
|
2013-06-19 18:24:37 +04:00
|
|
|
: mContent(aContent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
2016-11-14 12:40:37 +03:00
|
|
|
~ObjectInterfaceRequestorShim() = default;
|
2013-07-10 21:39:46 +04:00
|
|
|
nsCOMPtr<nsIObjectLoadingContent> mContent;
|
2013-06-19 18:24:37 +04:00
|
|
|
};
|
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION(ObjectInterfaceRequestorShim, mContent)
|
2013-06-19 18:24:37 +04:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ObjectInterfaceRequestorShim)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
|
2013-07-10 21:39:46 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
2013-06-19 18:24:37 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(ObjectInterfaceRequestorShim)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(ObjectInterfaceRequestorShim)
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
NS_IMETHODIMP
|
2013-06-19 18:24:37 +04:00
|
|
|
ObjectInterfaceRequestorShim::GetInterface(const nsIID & aIID, void **aResult)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
|
|
|
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-05 06:15:55 +04:00
|
|
|
nsObjectLoadingContent::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
|
|
|
nsIChannel *aNewChannel,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags,
|
2010-08-05 06:15:55 +04:00
|
|
|
nsIAsyncVerifyRedirectCallback *cb)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2011-02-28 22:26:05 +03:00
|
|
|
// If we're already busy with a new load, or have no load at all,
|
|
|
|
// cancel the redirect.
|
|
|
|
if (!mChannel || aOldChannel != mChannel) {
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
mChannel = aNewChannel;
|
2010-08-05 06:15:55 +04:00
|
|
|
cb->OnRedirectVerifyCallback(NS_OK);
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// <public>
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates
|
2005-09-21 23:14:30 +04:00
|
|
|
nsObjectLoadingContent::ObjectState() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eType_Loading:
|
2005-10-17 04:50:39 +04:00
|
|
|
return NS_EVENT_STATE_LOADING;
|
2005-09-21 23:14:30 +04:00
|
|
|
case eType_Image:
|
|
|
|
return ImageState();
|
|
|
|
case eType_Plugin:
|
2015-05-20 16:30:05 +03:00
|
|
|
case eType_FakePlugin:
|
2011-11-20 08:08:27 +04:00
|
|
|
case eType_Document:
|
2005-09-21 23:14:30 +04:00
|
|
|
// 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.
|
2014-04-03 08:18:36 +04:00
|
|
|
return EventStates();
|
2005-09-21 23:14:30 +04:00
|
|
|
case eType_Null:
|
2012-07-06 00:47:39 +04:00
|
|
|
switch (mFallbackType) {
|
|
|
|
case eFallbackSuppressed:
|
|
|
|
return NS_EVENT_STATE_SUPPRESSED;
|
|
|
|
case eFallbackUserDisabled:
|
|
|
|
return NS_EVENT_STATE_USERDISABLED;
|
|
|
|
case eFallbackClickToPlay:
|
2011-10-07 21:46:02 +04:00
|
|
|
return NS_EVENT_STATE_TYPE_CLICK_TO_PLAY;
|
2012-07-06 00:47:39 +04:00
|
|
|
case eFallbackDisabled:
|
|
|
|
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_DISABLED;
|
|
|
|
case eFallbackBlocklisted:
|
|
|
|
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_BLOCKED;
|
|
|
|
case eFallbackCrashed:
|
|
|
|
return NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_HANDLER_CRASHED;
|
2016-10-06 20:25:56 +03:00
|
|
|
case eFallbackUnsupported:
|
2012-07-06 00:47:39 +04:00
|
|
|
case eFallbackOutdated:
|
|
|
|
case eFallbackAlternate:
|
|
|
|
return NS_EVENT_STATE_BROKEN;
|
|
|
|
case eFallbackVulnerableUpdatable:
|
|
|
|
return NS_EVENT_STATE_VULNERABLE_UPDATABLE;
|
|
|
|
case eFallbackVulnerableNoUpdate:
|
|
|
|
return NS_EVENT_STATE_VULNERABLE_NO_UPDATE;
|
2005-12-29 17:15:33 +03:00
|
|
|
}
|
2016-01-22 18:58:49 +03:00
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
NS_NOTREACHED("unknown type?");
|
2012-07-06 01:07:46 +04:00
|
|
|
return NS_EVENT_STATE_LOADING;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2016-02-26 02:49:18 +03:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::MaybeRewriteYoutubeEmbed(nsIURI* aURI, nsIURI* aBaseURI, nsIURI** aOutURI)
|
2015-09-29 02:06:31 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "Must be an instance of content");
|
|
|
|
|
2015-10-30 18:03:00 +03:00
|
|
|
// We're only interested in switching out embed and object tags
|
|
|
|
if (!thisContent->NodeInfo()->Equals(nsGkAtoms::embed) &&
|
|
|
|
!thisContent->NodeInfo()->Equals(nsGkAtoms::object)) {
|
2016-02-26 02:49:18 +03:00
|
|
|
return;
|
2015-09-29 02:06:31 +03:00
|
|
|
}
|
2016-02-26 02:49:18 +03:00
|
|
|
|
2015-09-29 02:06:31 +03:00
|
|
|
nsCOMPtr<nsIEffectiveTLDService> tldService =
|
|
|
|
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
|
|
|
// If we can't analyze the URL, just pass on through.
|
|
|
|
if(!tldService) {
|
|
|
|
NS_WARNING("Could not get TLD service!");
|
2016-02-26 02:49:18 +03:00
|
|
|
return;
|
2015-09-29 02:06:31 +03:00
|
|
|
}
|
2016-01-06 11:01:59 +03:00
|
|
|
|
2015-09-29 02:06:31 +03:00
|
|
|
nsAutoCString currentBaseDomain;
|
2016-01-06 11:01:59 +03:00
|
|
|
bool ok = NS_SUCCEEDED(tldService->GetBaseDomain(aURI, 0, currentBaseDomain));
|
2015-09-29 02:06:31 +03:00
|
|
|
if (!ok) {
|
2016-01-06 11:01:59 +03:00
|
|
|
// Data URIs (commonly used for things like svg embeds) won't parse
|
|
|
|
// correctly, so just fail silently here.
|
2016-02-26 02:49:18 +03:00
|
|
|
return;
|
2015-09-29 02:06:31 +03:00
|
|
|
}
|
2016-01-06 11:01:59 +03:00
|
|
|
|
2015-10-30 18:03:00 +03:00
|
|
|
// See if URL is referencing youtube
|
2017-09-08 23:02:22 +03:00
|
|
|
if (!currentBaseDomain.EqualsLiteral("youtube.com") &&
|
|
|
|
!currentBaseDomain.EqualsLiteral("youtube-nocookie.com")) {
|
2016-02-26 02:49:18 +03:00
|
|
|
return;
|
2015-10-30 18:03:00 +03:00
|
|
|
}
|
2016-01-06 11:01:59 +03:00
|
|
|
|
|
|
|
// We should only rewrite URLs with paths starting with "/v/", as we shouldn't
|
|
|
|
// touch object nodes with "/embed/" urls that already do that right thing.
|
|
|
|
nsAutoCString path;
|
2017-07-29 14:50:21 +03:00
|
|
|
aURI->GetPathQueryRef(path);
|
2016-01-06 11:01:59 +03:00
|
|
|
if (!StringBeginsWith(path, NS_LITERAL_CSTRING("/v/"))) {
|
2016-02-26 02:49:18 +03:00
|
|
|
return;
|
2016-01-06 11:01:59 +03:00
|
|
|
}
|
|
|
|
|
2015-10-30 18:03:00 +03:00
|
|
|
// See if requester is planning on using the JS API.
|
|
|
|
nsAutoCString uri;
|
2016-09-08 07:17:58 +03:00
|
|
|
nsresult rv = aURI->GetSpec(uri);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-22 15:55:13 +03:00
|
|
|
// Some YouTube urls have parameters in path components, e.g.
|
2016-02-26 02:49:18 +03:00
|
|
|
// http://youtube.com/embed/7LcUOEP7Brc&start=35. These URLs work with flash,
|
|
|
|
// but break iframe/object embedding. If this situation occurs with rewritten
|
2016-06-22 15:55:13 +03:00
|
|
|
// URLs, convert the parameters to query in order to make the video load
|
|
|
|
// correctly as an iframe. In either case, warn about it in the
|
2016-02-26 02:49:18 +03:00
|
|
|
// developer console.
|
|
|
|
int32_t ampIndex = uri.FindChar('&', 0);
|
2016-06-22 15:55:13 +03:00
|
|
|
bool replaceQuery = false;
|
2016-02-26 02:49:18 +03:00
|
|
|
if (ampIndex != -1) {
|
|
|
|
int32_t qmIndex = uri.FindChar('?', 0);
|
|
|
|
if (qmIndex == -1 ||
|
|
|
|
qmIndex > ampIndex) {
|
2016-06-22 15:55:13 +03:00
|
|
|
replaceQuery = true;
|
2016-02-26 02:49:18 +03:00
|
|
|
}
|
2015-09-29 02:06:31 +03:00
|
|
|
}
|
2016-01-06 11:01:59 +03:00
|
|
|
|
2016-02-26 02:49:18 +03:00
|
|
|
// If we're pref'd off, return after telemetry has been logged.
|
|
|
|
if (!Preferences::GetBool(kPrefYoutubeRewrite)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString utf16OldURI = NS_ConvertUTF8toUTF16(uri);
|
2016-06-22 15:55:13 +03:00
|
|
|
// If we need to convert the URL, it means an ampersand comes first.
|
|
|
|
// Use the index we found earlier.
|
|
|
|
if (replaceQuery) {
|
|
|
|
// Replace question marks with ampersands.
|
|
|
|
uri.ReplaceChar('?', '&');
|
|
|
|
// Replace the first ampersand with a question mark.
|
|
|
|
uri.SetCharAt('?', ampIndex);
|
2016-02-26 02:49:18 +03:00
|
|
|
}
|
|
|
|
// Switch out video access url formats, which should possibly allow HTML5
|
|
|
|
// video loading.
|
|
|
|
uri.ReplaceSubstring(NS_LITERAL_CSTRING("/v/"),
|
|
|
|
NS_LITERAL_CSTRING("/embed/"));
|
|
|
|
nsAutoString utf16URI = NS_ConvertUTF8toUTF16(uri);
|
2016-09-08 07:17:58 +03:00
|
|
|
rv = nsContentUtils::NewURIWithDocumentCharset(aOutURI,
|
|
|
|
utf16URI,
|
|
|
|
thisContent->OwnerDoc(),
|
|
|
|
aBaseURI);
|
2016-02-26 02:49:18 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const char16_t* params[] = { utf16OldURI.get(), utf16URI.get() };
|
|
|
|
const char* msgName;
|
|
|
|
// If there's no query to rewrite, just notify in the developer console
|
|
|
|
// that we're changing the embed.
|
2016-06-22 15:55:13 +03:00
|
|
|
if (!replaceQuery) {
|
2016-06-22 15:55:14 +03:00
|
|
|
msgName = "RewriteYouTubeEmbed";
|
2016-02-26 02:49:18 +03:00
|
|
|
} else {
|
2016-06-22 15:55:14 +03:00
|
|
|
msgName = "RewriteYouTubeEmbedPathParams";
|
2016-02-26 02:49:18 +03:00
|
|
|
}
|
|
|
|
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
|
|
|
NS_LITERAL_CSTRING("Plugins"),
|
|
|
|
thisContent->OwnerDoc(),
|
|
|
|
nsContentUtils::eDOM_PROPERTIES,
|
|
|
|
msgName,
|
|
|
|
params, ArrayLength(params));
|
2015-09-29 02:06:31 +03:00
|
|
|
}
|
|
|
|
|
2012-08-17 05:44:14 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsObjectLoadingContent::CheckLoadPolicy(int16_t *aContentPolicy)
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
2012-08-17 05:44:14 +04:00
|
|
|
if (!aContentPolicy || !mURI) {
|
|
|
|
NS_NOTREACHED("Doing it wrong");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "Must be an instance of content");
|
|
|
|
|
2012-08-17 05:44:14 +04:00
|
|
|
nsIDocument* doc = thisContent->OwnerDoc();
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2015-07-18 18:51:00 +03:00
|
|
|
nsContentPolicyType contentPolicyType = GetContentPolicyType();
|
|
|
|
|
2012-08-17 05:44:14 +04:00
|
|
|
*aContentPolicy = nsIContentPolicy::ACCEPT;
|
2015-07-18 18:51:00 +03:00
|
|
|
nsresult rv = NS_CheckContentLoadPolicy(contentPolicyType,
|
2012-08-17 05:44:14 +04:00
|
|
|
mURI,
|
Bug 1407056: Part 1 - Provide more consistent principal/origin URL to content policies. r=bz,ckerschb
We're currently fairly vague and inconsistent about the values we provide to
content policy implementations for requestOrigin and requestPrincipal. In some
cases they're the triggering principal, sometimes the loading principal,
sometimes the channel principal.
Our existing content policy implementations which require or expect a loading
principal currently retrieve it from the context node. Since no current
callers require the principal to be the loading principal, and some already
expect it to be the triggering principal (which there's currently no other way
to retrieve), I chose to pass the triggering principal whenever possible, but
use the loading principal to determine the origin URL.
As a follow-up, I'd like to change the nsIContentPolicy interface to
explicitly receive loading and triggering principals, or possibly just
LoadInfo instances, rather than poorly-defined request
origin/principal/context args. But since that may cause trouble for
comm-central, I'd rather not do it as part of this bug.
MozReview-Commit-ID: LqD9GxdzMte
--HG--
extra : rebase_source : 41ce439912ae7b895e0a3b0e660fa6ba571eb50f
2017-10-13 01:43:55 +03:00
|
|
|
doc->NodePrincipal(), // loading principal
|
|
|
|
doc->NodePrincipal(), // triggering principal
|
2012-08-17 05:44:14 +04:00
|
|
|
thisContent,
|
|
|
|
mContentType,
|
|
|
|
nullptr, //extra
|
|
|
|
aContentPolicy,
|
2017-07-11 01:00:03 +03:00
|
|
|
nsContentUtils::GetContentPolicy());
|
2012-08-17 05:44:14 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
if (NS_CP_REJECTED(*aContentPolicy)) {
|
2016-08-26 09:02:31 +03:00
|
|
|
LOG(("OBJLC [%p]: Content policy denied load of %s",
|
|
|
|
this, mURI->GetSpecOrDefault().get()));
|
2012-07-06 01:07:46 +04:00
|
|
|
return false;
|
2007-07-27 06:49:18 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return true;
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-08-17 05:44:14 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsObjectLoadingContent::CheckProcessPolicy(int16_t *aContentPolicy)
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
2012-08-17 05:44:14 +04:00
|
|
|
if (!aContentPolicy) {
|
|
|
|
NS_NOTREACHED("Null out variable");
|
|
|
|
return false;
|
|
|
|
}
|
2005-10-31 21:28:56 +03:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2012-07-06 01:07:46 +04:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_ASSERTION(thisContent, "Must be an instance of content");
|
|
|
|
|
2012-07-26 00:39:01 +04:00
|
|
|
nsIDocument* doc = thisContent->OwnerDoc();
|
2016-01-09 03:11:58 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t objectType;
|
2012-08-17 05:44:14 +04:00
|
|
|
switch (mType) {
|
|
|
|
case eType_Image:
|
2015-09-21 00:55:59 +03:00
|
|
|
objectType = nsIContentPolicy::TYPE_INTERNAL_IMAGE;
|
2012-08-17 05:44:14 +04:00
|
|
|
break;
|
|
|
|
case eType_Document:
|
|
|
|
objectType = nsIContentPolicy::TYPE_DOCUMENT;
|
|
|
|
break;
|
2015-05-20 16:30:05 +03:00
|
|
|
// FIXME Fake plugins look just like real plugins to CSP, should they use
|
|
|
|
// the fake plugin's handler URI and look like documents instead?
|
|
|
|
case eType_FakePlugin:
|
2012-08-17 05:44:14 +04:00
|
|
|
case eType_Plugin:
|
2015-07-18 18:51:00 +03:00
|
|
|
objectType = GetContentPolicyType();
|
2012-08-17 05:44:14 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Calling checkProcessPolicy with a unloadable type");
|
|
|
|
return false;
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-08-17 05:44:14 +04:00
|
|
|
*aContentPolicy = nsIContentPolicy::ACCEPT;
|
|
|
|
nsresult rv =
|
|
|
|
NS_CheckContentProcessPolicy(objectType,
|
2013-07-09 21:29:06 +04:00
|
|
|
mURI ? mURI : mBaseURI,
|
Bug 1407056: Part 1 - Provide more consistent principal/origin URL to content policies. r=bz,ckerschb
We're currently fairly vague and inconsistent about the values we provide to
content policy implementations for requestOrigin and requestPrincipal. In some
cases they're the triggering principal, sometimes the loading principal,
sometimes the channel principal.
Our existing content policy implementations which require or expect a loading
principal currently retrieve it from the context node. Since no current
callers require the principal to be the loading principal, and some already
expect it to be the triggering principal (which there's currently no other way
to retrieve), I chose to pass the triggering principal whenever possible, but
use the loading principal to determine the origin URL.
As a follow-up, I'd like to change the nsIContentPolicy interface to
explicitly receive loading and triggering principals, or possibly just
LoadInfo instances, rather than poorly-defined request
origin/principal/context args. But since that may cause trouble for
comm-central, I'd rather not do it as part of this bug.
MozReview-Commit-ID: LqD9GxdzMte
--HG--
extra : rebase_source : 41ce439912ae7b895e0a3b0e660fa6ba571eb50f
2017-10-13 01:43:55 +03:00
|
|
|
doc->NodePrincipal(), // loading principal
|
|
|
|
doc->NodePrincipal(), // triggering principal
|
2012-07-06 01:07:46 +04:00
|
|
|
static_cast<nsIImageLoadingContent*>(this),
|
|
|
|
mContentType,
|
|
|
|
nullptr, //extra
|
2012-08-17 05:44:14 +04:00
|
|
|
aContentPolicy,
|
2017-07-11 01:00:03 +03:00
|
|
|
nsContentUtils::GetContentPolicy());
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2012-08-17 05:44:14 +04:00
|
|
|
|
|
|
|
if (NS_CP_REJECTED(*aContentPolicy)) {
|
|
|
|
LOG(("OBJLC [%p]: CheckContentProcessPolicy rejected load", this));
|
2012-07-06 01:07:46 +04:00
|
|
|
return false;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-08-17 05:44:14 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return true;
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
nsObjectLoadingContent::ParameterUpdateFlags
|
2017-07-28 05:21:18 +03:00
|
|
|
nsObjectLoadingContent::UpdateObjectParameters()
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "Must be an instance of content");
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t caps = GetCapabilities();
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: Updating object parameters", this));
|
|
|
|
|
|
|
|
nsresult rv;
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString newMime;
|
2013-10-15 03:05:18 +04:00
|
|
|
nsAutoString typeAttr;
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCOMPtr<nsIURI> newURI;
|
|
|
|
nsCOMPtr<nsIURI> newBaseURI;
|
|
|
|
ObjectType newType;
|
|
|
|
// Set if this state can't be used to load anything, forces eType_Null
|
|
|
|
bool stateInvalid = false;
|
|
|
|
// Indicates what parameters changed.
|
|
|
|
// eParamChannelChanged - means parameters that affect channel opening
|
|
|
|
// decisions changed
|
|
|
|
// eParamStateChanged - means anything that affects what content we load
|
|
|
|
// changed, even if the channel we'd open remains the
|
|
|
|
// same.
|
|
|
|
//
|
|
|
|
// State changes outside of the channel parameters only matter if we've
|
|
|
|
// already opened a channel or tried to instantiate content, whereas channel
|
|
|
|
// parameter changes require re-opening the channel even if we haven't gotten
|
|
|
|
// that far.
|
|
|
|
nsObjectLoadingContent::ParameterUpdateFlags retval = eParamNoChange;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Initial MIME Type
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Codebase
|
|
|
|
///
|
|
|
|
|
|
|
|
nsAutoString codebaseStr;
|
|
|
|
nsCOMPtr<nsIURI> docBaseURI = thisContent->GetBaseURI();
|
2013-03-25 23:26:38 +04:00
|
|
|
bool hasCodebase = thisContent->HasAttr(kNameSpaceID_None, nsGkAtoms::codebase);
|
2017-07-28 05:21:18 +03:00
|
|
|
if (hasCodebase) {
|
2013-03-25 23:26:38 +04:00
|
|
|
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::codebase, codebaseStr);
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!codebaseStr.IsEmpty()) {
|
|
|
|
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(newBaseURI),
|
|
|
|
codebaseStr,
|
|
|
|
thisContent->OwnerDoc(),
|
|
|
|
docBaseURI);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
NS_TryToSetImmutable(newBaseURI);
|
|
|
|
} else {
|
|
|
|
// Malformed URI
|
|
|
|
LOG(("OBJLC [%p]: Could not parse plugin's codebase as a URI, "
|
|
|
|
"will use document baseURI instead", this));
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2017-07-28 05:21:18 +03:00
|
|
|
nsAutoString rawTypeAttr;
|
|
|
|
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, rawTypeAttr);
|
|
|
|
if (!rawTypeAttr.IsEmpty()) {
|
|
|
|
typeAttr = rawTypeAttr;
|
|
|
|
CopyUTF16toUTF8(rawTypeAttr, newMime);
|
|
|
|
}
|
|
|
|
|
2013-03-25 23:26:38 +04:00
|
|
|
// If we failed to build a valid URI, use the document's base URI
|
2012-07-06 01:07:46 +04:00
|
|
|
if (!newBaseURI) {
|
|
|
|
newBaseURI = docBaseURI;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
///
|
|
|
|
/// URI
|
|
|
|
///
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
nsAutoString uriStr;
|
|
|
|
// Different elements keep this in various locations
|
2017-07-28 05:21:18 +03:00
|
|
|
if (thisContent->NodeInfo()->Equals(nsGkAtoms::object)) {
|
2012-07-06 01:07:46 +04:00
|
|
|
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, uriStr);
|
|
|
|
} else if (thisContent->NodeInfo()->Equals(nsGkAtoms::embed)) {
|
|
|
|
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, uriStr);
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("Unrecognized plugin-loading tag");
|
|
|
|
}
|
|
|
|
|
2016-06-24 13:12:53 +03:00
|
|
|
mRewrittenYoutubeEmbed = false;
|
2012-07-06 01:07:46 +04:00
|
|
|
// Note that the baseURI changing could affect the newURI, even if uriStr did
|
|
|
|
// not change.
|
|
|
|
if (!uriStr.IsEmpty()) {
|
|
|
|
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(newURI),
|
|
|
|
uriStr,
|
|
|
|
thisContent->OwnerDoc(),
|
|
|
|
newBaseURI);
|
2016-02-26 02:49:18 +03:00
|
|
|
nsCOMPtr<nsIURI> rewrittenURI;
|
|
|
|
MaybeRewriteYoutubeEmbed(newURI,
|
|
|
|
newBaseURI,
|
|
|
|
getter_AddRefs(rewrittenURI));
|
|
|
|
if (rewrittenURI) {
|
|
|
|
newURI = rewrittenURI;
|
2016-06-24 13:12:53 +03:00
|
|
|
mRewrittenYoutubeEmbed = true;
|
2016-01-06 11:01:59 +03:00
|
|
|
newMime = NS_LITERAL_CSTRING("text/html");
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
NS_TryToSetImmutable(newURI);
|
2012-07-26 00:39:01 +04:00
|
|
|
} else {
|
2012-07-06 01:07:46 +04:00
|
|
|
stateInvalid = true;
|
2012-07-26 00:39:01 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2012-10-20 00:42:37 +04:00
|
|
|
// For eAllowPluginSkipChannel tags, if we have a non-plugin type, but can get
|
|
|
|
// a plugin type from the extension, prefer that to falling back to a channel.
|
2015-05-20 16:30:05 +03:00
|
|
|
if (!IsPluginType(GetTypeOfContent(newMime, mSkipFakePlugins)) && newURI &&
|
2012-10-20 00:42:37 +04:00
|
|
|
(caps & eAllowPluginSkipChannel) &&
|
|
|
|
IsPluginEnabledByExtension(newURI, newMime)) {
|
|
|
|
LOG(("OBJLC [%p]: Using extension as type hint (%s)", this, newMime.get()));
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
///
|
|
|
|
/// Check if the original (pre-channel) content-type or URI changed, and
|
|
|
|
/// record mOriginal{ContentType,URI}
|
|
|
|
///
|
|
|
|
|
|
|
|
if ((mOriginalContentType != newMime) || !URIEquals(mOriginalURI, newURI)) {
|
|
|
|
// These parameters changing requires re-opening the channel, so don't
|
|
|
|
// consider the currently-open channel below
|
|
|
|
// XXX(johns): Changing the mime type might change our decision on whether
|
|
|
|
// or not we load a channel, so we count changes to it as a
|
|
|
|
// channel parameter change for the sake of simplicity.
|
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamChannelChanged);
|
|
|
|
LOG(("OBJLC [%p]: Channel parameters changed", this));
|
|
|
|
}
|
|
|
|
mOriginalContentType = newMime;
|
|
|
|
mOriginalURI = newURI;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// If we have a channel, see if its MIME type should take precendence and
|
|
|
|
/// check the final (redirected) URL
|
|
|
|
///
|
|
|
|
|
|
|
|
// If we have a loaded channel and channel parameters did not change, use it
|
|
|
|
// to determine what we would load.
|
|
|
|
bool useChannel = mChannelLoaded && !(retval & eParamChannelChanged);
|
2012-12-05 05:10:29 +04:00
|
|
|
// If we have a channel and are type loading, as opposed to having an existing
|
|
|
|
// channel for a previous load.
|
|
|
|
bool newChannel = useChannel && mType == eType_Loading;
|
|
|
|
|
|
|
|
if (newChannel && mChannel) {
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCString channelType;
|
|
|
|
rv = mChannel->GetContentType(channelType);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_NOTREACHED("GetContentType failed");
|
|
|
|
stateInvalid = true;
|
2012-08-07 01:00:17 +04:00
|
|
|
channelType.Truncate();
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: Channel has a content type of %s", this, channelType.get()));
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
bool binaryChannelType = false;
|
|
|
|
if (channelType.EqualsASCII(APPLICATION_GUESS_FROM_EXT)) {
|
|
|
|
channelType = APPLICATION_OCTET_STREAM;
|
|
|
|
mChannel->SetContentType(channelType);
|
|
|
|
binaryChannelType = true;
|
|
|
|
} else if (channelType.EqualsASCII(APPLICATION_OCTET_STREAM)
|
|
|
|
|| channelType.EqualsASCII(BINARY_OCTET_STREAM)) {
|
|
|
|
binaryChannelType = true;
|
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// Channel can change our URI through redirection
|
|
|
|
rv = NS_GetFinalChannelURI(mChannel, getter_AddRefs(newURI));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_NOTREACHED("NS_GetFinalChannelURI failure");
|
|
|
|
stateInvalid = true;
|
2012-07-26 00:39:01 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
ObjectType typeHint = newMime.IsEmpty() ? eType_Null
|
|
|
|
: GetTypeOfContent(newMime, mSkipFakePlugins);
|
2012-12-07 03:09:10 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
//
|
2012-12-07 03:09:10 +04:00
|
|
|
// In order of preference:
|
|
|
|
//
|
2013-10-15 03:05:18 +04:00
|
|
|
// 1) Perform typemustmatch check.
|
|
|
|
// If check is sucessful use type without further checks.
|
|
|
|
// If check is unsuccessful set stateInvalid to true
|
|
|
|
// 2) Use our type hint if it matches a plugin
|
|
|
|
// 3) If we have eAllowPluginSkipChannel, use the uri file extension if
|
2012-12-07 03:09:10 +04:00
|
|
|
// it matches a plugin
|
2013-10-15 03:05:18 +04:00
|
|
|
// 4) If the channel returns a binary stream type:
|
|
|
|
// 4a) If we have a type non-null non-document type hint, use that
|
|
|
|
// 4b) If the uri file extension matches a plugin type, use that
|
|
|
|
// 5) Use the channel type
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2012-12-07 03:09:10 +04:00
|
|
|
bool overrideChannelType = false;
|
2013-10-15 03:05:18 +04:00
|
|
|
if (thisContent->HasAttr(kNameSpaceID_None, nsGkAtoms::typemustmatch)) {
|
|
|
|
if (!typeAttr.LowerCaseEqualsASCII(channelType.get())) {
|
|
|
|
stateInvalid = true;
|
|
|
|
}
|
2015-05-20 16:30:05 +03:00
|
|
|
} else if (IsPluginType(typeHint)) {
|
2012-12-07 03:09:10 +04:00
|
|
|
LOG(("OBJLC [%p]: Using plugin type hint in favor of any channel type",
|
|
|
|
this));
|
|
|
|
overrideChannelType = true;
|
|
|
|
} else if ((caps & eAllowPluginSkipChannel) &&
|
|
|
|
IsPluginEnabledByExtension(newURI, newMime)) {
|
|
|
|
LOG(("OBJLC [%p]: Using extension as type hint for "
|
|
|
|
"eAllowPluginSkipChannel tag (%s)", this, newMime.get()));
|
|
|
|
overrideChannelType = true;
|
|
|
|
} else if (binaryChannelType &&
|
|
|
|
typeHint != eType_Null && typeHint != eType_Document) {
|
|
|
|
LOG(("OBJLC [%p]: Using type hint in favor of binary channel type",
|
|
|
|
this));
|
|
|
|
overrideChannelType = true;
|
|
|
|
} else if (binaryChannelType &&
|
|
|
|
IsPluginEnabledByExtension(newURI, newMime)) {
|
|
|
|
LOG(("OBJLC [%p]: Using extension as type hint for binary channel (%s)",
|
|
|
|
this, newMime.get()));
|
|
|
|
overrideChannelType = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (overrideChannelType) {
|
|
|
|
// 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
|
|
|
|
nsAutoCString parsedMime, dummy;
|
2015-10-01 19:51:50 +03:00
|
|
|
NS_ParseResponseContentType(newMime, parsedMime, dummy);
|
2012-12-07 03:09:10 +04:00
|
|
|
if (!parsedMime.IsEmpty()) {
|
|
|
|
mChannel->SetContentType(parsedMime);
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
} else {
|
|
|
|
newMime = channelType;
|
|
|
|
}
|
2012-12-05 05:10:29 +04:00
|
|
|
} else if (newChannel) {
|
|
|
|
LOG(("OBJLC [%p]: We failed to open a channel, marking invalid", this));
|
2012-07-06 01:07:46 +04:00
|
|
|
stateInvalid = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Determine final type
|
|
|
|
///
|
2012-12-07 03:09:10 +04:00
|
|
|
// In order of preference:
|
2012-07-06 01:07:46 +04:00
|
|
|
// 1) If we have attempted channel load, or set stateInvalid above, the type
|
|
|
|
// is always null (fallback)
|
2012-12-07 03:09:10 +04:00
|
|
|
// 2) If we have a loaded channel, we grabbed its mimeType above, use that
|
|
|
|
// type.
|
|
|
|
// 3) If we have a plugin type and no URI, use that type.
|
|
|
|
// 4) If we have a plugin type and eAllowPluginSkipChannel, use that type.
|
|
|
|
// 5) if we have a URI, set type to loading to indicate we'd need a channel
|
|
|
|
// to proceed.
|
|
|
|
// 6) Otherwise, type null to indicate unloadable content (fallback)
|
2012-07-06 01:07:46 +04:00
|
|
|
//
|
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
ObjectType newMime_Type = GetTypeOfContent(newMime, mSkipFakePlugins);
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
if (stateInvalid) {
|
|
|
|
newType = eType_Null;
|
2012-08-26 01:18:44 +04:00
|
|
|
newMime.Truncate();
|
2012-12-05 05:10:29 +04:00
|
|
|
} else if (newChannel) {
|
2016-01-06 11:01:59 +03:00
|
|
|
// If newChannel is set above, we considered it in setting newMime
|
2015-05-20 16:30:05 +03:00
|
|
|
newType = newMime_Type;
|
2016-01-06 11:01:59 +03:00
|
|
|
LOG(("OBJLC [%p]: Using channel type", this));
|
2012-08-07 22:42:56 +04:00
|
|
|
} else if (((caps & eAllowPluginSkipChannel) || !newURI) &&
|
2015-05-20 16:30:05 +03:00
|
|
|
IsPluginType(newMime_Type)) {
|
|
|
|
newType = newMime_Type;
|
2012-12-07 03:09:10 +04:00
|
|
|
LOG(("OBJLC [%p]: Plugin type with no URI, skipping channel load", this));
|
2012-07-06 01:07:46 +04:00
|
|
|
} else if (newURI) {
|
|
|
|
// We could potentially load this if we opened a channel on mURI, indicate
|
|
|
|
// This by leaving type as loading
|
|
|
|
newType = eType_Loading;
|
|
|
|
} else {
|
|
|
|
// Unloadable - no URI, and no plugin type. Non-plugin types (images,
|
|
|
|
// documents) always load with a channel.
|
|
|
|
newType = eType_Null;
|
|
|
|
}
|
|
|
|
|
2012-12-05 05:10:29 +04:00
|
|
|
///
|
|
|
|
/// Handle existing channels
|
|
|
|
///
|
|
|
|
|
|
|
|
if (useChannel && newType == eType_Loading) {
|
|
|
|
// We decided to use a channel, and also that the previous channel is still
|
|
|
|
// usable, so re-use the existing values.
|
|
|
|
newType = mType;
|
|
|
|
newMime = mContentType;
|
|
|
|
newURI = mURI;
|
|
|
|
} else if (useChannel && !newChannel) {
|
|
|
|
// We have an existing channel, but did not decide to use one.
|
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamChannelChanged);
|
|
|
|
useChannel = false;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
///
|
|
|
|
/// Update changed values
|
|
|
|
///
|
|
|
|
|
|
|
|
if (newType != mType) {
|
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamStateChanged);
|
|
|
|
LOG(("OBJLC [%p]: Type changed from %u -> %u", this, mType, newType));
|
2017-08-03 22:07:14 +03:00
|
|
|
bool updateIMEState = (mType == eType_Loading && newType == eType_Plugin);
|
2012-07-06 01:07:46 +04:00
|
|
|
mType = newType;
|
2017-08-03 22:07:14 +03:00
|
|
|
// The IME manager needs to know if this is a plugin so it can adjust
|
|
|
|
// input handling to an appropriate mode for plugins.
|
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
MOZ_ASSERT(thisContent, "should have content");
|
|
|
|
if (updateIMEState && thisContent && fm && fm->IsFocused(thisContent)) {
|
|
|
|
widget::IMEState state;
|
|
|
|
state.mEnabled = widget::IMEState::PLUGIN;
|
|
|
|
state.mOpen = widget::IMEState::DONT_CHANGE_OPEN_STATE;
|
|
|
|
IMEStateManager::UpdateIMEState(state, thisContent, nullptr);
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!URIEquals(mBaseURI, newBaseURI)) {
|
|
|
|
LOG(("OBJLC [%p]: Object effective baseURI changed", this));
|
|
|
|
mBaseURI = newBaseURI;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!URIEquals(newURI, mURI)) {
|
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamStateChanged);
|
|
|
|
LOG(("OBJLC [%p]: Object effective URI changed", this));
|
|
|
|
mURI = newURI;
|
|
|
|
}
|
|
|
|
|
2012-10-04 23:57:24 +04:00
|
|
|
// We don't update content type when loading, as the type is not final and we
|
|
|
|
// don't want to superfluously change between mOriginalContentType ->
|
|
|
|
// mContentType when doing |obj.data = obj.data| with a channel and differing
|
|
|
|
// type.
|
|
|
|
if (mType != eType_Loading && mContentType != newMime) {
|
2012-07-06 01:07:46 +04:00
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamStateChanged);
|
2012-10-04 23:57:24 +04:00
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamContentTypeChanged);
|
|
|
|
LOG(("OBJLC [%p]: Object effective mime type changed (%s -> %s)",
|
|
|
|
this, mContentType.get(), newMime.get()));
|
2012-07-06 01:07:46 +04:00
|
|
|
mContentType = newMime;
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2012-12-05 05:10:29 +04:00
|
|
|
// If we decided to keep using info from an old channel, but also that state
|
|
|
|
// changed, we need to invalidate it.
|
|
|
|
if (useChannel && !newChannel && (retval & eParamStateChanged)) {
|
|
|
|
mType = eType_Loading;
|
|
|
|
retval = (ParameterUpdateFlags)(retval | eParamChannelChanged);
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-12-11 04:35:05 +04:00
|
|
|
// Used by PluginDocument to kick off our initial load from the already-opened
|
|
|
|
// channel.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::InitializeFromChannel(nsIRequest *aChannel)
|
|
|
|
{
|
|
|
|
LOG(("OBJLC [%p] InitializeFromChannel: %p", this, aChannel));
|
|
|
|
if (mType != eType_Loading || mChannel) {
|
|
|
|
// We could technically call UnloadObject() here, if consumers have a valid
|
|
|
|
// reason for wanting to call this on an already-loaded tag.
|
|
|
|
NS_NOTREACHED("Should not have begun loading at this point");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because we didn't open this channel from an initial LoadObject, we'll
|
|
|
|
// update our parameters now, so the OnStartRequest->LoadObject doesn't
|
|
|
|
// believe our src/type suddenly changed.
|
|
|
|
UpdateObjectParameters();
|
|
|
|
// But we always want to load from a channel, in this case.
|
|
|
|
mType = eType_Loading;
|
|
|
|
mChannel = do_QueryInterface(aChannel);
|
|
|
|
NS_ASSERTION(mChannel, "passed a request that is not a channel");
|
|
|
|
|
|
|
|
// OnStartRequest will now see we have a channel in the loading state, and
|
|
|
|
// call into LoadObject. There's a possibility LoadObject will decide not to
|
|
|
|
// load anything from a channel - it will call CloseChannel() in that case.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// Only OnStartRequest should be passing the channel parameter
|
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::LoadObject(bool aNotify,
|
|
|
|
bool aForceLoad)
|
|
|
|
{
|
|
|
|
return LoadObject(aNotify, aForceLoad, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::LoadObject(bool aNotify,
|
|
|
|
bool aForceLoad,
|
|
|
|
nsIRequest *aLoadingChannel)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
nsIDocument* doc = thisContent->OwnerDoc();
|
2012-07-06 00:47:39 +04:00
|
|
|
nsresult rv = NS_OK;
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2017-01-04 01:08:58 +03:00
|
|
|
// Per bug 1318303, if the parent document is not active, load the alternative
|
|
|
|
// and return.
|
|
|
|
if (!doc->IsCurrentActiveDocument()) {
|
|
|
|
// Since this can be triggered on change of attributes, make sure we've
|
|
|
|
// unloaded whatever is loaded first.
|
|
|
|
UnloadObject();
|
|
|
|
LoadFallback(eFallbackAlternate, false);
|
|
|
|
return NS_OK;
|
2012-07-06 04:56:25 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// XXX(johns): In these cases, we refuse to touch our content and just
|
|
|
|
// remain unloaded, as per legacy behavior. It would make more sense to
|
|
|
|
// load fallback content initially and refuse to ever change state again.
|
|
|
|
if (doc->IsBeingUsedAsImage() || doc->IsLoadedAsData()) {
|
2012-07-26 00:39:01 +04:00
|
|
|
return NS_OK;
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: LoadObject called, notify %u, forceload %u, channel %p",
|
|
|
|
this, aNotify, aForceLoad, aLoadingChannel));
|
|
|
|
|
|
|
|
// We can't re-use an already open channel, but aForceLoad may make us try
|
|
|
|
// to load a plugin without any changes in channel state.
|
|
|
|
if (aForceLoad && mChannelLoaded) {
|
|
|
|
CloseChannel();
|
|
|
|
mChannelLoaded = false;
|
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
// Save these for NotifyStateChanged();
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates oldState = ObjectState();
|
2012-07-06 00:47:39 +04:00
|
|
|
ObjectType oldType = mType;
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
ParameterUpdateFlags stateChange = UpdateObjectParameters();
|
|
|
|
|
2012-08-15 23:16:17 +04:00
|
|
|
if (!stateChange && !aForceLoad) {
|
2012-07-06 01:07:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
/// State has changed, unload existing content and attempt to load new type
|
|
|
|
///
|
|
|
|
LOG(("OBJLC [%p]: LoadObject - plugin state changed (%u)",
|
|
|
|
this, stateChange));
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
// Setup fallback info. We may also change type to fallback below in case of
|
|
|
|
// sanity/OOM/etc. errors. We default to showing alternate content
|
|
|
|
// NOTE LoadFallback can override this in some cases
|
|
|
|
FallbackType fallbackType = eFallbackAlternate;
|
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
// If GetTypeOfContent(mContentType) is null we truly have no handler for the
|
|
|
|
// type -- otherwise, we have a handler but UpdateObjectParameters rejected
|
|
|
|
// the configuration for another reason (e.g. an embed tag with type
|
|
|
|
// "image/png" but no URI). Don't show a plugin error or unknown type error in
|
|
|
|
// the latter case.
|
|
|
|
if (mType == eType_Null &&
|
|
|
|
GetTypeOfContent(mContentType, mSkipFakePlugins) == eType_Null) {
|
2013-06-11 18:58:43 +04:00
|
|
|
fallbackType = eFallbackUnsupported;
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2012-10-04 23:57:24 +04:00
|
|
|
// Explicit user activation should reset if the object changes content types
|
|
|
|
if (mActivated && (stateChange & eParamContentTypeChanged)) {
|
|
|
|
LOG(("OBJLC [%p]: Content type changed, clearing activation state", this));
|
|
|
|
mActivated = false;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// We synchronously start/stop plugin instances below, which may spin the
|
|
|
|
// event loop. Re-entering into the load is fine, but at that point the
|
|
|
|
// original load call needs to abort when unwinding
|
2015-05-20 16:30:05 +03:00
|
|
|
// NOTE this is located *after* the state change check, a subsequent load
|
2012-07-06 01:07:46 +04:00
|
|
|
// with no subsequently changed state will be a no-op.
|
2012-08-20 23:46:48 +04:00
|
|
|
if (mIsLoading) {
|
|
|
|
LOG(("OBJLC [%p]: Re-entering into LoadObject", this));
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
mIsLoading = true;
|
|
|
|
AutoSetLoadingToFalse reentryCheck(this);
|
|
|
|
|
|
|
|
// Unload existing content, keeping in mind stopping plugins might spin the
|
2012-07-06 00:47:39 +04:00
|
|
|
// event loop. Note that we check for still-open channels below
|
|
|
|
UnloadObject(false); // Don't reset state
|
2012-07-06 01:07:46 +04:00
|
|
|
if (!mIsLoading) {
|
|
|
|
// The event loop must've spun and re-entered into LoadObject, which
|
|
|
|
// finished the load
|
2012-08-20 23:46:48 +04:00
|
|
|
LOG(("OBJLC [%p]: Re-entered into LoadObject, aborting outer load", this));
|
2012-07-06 01:07:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-07 03:09:10 +04:00
|
|
|
// Determine what's going on with our channel.
|
2012-07-06 01:07:46 +04:00
|
|
|
if (stateChange & eParamChannelChanged) {
|
|
|
|
// If the channel params changed, throw away the channel, but unset
|
|
|
|
// mChannelLoaded so we'll still try to open a new one for this load if
|
|
|
|
// necessary
|
|
|
|
CloseChannel();
|
|
|
|
mChannelLoaded = false;
|
|
|
|
} else if (mType == eType_Null && mChannel) {
|
|
|
|
// If we opened a channel but then failed to find a loadable state, throw it
|
|
|
|
// away. mChannelLoaded will indicate that we tried to load a channel at one
|
|
|
|
// point so we wont recurse
|
|
|
|
CloseChannel();
|
2012-08-15 23:16:17 +04:00
|
|
|
} else if (mType == eType_Loading && mChannel) {
|
|
|
|
// We're still waiting on a channel load, already opened one, and
|
|
|
|
// channel parameters didn't change
|
|
|
|
return NS_OK;
|
2012-07-06 01:07:46 +04:00
|
|
|
} else if (mChannelLoaded && mChannel != aLoadingChannel) {
|
|
|
|
// The only time we should have a loaded channel with a changed state is
|
|
|
|
// when the channel has just opened -- in which case this call should
|
|
|
|
// have originated from OnStartRequest
|
|
|
|
NS_NOTREACHED("Loading with a channel, but state doesn't make sense");
|
|
|
|
return NS_OK;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
//
|
|
|
|
// Security checks
|
|
|
|
//
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
if (mType != eType_Null) {
|
2012-12-07 03:10:54 +04:00
|
|
|
bool allowLoad = true;
|
2013-03-25 23:26:38 +04:00
|
|
|
int16_t contentPolicy = nsIContentPolicy::ACCEPT;
|
2012-12-07 03:10:54 +04:00
|
|
|
// If mChannelLoaded is set we presumably already passed load policy
|
2016-06-28 10:37:55 +03:00
|
|
|
// If mType == eType_Loading then we call OpenChannel() which internally
|
|
|
|
// creates a new channel and calls asyncOpen2() on that channel which
|
|
|
|
// then enforces content policy checks.
|
|
|
|
if (allowLoad && mURI && !mChannelLoaded && mType != eType_Loading) {
|
2012-12-07 03:10:54 +04:00
|
|
|
allowLoad = CheckLoadPolicy(&contentPolicy);
|
|
|
|
}
|
|
|
|
// If we're loading a type now, check ProcessPolicy. Note that we may check
|
|
|
|
// both now in the case of plugins whose type is determined before opening a
|
|
|
|
// channel.
|
|
|
|
if (allowLoad && mType != eType_Loading) {
|
2012-08-17 05:44:14 +04:00
|
|
|
allowLoad = CheckProcessPolicy(&contentPolicy);
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
2012-08-20 23:46:48 +04:00
|
|
|
|
|
|
|
// Content policy implementations can mutate the DOM, check for re-entry
|
|
|
|
if (!mIsLoading) {
|
|
|
|
LOG(("OBJLC [%p]: We re-entered in content policy, leaving original load",
|
|
|
|
this));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-12-07 03:09:10 +04:00
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
// Load denied, switch to fallback and set disabled/suppressed if applicable
|
|
|
|
if (!allowLoad) {
|
2012-08-17 05:44:14 +04:00
|
|
|
LOG(("OBJLC [%p]: Load denied by policy", this));
|
2012-07-06 00:47:39 +04:00
|
|
|
mType = eType_Null;
|
|
|
|
if (contentPolicy == nsIContentPolicy::REJECT_TYPE) {
|
2012-08-17 05:44:14 +04:00
|
|
|
// XXX(johns) This is assuming that we were rejected by
|
|
|
|
// nsContentBlocker, which rejects by type if permissions
|
|
|
|
// reject plugins
|
2012-07-06 00:47:39 +04:00
|
|
|
fallbackType = eFallbackUserDisabled;
|
|
|
|
} else {
|
|
|
|
fallbackType = eFallbackSuppressed;
|
|
|
|
}
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
2014-04-25 14:19:21 +04:00
|
|
|
// Don't allow view-source scheme.
|
|
|
|
// view-source is the only scheme to which this applies at the moment due to
|
|
|
|
// potential timing attacks to read data from cross-origin documents. If this
|
|
|
|
// widens we should add a protocol flag for whether the scheme is only allowed
|
|
|
|
// in top and use something like nsNetUtil::NS_URIChainHasFlags.
|
|
|
|
if (mType != eType_Null) {
|
|
|
|
nsCOMPtr<nsIURI> tempURI = mURI;
|
|
|
|
nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(tempURI);
|
|
|
|
while (nestedURI) {
|
|
|
|
// view-source should always be an nsINestedURI, loop and check the
|
|
|
|
// scheme on this and all inner URIs that are also nested URIs.
|
|
|
|
bool isViewSource = false;
|
|
|
|
rv = tempURI->SchemeIs("view-source", &isViewSource);
|
|
|
|
if (NS_FAILED(rv) || isViewSource) {
|
|
|
|
LOG(("OBJLC [%p]: Blocking as effective URI has view-source scheme",
|
|
|
|
this));
|
|
|
|
mType = eType_Null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nestedURI->GetInnerURI(getter_AddRefs(tempURI));
|
|
|
|
nestedURI = do_QueryInterface(tempURI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-17 13:05:42 +03:00
|
|
|
// Items resolved as Image/Document are no candidates for content blocking,
|
|
|
|
// as well as invalid plugins (they will not have the mContentType set).
|
2015-05-20 16:30:05 +03:00
|
|
|
if ((mType == eType_Null || IsPluginType(mType)) && ShouldBlockContent()) {
|
2016-06-17 13:05:42 +03:00
|
|
|
LOG(("OBJLC [%p]: Enable content blocking", this));
|
|
|
|
mType = eType_Loading;
|
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
// If we're a plugin but shouldn't start yet, load fallback with
|
2013-02-15 01:38:41 +04:00
|
|
|
// reason click-to-play instead. Items resolved as Image/Document
|
|
|
|
// will not be checked for previews, as well as invalid plugins
|
|
|
|
// (they will not have the mContentType set).
|
2012-07-06 00:47:39 +04:00
|
|
|
FallbackType clickToPlayReason;
|
2015-05-20 16:30:05 +03:00
|
|
|
if (!mActivated && IsPluginType(mType) && !ShouldPlay(clickToPlayReason)) {
|
2012-07-06 00:47:39 +04:00
|
|
|
LOG(("OBJLC [%p]: Marking plugin as click-to-play", this));
|
2012-07-06 01:07:46 +04:00
|
|
|
mType = eType_Null;
|
2012-07-06 00:47:39 +04:00
|
|
|
fallbackType = clickToPlayReason;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
if (!mActivated && IsPluginType(mType)) {
|
2013-02-15 01:38:41 +04:00
|
|
|
// Object passed ShouldPlay, so it should be considered
|
2012-10-04 23:57:24 +04:00
|
|
|
// activated until it changes content type
|
|
|
|
LOG(("OBJLC [%p]: Object implicitly activated", this));
|
|
|
|
mActivated = true;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// Sanity check: We shouldn't have any loaded resources, pending events, or
|
|
|
|
// a final listener at this point
|
|
|
|
if (mFrameLoader || mPendingInstantiateEvent || mInstanceOwner ||
|
2012-09-07 04:16:02 +04:00
|
|
|
mPendingCheckPluginStopEvent || mFinalListener)
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
|
|
|
NS_NOTREACHED("Trying to load new plugin with existing content");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
2012-07-26 00:39:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// More sanity-checking:
|
|
|
|
// If mChannel is set, mChannelLoaded should be set, and vice-versa
|
|
|
|
if (mType != eType_Null && !!mChannel != mChannelLoaded) {
|
|
|
|
NS_NOTREACHED("Trying to load with bad channel state");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Attempt to load new type
|
|
|
|
///
|
2012-10-05 00:50:49 +04:00
|
|
|
|
2014-08-16 01:17:35 +04:00
|
|
|
|
|
|
|
// Cache the current attributes and parameters.
|
|
|
|
if (mType == eType_Plugin || mType == eType_Null) {
|
2016-09-08 07:17:58 +03:00
|
|
|
rv = BuildParametersArray();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2014-08-16 01:17:35 +04:00
|
|
|
}
|
|
|
|
|
2012-10-05 00:50:49 +04:00
|
|
|
// We don't set mFinalListener until OnStartRequest has been called, to
|
|
|
|
// prevent re-entry ugliness with CloseChannel()
|
|
|
|
nsCOMPtr<nsIStreamListener> finalListener;
|
2012-12-07 03:10:54 +04:00
|
|
|
// If we decide to synchronously spawn a plugin, we do it after firing
|
|
|
|
// notifications to avoid re-entry causing notifications to fire out of order.
|
|
|
|
bool doSpawnPlugin = false;
|
2012-07-06 01:07:46 +04:00
|
|
|
switch (mType) {
|
|
|
|
case eType_Image:
|
|
|
|
if (!mChannel) {
|
|
|
|
// We have a LoadImage() call, but UpdateObjectParameters requires a
|
|
|
|
// channel for images, so this is not a valid state.
|
|
|
|
NS_NOTREACHED("Attempting to load image without a channel?");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
2012-07-06 00:47:39 +04:00
|
|
|
break;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-10-05 00:50:49 +04:00
|
|
|
rv = LoadImageWithChannel(mChannel, getter_AddRefs(finalListener));
|
|
|
|
// finalListener will receive OnStartRequest below
|
2012-07-06 01:07:46 +04:00
|
|
|
break;
|
|
|
|
case eType_Plugin:
|
|
|
|
{
|
|
|
|
if (mChannel) {
|
2012-07-06 00:47:39 +04:00
|
|
|
// Force a sync state change now, we need the frame created
|
|
|
|
NotifyStateChanged(oldType, oldState, true, aNotify);
|
|
|
|
oldType = mType;
|
|
|
|
oldState = ObjectState();
|
|
|
|
|
2012-08-31 21:52:50 +04:00
|
|
|
if (!thisContent->GetPrimaryFrame()) {
|
|
|
|
// We're un-rendered, and can't instantiate a plugin. HasNewFrame will
|
|
|
|
// re-start us when we can proceed.
|
|
|
|
LOG(("OBJLC [%p]: Aborting load - plugin-type, but no frame", this));
|
|
|
|
CloseChannel();
|
|
|
|
break;
|
|
|
|
}
|
2012-12-07 03:09:10 +04:00
|
|
|
|
2012-12-07 03:10:54 +04:00
|
|
|
// We'll handle this below
|
|
|
|
doSpawnPlugin = true;
|
2012-07-06 01:07:46 +04:00
|
|
|
} else {
|
|
|
|
rv = AsyncStartPluginInstance();
|
|
|
|
}
|
2012-07-26 00:39:01 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
break;
|
2015-05-20 16:30:05 +03:00
|
|
|
case eType_FakePlugin:
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
2015-05-20 16:30:05 +03:00
|
|
|
if (mChannel) {
|
|
|
|
/// XXX(johns): Ideally we'd have some way to pass the channel to the
|
|
|
|
/// fake plugin handler, but for now handlers will need to
|
|
|
|
/// request element.srcURI themselves if they want it
|
|
|
|
LOG(("OBJLC [%p]: Closing unused channel for fake plugin type", this));
|
|
|
|
CloseChannel();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// XXX(johns) Bug FIXME - We need to cleanup the various plugintag
|
|
|
|
/// classes to be more sane and avoid this dance
|
|
|
|
nsCOMPtr<nsIPluginTag> basetag =
|
|
|
|
nsContentUtils::PluginTagForType(mContentType, false);
|
|
|
|
nsCOMPtr<nsIFakePluginTag> tag = do_QueryInterface(basetag);
|
2017-05-29 13:38:46 +03:00
|
|
|
|
|
|
|
uint32_t id;
|
|
|
|
if (NS_FAILED(tag->GetId(&id))) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(id <= PR_INT32_MAX,
|
|
|
|
"Something went wrong, nsPluginHost::RegisterFakePlugin shouldn't have "
|
|
|
|
"given out this id.");
|
|
|
|
|
|
|
|
SetupFrameLoader(int32_t(id));
|
|
|
|
if (!mFrameLoader) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-09-27 13:28:36 +03:00
|
|
|
|
|
|
|
nsString sandboxScript;
|
|
|
|
tag->GetSandboxScript(sandboxScript);
|
|
|
|
if (!sandboxScript.IsEmpty()) {
|
|
|
|
// Create a sandbox.
|
|
|
|
AutoJSAPI jsapi;
|
|
|
|
jsapi.Init();
|
|
|
|
JS::Rooted<JSObject*> sandbox(jsapi.cx());
|
|
|
|
rv = nsContentUtils::XPConnect()->
|
|
|
|
CreateSandbox(jsapi.cx(), nsContentUtils::GetSystemPrincipal(),
|
|
|
|
sandbox.address());
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoEntryScript aes(sandbox, "JS plugin sandbox code");
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> element(aes.cx());
|
|
|
|
if (!ToJSValue(aes.cx(), thisContent, &element)) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!JS_DefineProperty(aes.cx(), sandbox, "pluginElement", element, JSPROP_ENUMERATE)) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Rooted<JS::Value> rval(aes.cx());
|
|
|
|
// If the eval'ed code throws we won't load and do fallback instead.
|
|
|
|
rv = nsContentUtils::XPConnect()->EvalInSandboxObject(sandboxScript, nullptr, aes.cx(), sandbox, &rval);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
nsCOMPtr<nsIURI> handlerURI;
|
|
|
|
if (tag) {
|
|
|
|
tag->GetHandlerURI(getter_AddRefs(handlerURI));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!handlerURI) {
|
|
|
|
NS_NOTREACHED("Selected type is not a proper fake plugin handler");
|
|
|
|
rv = NS_ERROR_FAILURE;
|
2012-07-06 00:47:39 +04:00
|
|
|
break;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
2012-12-07 03:09:10 +04:00
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
nsCString spec;
|
|
|
|
handlerURI->GetSpec(spec);
|
|
|
|
LOG(("OBJLC [%p]: Loading fake plugin handler (%s)", this, spec.get()));
|
|
|
|
|
2017-05-29 13:38:46 +03:00
|
|
|
rv = mFrameLoader->LoadURI(handlerURI);
|
2012-07-06 01:07:46 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2015-05-20 16:30:05 +03:00
|
|
|
LOG(("OBJLC [%p]: LoadURI() failed for fake handler", this));
|
2012-10-06 02:30:13 +04:00
|
|
|
mFrameLoader->Destroy();
|
|
|
|
mFrameLoader = nullptr;
|
2015-05-20 16:30:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eType_Document:
|
|
|
|
{
|
|
|
|
if (!mChannel) {
|
|
|
|
// We could mFrameLoader->LoadURI(mURI), but UpdateObjectParameters
|
|
|
|
// requires documents have a channel, so this is not a valid state.
|
|
|
|
NS_NOTREACHED("Attempting to load a document without a channel");
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-05-29 13:38:46 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = SetupDocShell(mURI);
|
2015-05-20 16:30:05 +03:00
|
|
|
if (!docShell) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
2012-07-06 00:47:39 +04:00
|
|
|
break;
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// We're loading a document, so we have to set LOAD_DOCUMENT_URI
|
|
|
|
// (especially important for firing onload)
|
|
|
|
nsLoadFlags flags = 0;
|
|
|
|
mChannel->GetLoadFlags(&flags);
|
|
|
|
flags |= nsIChannel::LOAD_DOCUMENT_URI;
|
|
|
|
mChannel->SetLoadFlags(flags);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(docShell));
|
|
|
|
NS_ASSERTION(req, "Docshell must be an ifreq");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURILoader>
|
|
|
|
uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
|
2012-07-06 00:47:39 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_NOTREACHED("Failed to get uriLoader service");
|
2015-05-20 16:30:05 +03:00
|
|
|
mFrameLoader->Destroy();
|
|
|
|
mFrameLoader = nullptr;
|
2012-07-06 00:47:39 +04:00
|
|
|
break;
|
|
|
|
}
|
2015-05-20 16:30:05 +03:00
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
rv = uriLoader->OpenChannel(mChannel, nsIURILoader::DONT_RETARGET, req,
|
2012-10-05 00:50:49 +04:00
|
|
|
getter_AddRefs(finalListener));
|
|
|
|
// finalListener will receive OnStartRequest below
|
2012-07-26 00:39:01 +04:00
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
break;
|
|
|
|
case eType_Loading:
|
|
|
|
// If our type remains Loading, we need a channel to proceed
|
2012-08-17 05:44:14 +04:00
|
|
|
rv = OpenChannel();
|
2012-07-06 01:07:46 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("OBJLC [%p]: OpenChannel returned failure (%" PRIu32 ")",
|
|
|
|
this, static_cast<uint32_t>(rv)));
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
break;
|
2012-07-06 00:47:39 +04:00
|
|
|
case eType_Null:
|
|
|
|
// Handled below, silence compiler warnings
|
2012-07-06 01:07:46 +04:00
|
|
|
break;
|
2016-01-22 18:58:49 +03:00
|
|
|
}
|
2012-07-26 00:39:01 +04:00
|
|
|
|
2012-10-05 00:50:49 +04:00
|
|
|
//
|
|
|
|
// Loaded, handle notifications and fallback
|
|
|
|
//
|
2012-07-06 00:47:39 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// If we failed in the loading hunk above, switch to fallback
|
|
|
|
LOG(("OBJLC [%p]: Loading failed, switching to fallback", this));
|
|
|
|
mType = eType_Null;
|
|
|
|
}
|
|
|
|
|
2012-10-05 00:50:49 +04:00
|
|
|
// If we didn't load anything, handle switching to fallback state
|
2012-07-06 00:47:39 +04:00
|
|
|
if (mType == eType_Null) {
|
|
|
|
LOG(("OBJLC [%p]: Loading fallback, type %u", this, fallbackType));
|
|
|
|
NS_ASSERTION(!mFrameLoader && !mInstanceOwner,
|
|
|
|
"switched to type null but also loaded something");
|
|
|
|
|
2016-06-23 07:32:23 +03:00
|
|
|
// Don't fire error events if we're falling back to click-to-play; instead
|
|
|
|
// pretend like this is a really slow-loading plug-in instead.
|
|
|
|
if (fallbackType != eFallbackClickToPlay) {
|
|
|
|
MaybeFireErrorEvent();
|
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
if (mChannel) {
|
|
|
|
// If we were loading with a channel but then failed over, throw it away
|
|
|
|
CloseChannel();
|
|
|
|
}
|
|
|
|
|
2012-12-07 03:10:54 +04:00
|
|
|
// Don't try to initialize plugins or final listener below
|
|
|
|
doSpawnPlugin = false;
|
2012-11-29 00:34:34 +04:00
|
|
|
finalListener = nullptr;
|
|
|
|
|
2012-11-08 01:59:15 +04:00
|
|
|
// Don't notify, as LoadFallback doesn't know of our previous state
|
2012-07-06 00:47:39 +04:00
|
|
|
// (so really this is just setting mFallbackType)
|
|
|
|
LoadFallback(fallbackType, false);
|
|
|
|
}
|
|
|
|
|
2012-11-08 01:59:15 +04:00
|
|
|
// Notify of our final state
|
2012-07-06 00:47:39 +04:00
|
|
|
NotifyStateChanged(oldType, oldState, false, aNotify);
|
2012-12-07 03:10:54 +04:00
|
|
|
NS_ENSURE_TRUE(mIsLoading, NS_OK);
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2012-10-05 00:50:49 +04:00
|
|
|
//
|
2012-12-07 03:10:54 +04:00
|
|
|
// Spawning plugins and dispatching to the final listener may re-enter, so are
|
|
|
|
// delayed until after we fire a notification, to prevent missing
|
|
|
|
// notifications or firing them out of order.
|
2012-12-07 03:09:10 +04:00
|
|
|
//
|
2012-12-07 03:10:54 +04:00
|
|
|
// Note that we ensured that we entered into LoadObject() from
|
|
|
|
// ::OnStartRequest above when loading with a channel.
|
2012-10-05 00:50:49 +04:00
|
|
|
//
|
|
|
|
|
2012-12-07 03:10:54 +04:00
|
|
|
rv = NS_OK;
|
|
|
|
if (doSpawnPlugin) {
|
|
|
|
rv = InstantiatePluginInstance(true);
|
|
|
|
NS_ENSURE_TRUE(mIsLoading, NS_OK);
|
|
|
|
// Create the final listener if we're loading with a channel. We can't do
|
|
|
|
// this in the loading block above as it requires an instance.
|
|
|
|
if (aLoadingChannel && NS_SUCCEEDED(rv)) {
|
|
|
|
if (NS_SUCCEEDED(rv) && MakePluginListener()) {
|
2012-12-16 12:25:04 +04:00
|
|
|
rv = mFinalListener->OnStartRequest(mChannel, nullptr);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Plugins can reject their initial stream, but continue to run.
|
|
|
|
CloseChannel();
|
|
|
|
NS_ENSURE_TRUE(mIsLoading, NS_OK);
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
2012-12-07 03:10:54 +04:00
|
|
|
}
|
|
|
|
}
|
2012-10-05 00:50:49 +04:00
|
|
|
} else if (finalListener) {
|
|
|
|
NS_ASSERTION(mType != eType_Null && mType != eType_Loading,
|
|
|
|
"We should not have a final listener with a non-loaded type");
|
|
|
|
mFinalListener = finalListener;
|
2012-10-18 22:49:45 +04:00
|
|
|
rv = finalListener->OnStartRequest(mChannel, nullptr);
|
2012-12-07 03:10:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(rv) && mIsLoading) {
|
|
|
|
// Since we've already notified of our transition, we can just Unload and
|
|
|
|
// call LoadFallback (which will notify again)
|
|
|
|
mType = eType_Null;
|
|
|
|
UnloadObject(false);
|
|
|
|
NS_ENSURE_TRUE(mIsLoading, NS_OK);
|
|
|
|
CloseChannel();
|
|
|
|
LoadFallback(fallbackType, true);
|
2012-10-05 00:50:49 +04:00
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-05 00:50:49 +04:00
|
|
|
// This call can re-enter when dealing with plugin listeners
|
2012-07-06 01:07:46 +04:00
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::CloseChannel()
|
|
|
|
{
|
|
|
|
if (mChannel) {
|
|
|
|
LOG(("OBJLC [%p]: Closing channel\n", this));
|
2012-10-05 00:50:49 +04:00
|
|
|
// Null the values before potentially-reentering, and ensure they survive
|
|
|
|
// the call
|
|
|
|
nsCOMPtr<nsIChannel> channelGrip(mChannel);
|
|
|
|
nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
|
2012-07-06 01:07:46 +04:00
|
|
|
mChannel = nullptr;
|
2012-10-05 00:50:49 +04:00
|
|
|
mFinalListener = nullptr;
|
|
|
|
channelGrip->Cancel(NS_BINDING_ABORTED);
|
|
|
|
if (listenerGrip) {
|
2013-01-18 02:50:25 +04:00
|
|
|
// mFinalListener is only set by LoadObject after OnStartRequest, or
|
|
|
|
// by OnStartRequest in the case of late-opened plugin streams
|
2012-10-05 00:50:49 +04:00
|
|
|
listenerGrip->OnStopRequest(channelGrip, nullptr, NS_BINDING_ABORTED);
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-17 05:44:14 +04:00
|
|
|
nsObjectLoadingContent::OpenChannel()
|
2012-07-06 01:07:46 +04:00
|
|
|
{
|
2012-12-07 03:10:54 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2012-07-06 01:07:46 +04:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
nsIDocument* doc = thisContent->OwnerDoc();
|
|
|
|
NS_ASSERTION(doc, "No owner document?");
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
mChannel = nullptr;
|
|
|
|
|
|
|
|
// E.g. mms://
|
|
|
|
if (!mURI || !CanHandleURI(mURI)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadGroup> group = doc->GetDocumentLoadGroup();
|
|
|
|
nsCOMPtr<nsIChannel> chan;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ObjectInterfaceRequestorShim> shim =
|
2013-06-19 18:24:37 +04:00
|
|
|
new ObjectInterfaceRequestorShim(this);
|
2014-09-21 20:36:25 +04:00
|
|
|
|
2014-07-18 03:07:58 +04:00
|
|
|
bool isSandBoxed = doc->GetSandboxFlags() & SANDBOXED_ORIGIN;
|
|
|
|
bool inherit = nsContentUtils::ChannelShouldInheritPrincipal(thisContent->NodePrincipal(),
|
|
|
|
mURI,
|
|
|
|
true, // aInheritForAboutBlank
|
|
|
|
false); // aForceInherit
|
2017-07-26 13:51:17 +03:00
|
|
|
nsSecurityFlags securityFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
|
|
|
|
|
|
|
|
bool isData;
|
|
|
|
bool isURIUniqueOrigin = nsIOService::IsDataURIUniqueOpaqueOrigin() &&
|
|
|
|
NS_SUCCEEDED(mURI->SchemeIs("data", &isData)) &&
|
|
|
|
isData;
|
|
|
|
|
|
|
|
if (inherit && !isURIUniqueOrigin) {
|
2014-07-18 03:07:58 +04:00
|
|
|
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
|
|
|
|
}
|
|
|
|
if (isSandBoxed) {
|
|
|
|
securityFlags |= nsILoadInfo::SEC_SANDBOXED;
|
|
|
|
}
|
|
|
|
|
2015-07-18 18:51:00 +03:00
|
|
|
nsContentPolicyType contentPolicyType = GetContentPolicyType();
|
|
|
|
|
2014-09-21 20:36:25 +04:00
|
|
|
rv = NS_NewChannel(getter_AddRefs(chan),
|
|
|
|
mURI,
|
|
|
|
thisContent,
|
2014-07-18 03:07:58 +04:00
|
|
|
securityFlags,
|
2015-07-18 18:51:00 +03:00
|
|
|
contentPolicyType,
|
2014-09-21 20:36:25 +04:00
|
|
|
group, // aLoadGroup
|
|
|
|
shim, // aCallbacks
|
2010-05-22 01:03:02 +04:00
|
|
|
nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
|
2015-10-06 16:37:07 +03:00
|
|
|
nsIChannel::LOAD_CLASSIFY_URI |
|
2017-03-04 02:20:37 +03:00
|
|
|
nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
|
|
|
|
nsIRequest::LOAD_HTML_OBJECT_DATA);
|
2005-09-21 23:14:30 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2016-11-08 09:23:12 +03:00
|
|
|
if (inherit) {
|
|
|
|
nsCOMPtr<nsILoadInfo> loadinfo = chan->GetLoadInfo();
|
2017-02-07 06:49:34 +03:00
|
|
|
NS_ENSURE_STATE(loadinfo);
|
2016-11-08 09:23:12 +03:00
|
|
|
loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal());
|
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
|
|
|
|
// Referrer
|
|
|
|
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
|
|
|
|
if (httpChan) {
|
2016-12-20 06:49:32 +03:00
|
|
|
rv = httpChan->SetReferrerWithPolicy(doc->GetDocumentURI(),
|
|
|
|
doc->GetReferrerPolicy());
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
2013-10-16 05:35:44 +04:00
|
|
|
|
|
|
|
// Set the initiator type
|
|
|
|
nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChan));
|
|
|
|
if (timedChannel) {
|
|
|
|
timedChannel->SetInitiatorType(thisContent->LocalName());
|
|
|
|
}
|
2017-05-05 08:59:42 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(httpChan));
|
|
|
|
if (cos && EventStateManager::IsHandlingUserInput()) {
|
|
|
|
cos->AddClassFlags(nsIClassOfService::UrgentStart);
|
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2007-12-04 00:57:17 +03:00
|
|
|
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(chan);
|
|
|
|
if (scriptChannel) {
|
|
|
|
// Allow execution against our context if the principals match
|
2012-07-06 01:07:46 +04:00
|
|
|
scriptChannel->SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
|
2007-12-04 00:57:17 +03:00
|
|
|
}
|
|
|
|
|
2016-06-28 10:37:55 +03:00
|
|
|
// AsyncOpen2 can fail if a file does not exist.
|
|
|
|
rv = chan->AsyncOpen2(shim);
|
2012-07-06 01:07:46 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
LOG(("OBJLC [%p]: Channel opened", this));
|
|
|
|
mChannel = chan;
|
2005-09-21 23:14:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2005-09-21 23:14:30 +04:00
|
|
|
nsObjectLoadingContent::GetCapabilities() const
|
|
|
|
{
|
|
|
|
return eSupportImages |
|
|
|
|
eSupportPlugins |
|
2016-01-15 01:09:08 +03:00
|
|
|
eSupportDocuments;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2012-07-26 00:39:01 +04:00
|
|
|
void
|
2012-07-06 01:07:46 +04:00
|
|
|
nsObjectLoadingContent::DestroyContent()
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrameLoader = nullptr;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
2012-02-01 01:55:54 +04:00
|
|
|
|
2014-07-21 22:30:20 +04:00
|
|
|
if (mInstanceOwner || mInstantiating) {
|
|
|
|
QueueCheckPluginStopEvent();
|
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2011-08-28 18:07:24 +04:00
|
|
|
/* static */
|
2007-03-08 14:17:16 +03:00
|
|
|
void
|
2011-08-28 18:07:24 +04:00
|
|
|
nsObjectLoadingContent::Traverse(nsObjectLoadingContent *tmp,
|
|
|
|
nsCycleCollectionTraversalCallback &cb)
|
2007-03-08 14:17:16 +03:00
|
|
|
{
|
2011-08-28 18:07:24 +04:00
|
|
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mFrameLoader");
|
|
|
|
cb.NoteXPCOMChild(static_cast<nsIFrameLoader*>(tmp->mFrameLoader));
|
2007-03-08 14:17:16 +03:00
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
void
|
2012-07-06 00:47:39 +04:00
|
|
|
nsObjectLoadingContent::UnloadObject(bool aResetState)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2012-07-06 00:47:39 +04:00
|
|
|
// Don't notify in CancelImageRequests until we transition to a new loaded
|
|
|
|
// state
|
2011-10-17 18:59:28 +04:00
|
|
|
CancelImageRequests(false);
|
2005-09-21 23:14:30 +04:00
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrameLoader = nullptr;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
|
|
|
|
if (aResetState) {
|
2012-10-05 00:50:49 +04:00
|
|
|
if (mType != eType_Plugin) {
|
|
|
|
// This can re-enter when dealing with plugins, and StopPluginInstance
|
|
|
|
// will handle it
|
|
|
|
CloseChannel();
|
|
|
|
}
|
2012-08-14 22:12:30 +04:00
|
|
|
mChannelLoaded = false;
|
2012-07-06 00:47:39 +04:00
|
|
|
mType = eType_Loading;
|
2012-08-14 22:12:30 +04:00
|
|
|
mURI = mOriginalURI = mBaseURI = nullptr;
|
|
|
|
mContentType.Truncate();
|
|
|
|
mOriginalContentType.Truncate();
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2013-04-18 04:11:58 +04:00
|
|
|
// InstantiatePluginInstance checks this after re-entrant calls and aborts if
|
|
|
|
// it was cleared from under it
|
|
|
|
mInstantiating = false;
|
|
|
|
|
2012-12-08 02:50:10 +04:00
|
|
|
mScriptRequested = false;
|
|
|
|
|
2014-07-01 20:11:01 +04:00
|
|
|
if (mIsStopping) {
|
2013-09-06 00:54:58 +04:00
|
|
|
// The protochain is normally thrown out after a plugin stops, but if we
|
|
|
|
// re-enter while stopping a plugin and try to load something new, we need
|
|
|
|
// to throw away the old protochain in the nested unload.
|
|
|
|
TeardownProtoChain();
|
|
|
|
mIsStopping = false;
|
|
|
|
}
|
|
|
|
|
2014-08-16 01:17:35 +04:00
|
|
|
mCachedAttributes.Clear();
|
|
|
|
mCachedParameters.Clear();
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
// This call should be last as it may re-enter
|
|
|
|
StopPluginInstance();
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates aOldState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aSync,
|
|
|
|
bool aNotify)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("OBJLC [%p]: Notifying about state change: (%u, %" PRIx64 ") -> (%u, %" PRIx64 ")"
|
2012-07-06 00:47:39 +04:00
|
|
|
" (sync %i, notify %i)", this, aOldType, aOldState.GetInternalValue(),
|
|
|
|
mType, ObjectState().GetInternalValue(), aSync, aNotify));
|
2005-10-31 21:28:56 +03:00
|
|
|
|
2015-02-25 19:36:39 +03:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2007-07-08 11:08:04 +04:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2005-09-21 23:14:30 +04:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
NS_ASSERTION(thisContent->IsElement(), "Not an element?");
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
// XXX(johns): A good bit of the code below replicates UpdateState(true)
|
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
// Unfortunately, we do some state changes without notifying
|
|
|
|
// (e.g. in Fallback when canceling image requests), so we have to
|
|
|
|
// manually notify object state changes.
|
|
|
|
thisContent->AsElement()->UpdateState(false);
|
|
|
|
|
|
|
|
if (!aNotify) {
|
|
|
|
// We're done here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-02 22:45:44 +04:00
|
|
|
nsIDocument* doc = thisContent->GetComposedDoc();
|
2005-09-21 23:14:30 +04:00
|
|
|
if (!doc) {
|
|
|
|
return; // Nothing to do
|
|
|
|
}
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates newState = ObjectState();
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2017-04-17 19:01:37 +03:00
|
|
|
if (newState == aOldState && mType == aOldType) {
|
|
|
|
return; // Also done.
|
|
|
|
}
|
|
|
|
|
2005-09-21 23:14:30 +04:00
|
|
|
if (newState != aOldState) {
|
2016-01-21 21:39:13 +03:00
|
|
|
NS_ASSERTION(thisContent->IsInComposedDoc(), "Something is confused");
|
2005-09-21 23:14:30 +04:00
|
|
|
// This will trigger frame construction
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates changedBits = aOldState ^ newState;
|
2005-10-24 00:00:47 +04:00
|
|
|
{
|
2011-06-01 01:38:25 +04:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2011-03-29 07:32:11 +04:00
|
|
|
doc->ContentStateChanged(thisContent, changedBits);
|
2005-10-24 00:00:47 +04:00
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
} else if (aOldType != mType) {
|
|
|
|
// If our state changed, then we already recreated frames
|
|
|
|
// Otherwise, need to do that here
|
2010-06-25 17:59:57 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = doc->GetShell();
|
2010-01-07 13:36:11 +03:00
|
|
|
if (shell) {
|
2017-04-17 19:01:37 +03:00
|
|
|
shell->PostRecreateFramesFor(thisContent->AsElement());
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
}
|
2017-04-17 19:01:37 +03:00
|
|
|
|
|
|
|
if (aSync) {
|
|
|
|
NS_ASSERTION(InActiveDocument(thisContent), "Something is confused");
|
|
|
|
// Make sure that frames are actually constructed immediately.
|
|
|
|
doc->FlushPendingNotifications(FlushType::Frames);
|
|
|
|
}
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsObjectLoadingContent::ObjectType
|
2015-05-20 16:30:05 +03:00
|
|
|
nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType,
|
|
|
|
bool aNoFakePlugin)
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2017-03-04 02:18:02 +03:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
2005-09-21 23:14:30 +04:00
|
|
|
|
2017-03-04 02:18:02 +03:00
|
|
|
ObjectType type = static_cast<ObjectType>(
|
2015-05-20 16:30:05 +03:00
|
|
|
nsContentUtils::HtmlObjectContentTypeForMIMEType(aMIMEType, aNoFakePlugin,
|
|
|
|
thisContent));
|
2015-07-02 19:09:45 +03:00
|
|
|
|
2017-03-04 02:18:02 +03:00
|
|
|
// Switch the result type to eType_Null ic the capability is not present.
|
|
|
|
uint32_t caps = GetCapabilities();
|
|
|
|
if (!(caps & eSupportImages) && type == eType_Image) {
|
|
|
|
type = eType_Null;
|
2015-08-18 19:24:16 +03:00
|
|
|
}
|
2017-03-04 02:18:02 +03:00
|
|
|
if (!(caps & eSupportDocuments) && type == eType_Document) {
|
|
|
|
type = eType_Null;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
2015-05-20 16:30:05 +03:00
|
|
|
if (!(caps & eSupportPlugins) &&
|
|
|
|
(type == eType_Plugin || type == eType_FakePlugin)) {
|
2017-03-04 02:18:02 +03:00
|
|
|
type = eType_Null;
|
2006-01-28 17:08:55 +03:00
|
|
|
}
|
|
|
|
|
2017-03-04 02:18:02 +03:00
|
|
|
return type;
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2014-09-24 08:34:00 +04:00
|
|
|
nsPluginFrame*
|
2012-02-01 01:55:54 +04:00
|
|
|
nsObjectLoadingContent::GetExistingFrame()
|
2005-09-21 23:14:30 +04:00
|
|
|
{
|
2012-02-01 01:55:54 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
nsIFrame* frame = thisContent->GetPrimaryFrame();
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIObjectFrame* objFrame = do_QueryFrame(frame);
|
2014-09-24 08:34:00 +04:00
|
|
|
return static_cast<nsPluginFrame*>(objFrame);
|
2005-09-21 23:14:30 +04:00
|
|
|
}
|
|
|
|
|
2009-12-11 07:02:13 +03: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 {
|
2012-02-01 01:55:54 +04:00
|
|
|
aDest->mPrintFrame = const_cast<nsObjectLoadingContent*>(this)->GetExistingFrame();
|
2009-12-11 07:02:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mFrameLoader) {
|
2016-09-27 01:03:24 +03:00
|
|
|
nsCOMPtr<nsIContent> content =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(aDest));
|
2016-10-17 17:37:50 +03:00
|
|
|
nsFrameLoader* fl = nsFrameLoader::Create(content->AsElement(), nullptr, false);
|
2009-12-11 07:02:13 +03:00
|
|
|
if (fl) {
|
|
|
|
aDest->mFrameLoader = fl;
|
|
|
|
mFrameLoader->CreateStaticClone(fl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetPrintFrame(nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
*aFrame = mPrintFrame.GetFrame();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-20 02:38:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::PluginDestroyed()
|
|
|
|
{
|
|
|
|
// Called when our plugin is destroyed from under us, usually when reloading
|
|
|
|
// plugins in plugin host. Invalidate instance owner / prototype but otherwise
|
|
|
|
// don't take any action.
|
|
|
|
TeardownProtoChain();
|
2015-04-16 01:24:28 +03:00
|
|
|
if (mInstanceOwner) {
|
|
|
|
mInstanceOwner->Destroy();
|
|
|
|
mInstanceOwner = nullptr;
|
|
|
|
}
|
2013-03-20 02:38:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-13 19:42:41 +03:00
|
|
|
NS_IMETHODIMP
|
2010-03-17 08:10:08 +03:00
|
|
|
nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
|
2010-03-25 00:22:04 +03:00
|
|
|
const nsAString& pluginDumpID,
|
|
|
|
const nsAString& browserDumpID,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool submittedCrashReport)
|
2010-01-13 19:42:41 +03:00
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
LOG(("OBJLC [%p]: Plugin Crashed, queuing crash event", this));
|
|
|
|
NS_ASSERTION(mType == eType_Plugin, "PluginCrashed at non-plugin type");
|
|
|
|
|
2015-03-27 03:38:13 +03:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
HTMLObjectElement::HandlePluginCrashed(thisContent->AsElement());
|
|
|
|
#endif
|
|
|
|
|
2013-03-20 02:38:25 +04:00
|
|
|
PluginDestroyed();
|
2012-07-06 00:47:39 +04:00
|
|
|
|
|
|
|
// Switch to fallback/crashed state, notify
|
|
|
|
LoadFallback(eFallbackCrashed, true);
|
|
|
|
|
|
|
|
// send nsPluginCrashedEvent
|
2010-03-17 08:10:08 +03:00
|
|
|
|
2016-01-09 03:11:58 +03:00
|
|
|
// Note that aPluginTag in invalidated after we're called, so copy
|
2010-03-17 08:10:08 +03:00
|
|
|
// out any data we need now.
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pluginName;
|
2010-03-17 08:10:08 +03:00
|
|
|
aPluginTag->GetName(pluginName);
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString pluginFilename;
|
2010-04-08 11:45:00 +04:00
|
|
|
aPluginTag->GetFilename(pluginFilename);
|
2010-03-17 08:10:08 +03:00
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
nsCOMPtr<nsIRunnable> ev =
|
|
|
|
new nsPluginCrashedEvent(thisContent,
|
|
|
|
pluginDumpID,
|
|
|
|
browserDumpID,
|
|
|
|
NS_ConvertUTF8toUTF16(pluginName),
|
|
|
|
NS_ConvertUTF8toUTF16(pluginFilename),
|
|
|
|
submittedCrashReport);
|
2010-02-10 04:05:31 +03:00
|
|
|
nsresult rv = NS_DispatchToCurrentThread(ev);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("failed to dispatch nsPluginCrashedEvent");
|
|
|
|
}
|
2010-01-13 19:42:41 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-12-10 21:23:05 +04:00
|
|
|
|
2013-04-10 21:49:05 +04:00
|
|
|
nsresult
|
|
|
|
nsObjectLoadingContent::ScriptRequestPluginInstance(JSContext* aCx,
|
2012-12-08 02:50:10 +04:00
|
|
|
nsNPAPIPluginInstance **aResult)
|
|
|
|
{
|
2013-04-10 21:49:05 +04:00
|
|
|
// The below methods pull the cx off the stack, so make sure they match.
|
|
|
|
//
|
|
|
|
// NB: Sometimes there's a null cx on the stack, in which case |cx| is the
|
|
|
|
// safe JS context. But in that case, IsCallerChrome() will return true,
|
|
|
|
// so the ensuing expression is short-circuited.
|
2017-02-01 23:43:36 +03:00
|
|
|
// XXXbz the NB comment above doesn't really make sense. At the moment, all
|
|
|
|
// the callers to this except maybe SetupProtoChain have a useful JSContext*
|
|
|
|
// that could be used for nsContentUtils::IsSystemCaller... We do need to
|
|
|
|
// sort out what the SetupProtoChain callers look like.
|
2013-04-10 21:49:05 +04:00
|
|
|
MOZ_ASSERT_IF(nsContentUtils::GetCurrentJSContext(),
|
|
|
|
aCx == nsContentUtils::GetCurrentJSContext());
|
2014-09-25 13:04:45 +04:00
|
|
|
bool callerIsContentJS = (nsContentUtils::GetCurrentJSContext() &&
|
|
|
|
!nsContentUtils::IsCallerChrome() &&
|
2015-10-27 11:18:11 +03:00
|
|
|
!nsContentUtils::IsCallerContentXBL());
|
2013-04-10 21:49:05 +04:00
|
|
|
|
2012-12-08 02:50:10 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
|
|
|
|
*aResult = nullptr;
|
|
|
|
|
|
|
|
// The first time content script attempts to access placeholder content, fire
|
|
|
|
// an event. Fallback types >= eFallbackClickToPlay are plugin-replacement
|
|
|
|
// types, see header.
|
2013-04-10 21:49:05 +04:00
|
|
|
if (callerIsContentJS && !mScriptRequested &&
|
2012-12-08 02:50:10 +04:00
|
|
|
InActiveDocument(thisContent) && mType == eType_Null &&
|
|
|
|
mFallbackType >= eFallbackClickToPlay) {
|
|
|
|
nsCOMPtr<nsIRunnable> ev =
|
|
|
|
new nsSimplePluginEvent(thisContent,
|
|
|
|
NS_LITERAL_STRING("PluginScripted"));
|
|
|
|
nsresult rv = NS_DispatchToCurrentThread(ev);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_NOTREACHED("failed to dispatch PluginScripted event");
|
|
|
|
}
|
|
|
|
mScriptRequested = true;
|
2014-02-05 01:53:32 +04:00
|
|
|
} else if (callerIsContentJS && mType == eType_Plugin && !mInstanceOwner &&
|
2012-12-08 02:50:10 +04:00
|
|
|
nsContentUtils::IsSafeToRunScript() &&
|
|
|
|
InActiveDocument(thisContent)) {
|
|
|
|
// If we're configured as a plugin in an active document and it's safe to
|
|
|
|
// run scripts right now, try spawning synchronously
|
|
|
|
SyncStartPluginInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mInstanceOwner) {
|
|
|
|
return mInstanceOwner->GetInstance(aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note that returning a null plugin is expected (and happens often)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::SyncStartPluginInstance()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"Must be able to run script in order to instantiate a plugin instance!");
|
|
|
|
|
2012-02-14 01:26:41 +04:00
|
|
|
// Don't even attempt to start an instance unless the content is in
|
2012-07-06 04:56:25 +04:00
|
|
|
// the document and active
|
2012-02-14 01:26:41 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2012-07-06 04:56:25 +04:00
|
|
|
if (!InActiveDocument(thisContent)) {
|
2012-02-01 01:55:54 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-02-09 03:15:16 +04:00
|
|
|
nsCOMPtr<nsIURI> kungFuURIGrip(mURI);
|
2016-08-24 21:12:09 +03:00
|
|
|
mozilla::Unused << kungFuURIGrip; // This URI is not referred to within this function
|
2012-02-14 01:26:41 +04:00
|
|
|
nsCString contentType(mContentType);
|
2012-07-06 01:07:46 +04:00
|
|
|
return InstantiatePluginInstance();
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::AsyncStartPluginInstance()
|
|
|
|
{
|
2013-03-13 03:13:46 +04:00
|
|
|
// OK to have an instance already or a pending spawn.
|
|
|
|
if (mInstanceOwner || mPendingInstantiateEvent) {
|
2012-02-01 01:55:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-13 03:13:46 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2012-02-01 01:55:54 +04:00
|
|
|
nsIDocument* doc = thisContent->OwnerDoc();
|
|
|
|
if (doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRunnable> event = new nsAsyncInstantiateEvent(this);
|
|
|
|
nsresult rv = NS_DispatchToCurrentThread(event);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2013-03-13 03:13:46 +04:00
|
|
|
// Track pending events
|
2012-02-01 01:55:54 +04:00
|
|
|
mPendingInstantiateEvent = event;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-03-12 20:48:27 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::GetSrcURI(nsIURI** aURI)
|
|
|
|
{
|
2013-03-04 23:08:24 +04:00
|
|
|
NS_IF_ADDREF(*aURI = GetSrcURI());
|
2012-03-12 20:48:27 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) {
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates oldState = ObjectState();
|
2012-07-06 00:47:39 +04:00
|
|
|
ObjectType oldType = mType;
|
|
|
|
|
|
|
|
NS_ASSERTION(!mInstanceOwner && !mFrameLoader && !mChannel,
|
|
|
|
"LoadFallback called with loaded content");
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fixup mFallbackType
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
2017-02-09 02:19:01 +03:00
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2012-07-06 00:47:39 +04:00
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!thisContent->IsHTMLElement() || mContentType.IsEmpty()) {
|
2012-08-21 03:28:19 +04:00
|
|
|
// Don't let custom fallback handlers run outside HTML, tags without a
|
|
|
|
// determined type should always just be alternate content
|
2012-07-06 00:47:39 +04:00
|
|
|
aType = eFallbackAlternate;
|
|
|
|
}
|
|
|
|
|
2016-04-29 00:57:34 +03:00
|
|
|
// We'll set this to null no matter what now, doing it here means we'll load
|
|
|
|
// child embeds as we find them in the upcoming loop.
|
|
|
|
mType = eType_Null;
|
|
|
|
|
2017-02-09 02:19:01 +03:00
|
|
|
bool thisIsObject = thisContent->IsHTMLElement(nsGkAtoms::object);
|
|
|
|
|
|
|
|
// Do a depth-first traverse of node tree with the current element as root,
|
|
|
|
// looking for <embed> or <object> elements that might now need to load.
|
2016-04-29 00:57:34 +03:00
|
|
|
nsTArray<nsINodeList*> childNodes;
|
2017-07-29 02:44:39 +03:00
|
|
|
if (thisContent->IsHTMLElement(nsGkAtoms::object) &&
|
2012-07-06 00:47:39 +04:00
|
|
|
(aType == eFallbackUnsupported ||
|
|
|
|
aType == eFallbackDisabled ||
|
2016-05-21 06:13:17 +03:00
|
|
|
aType == eFallbackBlocklisted ||
|
|
|
|
aType == eFallbackAlternate))
|
2012-07-06 00:47:39 +04:00
|
|
|
{
|
2017-07-25 00:58:34 +03:00
|
|
|
for (nsIContent* child = thisContent->GetFirstChild(); child; ) {
|
|
|
|
// When we advance to our next child, we don't want to traverse subtrees
|
|
|
|
// under descendant <object> and <embed> elements; those will handle
|
|
|
|
// those subtrees themselves if they end up falling back.
|
|
|
|
bool skipChildDescendants = false;
|
2016-04-29 00:57:34 +03:00
|
|
|
if (aType != eFallbackAlternate &&
|
|
|
|
!child->IsHTMLElement(nsGkAtoms::param) &&
|
2012-08-21 03:16:02 +04:00
|
|
|
nsStyleUtil::IsSignificantChild(child, true, false)) {
|
|
|
|
aType = eFallbackAlternate;
|
2016-04-29 00:57:34 +03:00
|
|
|
}
|
2017-02-09 02:19:01 +03:00
|
|
|
if (thisIsObject) {
|
2017-07-29 07:35:43 +03:00
|
|
|
if (auto embed = HTMLEmbedElement::FromContent(child)) {
|
2017-02-09 02:19:01 +03:00
|
|
|
embed->StartObjectLoad(true, true);
|
2017-07-25 00:58:34 +03:00
|
|
|
skipChildDescendants = true;
|
2017-02-09 02:19:01 +03:00
|
|
|
} else if (auto object = HTMLObjectElement::FromContent(child)) {
|
2016-04-29 00:57:34 +03:00
|
|
|
object->StartObjectLoad(true, true);
|
2017-07-25 00:58:34 +03:00
|
|
|
skipChildDescendants = true;
|
2016-04-29 00:57:34 +03:00
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
2017-07-25 00:58:34 +03:00
|
|
|
|
|
|
|
if (skipChildDescendants) {
|
|
|
|
child = child->GetNextNonChildNode(thisContent);
|
|
|
|
} else {
|
|
|
|
child = child->GetNextNode(thisContent);
|
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mFallbackType = aType;
|
|
|
|
|
2012-11-08 01:59:15 +04:00
|
|
|
// Notify
|
2012-07-06 00:47:39 +04:00
|
|
|
if (!aNotify) {
|
|
|
|
return; // done
|
|
|
|
}
|
|
|
|
|
|
|
|
NotifyStateChanged(oldType, oldState, false, true);
|
|
|
|
}
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
void
|
2016-11-17 00:44:24 +03:00
|
|
|
nsObjectLoadingContent::DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner)
|
2012-05-26 02:34:11 +04:00
|
|
|
{
|
2012-09-07 04:16:02 +04:00
|
|
|
// DoStopPlugin can process events -- There may be pending
|
|
|
|
// CheckPluginStopEvent events which can drop in underneath us and destroy the
|
2016-11-17 00:44:24 +03:00
|
|
|
// instance we are about to destroy. We prevent that with the mIsStopping
|
|
|
|
// flag.
|
|
|
|
if (mIsStopping) {
|
2012-05-26 02:34:11 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
mIsStopping = true;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginInstanceOwner> kungFuDeathGrip(aInstanceOwner);
|
2017-05-29 13:38:46 +03:00
|
|
|
if (mType == eType_FakePlugin) {
|
|
|
|
if (mFrameLoader) {
|
|
|
|
mFrameLoader->Destroy();
|
|
|
|
mFrameLoader = nullptr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RefPtr<nsNPAPIPluginInstance> inst;
|
|
|
|
aInstanceOwner->GetInstance(getter_AddRefs(inst));
|
|
|
|
if (inst) {
|
2012-02-01 01:55:54 +04:00
|
|
|
#if defined(XP_MACOSX)
|
2017-05-29 13:38:46 +03:00
|
|
|
aInstanceOwner->HidePluginWindow();
|
2012-02-01 01:55:54 +04:00
|
|
|
#endif
|
|
|
|
|
2017-05-29 13:38:46 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
|
|
|
NS_ASSERTION(pluginHost, "No plugin host?");
|
|
|
|
pluginHost->StopPluginInstance(inst);
|
|
|
|
}
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
2013-09-06 00:54:58 +04:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
aInstanceOwner->Destroy();
|
2013-03-15 05:29:16 +04:00
|
|
|
|
2013-09-06 00:54:58 +04:00
|
|
|
// If we re-enter in plugin teardown UnloadObject will tear down the
|
|
|
|
// protochain -- the current protochain could be from a new, unrelated, load.
|
|
|
|
if (!mIsStopping) {
|
|
|
|
LOG(("OBJLC [%p]: Re-entered in plugin teardown", this));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TeardownProtoChain();
|
2012-08-18 01:58:43 +04:00
|
|
|
mIsStopping = false;
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::StopPluginInstance()
|
|
|
|
{
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL("nsObjectLoadingContent::StopPluginInstance", OTHER);
|
2012-09-07 04:16:02 +04:00
|
|
|
// Clear any pending events
|
2012-07-06 01:07:46 +04:00
|
|
|
mPendingInstantiateEvent = nullptr;
|
2012-09-07 04:16:02 +04:00
|
|
|
mPendingCheckPluginStopEvent = nullptr;
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2014-02-21 01:34:06 +04:00
|
|
|
// If we're currently instantiating, clearing this will cause
|
|
|
|
// InstantiatePluginInstance's re-entrance check to destroy the created plugin
|
|
|
|
mInstantiating = false;
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
if (!mInstanceOwner) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-06 01:07:46 +04:00
|
|
|
if (mChannel) {
|
|
|
|
// The plugin has already used data from this channel, we'll need to
|
|
|
|
// re-open it to handle instantiating again, even if we don't invalidate
|
|
|
|
// our loaded state.
|
|
|
|
/// XXX(johns): Except currently, we don't, just leaving re-opening channels
|
|
|
|
/// to plugins...
|
|
|
|
LOG(("OBJLC [%p]: StopPluginInstance - Closing used channel", this));
|
|
|
|
CloseChannel();
|
|
|
|
}
|
|
|
|
|
2013-04-18 02:11:21 +04:00
|
|
|
// We detach the instance owner's frame before destruction, but don't destroy
|
|
|
|
// the instance owner until the plugin is stopped.
|
2013-03-15 05:29:16 +04:00
|
|
|
mInstanceOwner->SetFrame(nullptr);
|
2012-02-01 01:55:54 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginInstanceOwner> ownerGrip(mInstanceOwner);
|
2012-07-30 18:20:58 +04:00
|
|
|
mInstanceOwner = nullptr;
|
2012-05-26 02:34:11 +04:00
|
|
|
|
2013-03-15 05:29:16 +04:00
|
|
|
// This can/will re-enter
|
2016-11-17 00:44:24 +03:00
|
|
|
DoStopPlugin(ownerGrip);
|
2013-03-15 05:29:16 +04:00
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsObjectLoadingContent::NotifyContentObjectWrapper()
|
|
|
|
{
|
2012-07-06 01:07:46 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
2012-02-01 01:55:54 +04:00
|
|
|
|
2014-07-15 15:34:42 +04:00
|
|
|
AutoJSAPI jsapi;
|
|
|
|
jsapi.Init();
|
|
|
|
JSContext* cx = jsapi.cx();
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2013-05-02 13:12:45 +04:00
|
|
|
JS::Rooted<JSObject*> obj(cx, thisContent->GetWrapper());
|
2013-03-04 23:08:23 +04:00
|
|
|
if (!obj) {
|
2012-02-01 01:55:54 +04:00
|
|
|
// Nothing to do here if there's no wrapper for mContent. The proto
|
|
|
|
// chain will be fixed appropriately when the wrapper is created.
|
|
|
|
return;
|
|
|
|
}
|
2012-07-06 01:07:46 +04:00
|
|
|
|
2013-04-10 21:49:05 +04:00
|
|
|
SetupProtoChain(cx, obj);
|
2012-02-01 01:55:54 +04:00
|
|
|
}
|
|
|
|
|
2017-02-01 23:43:36 +03:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::PlayPlugin(SystemCallerGuarantee, ErrorResult& aRv)
|
2011-12-10 21:23:05 +04:00
|
|
|
{
|
2017-02-01 23:43:36 +03:00
|
|
|
// This is a ChromeOnly method, so no need to check caller type here.
|
2012-10-04 23:57:24 +04:00
|
|
|
if (!mActivated) {
|
|
|
|
mActivated = true;
|
|
|
|
LOG(("OBJLC [%p]: Activated by user", this));
|
|
|
|
}
|
|
|
|
|
2015-08-20 23:15:18 +03:00
|
|
|
// If we're in a click-to-play state, reload.
|
2012-10-04 23:57:24 +04:00
|
|
|
// Fallback types >= eFallbackClickToPlay are plugin-replacement types, see
|
|
|
|
// header
|
|
|
|
if (mType == eType_Null && mFallbackType >= eFallbackClickToPlay) {
|
2017-02-01 23:43:36 +03:00
|
|
|
aRv = LoadObject(true, true);
|
2012-10-04 23:57:24 +04:00
|
|
|
}
|
2011-12-10 21:23:05 +04:00
|
|
|
}
|
2012-03-28 19:53:56 +04:00
|
|
|
|
2013-06-19 01:35:26 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::Reload(bool aClearActivation)
|
|
|
|
{
|
|
|
|
if (aClearActivation) {
|
|
|
|
mActivated = false;
|
2015-05-20 16:30:05 +03:00
|
|
|
mSkipFakePlugins = false;
|
2013-06-19 01:35:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return LoadObject(true, true);
|
|
|
|
}
|
|
|
|
|
2012-03-28 19:53:56 +04:00
|
|
|
NS_IMETHODIMP
|
2012-07-06 00:47:39 +04:00
|
|
|
nsObjectLoadingContent::GetActivated(bool *aActivated)
|
2012-03-28 19:53:56 +04:00
|
|
|
{
|
2013-03-04 23:08:24 +04:00
|
|
|
*aActivated = Activated();
|
2012-03-28 19:53:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2013-06-24 16:51:07 +04:00
|
|
|
uint32_t
|
|
|
|
nsObjectLoadingContent::DefaultFallbackType()
|
|
|
|
{
|
|
|
|
FallbackType reason;
|
2015-05-20 16:30:05 +03:00
|
|
|
if (ShouldPlay(reason)) {
|
2013-06-24 16:51:07 +04:00
|
|
|
return PLUGIN_ACTIVE;
|
|
|
|
}
|
|
|
|
return reason;
|
|
|
|
}
|
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::SkipFakePlugins()
|
|
|
|
{
|
|
|
|
if (!nsContentUtils::IsCallerChrome())
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
mSkipFakePlugins = true;
|
|
|
|
|
|
|
|
// If we're showing a fake plugin now, reload
|
|
|
|
if (mType == eType_FakePlugin) {
|
|
|
|
return LoadObject(true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-02-01 23:43:36 +03:00
|
|
|
uint32_t
|
|
|
|
nsObjectLoadingContent::GetRunID(SystemCallerGuarantee, ErrorResult& aRv)
|
2015-03-17 20:28:32 +03:00
|
|
|
{
|
|
|
|
if (!mHasRunID) {
|
|
|
|
// The plugin instance must not have a run ID, so we must
|
|
|
|
// be running the plugin in-process.
|
2017-02-01 23:43:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
2015-03-17 20:28:32 +03:00
|
|
|
}
|
2017-02-01 23:43:36 +03:00
|
|
|
return mRunID;
|
2015-03-17 20:28:32 +03:00
|
|
|
}
|
|
|
|
|
2013-06-24 16:51:07 +04:00
|
|
|
static bool sPrefsInitialized;
|
|
|
|
static uint32_t sSessionTimeoutMinutes;
|
|
|
|
static uint32_t sPersistentTimeoutDays;
|
2017-02-07 00:40:00 +03:00
|
|
|
static bool sBlockURIs;
|
|
|
|
|
|
|
|
static void initializeObjectLoadingContentPrefs()
|
|
|
|
{
|
|
|
|
if (!sPrefsInitialized) {
|
|
|
|
Preferences::AddUintVarCache(&sSessionTimeoutMinutes,
|
|
|
|
"plugin.sessionPermissionNow.intervalInMinutes", 60);
|
|
|
|
Preferences::AddUintVarCache(&sPersistentTimeoutDays,
|
|
|
|
"plugin.persistentPermissionAlways.intervalInDays", 90);
|
|
|
|
|
|
|
|
Preferences::AddBoolVarCache(&sBlockURIs, kPrefBlockURIs, false);
|
|
|
|
sPrefsInitialized = true;
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 16:51:07 +04:00
|
|
|
|
2016-06-17 13:05:42 +03:00
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::ShouldBlockContent()
|
|
|
|
{
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2017-02-07 00:40:00 +03:00
|
|
|
if (!sPrefsInitialized) {
|
|
|
|
initializeObjectLoadingContentPrefs();
|
|
|
|
}
|
2016-06-17 13:05:42 +03:00
|
|
|
|
2017-02-07 00:40:00 +03:00
|
|
|
if (mContentBlockingEnabled && mURI && IsFlashMIME(mContentType) && sBlockURIs ) {
|
|
|
|
return true;
|
2016-06-17 13:05:42 +03:00
|
|
|
}
|
|
|
|
|
2017-02-07 00:40:00 +03:00
|
|
|
return false;
|
2016-06-17 13:05:42 +03:00
|
|
|
}
|
|
|
|
|
2012-07-06 00:47:39 +04:00
|
|
|
bool
|
2015-05-20 16:30:05 +03:00
|
|
|
nsObjectLoadingContent::ShouldPlay(FallbackType &aReason)
|
2012-07-06 00:47:39 +04:00
|
|
|
{
|
2013-06-11 18:58:43 +04:00
|
|
|
nsresult rv;
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2013-06-24 16:51:07 +04:00
|
|
|
if (!sPrefsInitialized) {
|
2017-02-07 00:40:00 +03:00
|
|
|
initializeObjectLoadingContentPrefs();
|
2013-06-24 16:51:07 +04:00
|
|
|
}
|
|
|
|
|
2016-01-06 04:57:11 +03:00
|
|
|
if (BrowserTabsRemoteAutostart()) {
|
|
|
|
bool shouldLoadInParent = nsPluginHost::ShouldLoadTypeInParent(mContentType);
|
|
|
|
bool inParent = XRE_IsParentProcess();
|
|
|
|
|
|
|
|
if (shouldLoadInParent != inParent) {
|
|
|
|
// Plugins need to be locked to either the parent process or the content
|
|
|
|
// process. If a plugin is locked to one process type, it can't be used in
|
|
|
|
// the other. Otherwise we'll get hangs.
|
|
|
|
aReason = eFallbackDisabled;
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-23 04:29:21 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2013-06-11 18:58:43 +04:00
|
|
|
// Order of checks:
|
|
|
|
// * Assume a default of click-to-play
|
2013-06-24 16:51:07 +04:00
|
|
|
// * If globally disabled, per-site permissions cannot override.
|
2013-06-11 18:58:43 +04:00
|
|
|
// * If blocklisted, override the reason with the blocklist reason
|
2016-11-23 02:01:04 +03:00
|
|
|
// * Check if the flash blocking status for this page denies flash from loading.
|
2013-06-11 18:58:43 +04:00
|
|
|
// * Check per-site permissions and follow those if specified.
|
|
|
|
// * Honor per-plugin disabled permission
|
|
|
|
// * Blocklisted plugins are forced to CtP
|
|
|
|
// * Check per-plugin permission and follow that.
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2013-06-24 16:51:07 +04:00
|
|
|
aReason = eFallbackClickToPlay;
|
|
|
|
|
|
|
|
uint32_t enabledState = nsIPluginTag::STATE_DISABLED;
|
2015-02-25 19:36:39 +03:00
|
|
|
pluginHost->GetStateForType(mContentType, nsPluginHost::eExcludeNone,
|
|
|
|
&enabledState);
|
2013-06-24 16:51:07 +04:00
|
|
|
if (nsIPluginTag::STATE_DISABLED == enabledState) {
|
|
|
|
aReason = eFallbackDisabled;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-11 18:58:43 +04:00
|
|
|
// Before we check permissions, get the blocklist state of this plugin to set
|
2015-05-01 18:07:19 +03:00
|
|
|
// the fallback reason correctly. In the content process this will involve
|
|
|
|
// an ipc call to chrome.
|
|
|
|
uint32_t blocklistState = nsIBlocklistService::STATE_BLOCKED;
|
2015-02-25 19:36:39 +03:00
|
|
|
pluginHost->GetBlocklistStateForType(mContentType,
|
|
|
|
nsPluginHost::eExcludeNone,
|
|
|
|
&blocklistState);
|
2013-06-24 16:51:07 +04:00
|
|
|
if (blocklistState == nsIBlocklistService::STATE_BLOCKED) {
|
|
|
|
// no override possible
|
|
|
|
aReason = eFallbackBlocklisted;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-11 18:58:43 +04:00
|
|
|
if (blocklistState == nsIBlocklistService::STATE_VULNERABLE_UPDATE_AVAILABLE) {
|
2012-10-01 20:46:05 +04:00
|
|
|
aReason = eFallbackVulnerableUpdatable;
|
2015-05-20 16:30:05 +03:00
|
|
|
} else if (blocklistState == nsIBlocklistService::STATE_VULNERABLE_NO_UPDATE) {
|
2012-10-01 20:46:05 +04:00
|
|
|
aReason = eFallbackVulnerableNoUpdate;
|
|
|
|
}
|
2013-06-11 18:58:43 +04:00
|
|
|
|
2016-11-23 02:01:04 +03:00
|
|
|
// Document and window lookup
|
2012-07-06 00:47:39 +04:00
|
|
|
nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
|
|
|
MOZ_ASSERT(thisContent);
|
|
|
|
nsIDocument* ownerDoc = thisContent->OwnerDoc();
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> window = ownerDoc->GetWindow();
|
2012-07-06 00:47:39 +04:00
|
|
|
if (!window) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> topWindow = window->GetTop();
|
2015-10-27 00:37:32 +03:00
|
|
|
NS_ENSURE_TRUE(topWindow, false);
|
|
|
|
nsCOMPtr<nsIDocument> topDoc = topWindow->GetDoc();
|
|
|
|
NS_ENSURE_TRUE(topDoc, false);
|
2012-07-06 00:47:39 +04:00
|
|
|
|
2016-11-23 02:01:04 +03:00
|
|
|
// Check the flash blocking status for this page (this applies to Flash only)
|
2017-03-25 00:15:02 +03:00
|
|
|
FlashClassification documentClassification = FlashClassification::Unknown;
|
2016-11-23 02:01:04 +03:00
|
|
|
if (IsFlashMIME(mContentType)) {
|
|
|
|
documentClassification = ownerDoc->DocumentFlashClassification();
|
|
|
|
}
|
2017-02-14 00:39:40 +03:00
|
|
|
if (documentClassification == FlashClassification::Denied) {
|
2016-11-23 02:01:04 +03:00
|
|
|
aReason = eFallbackSuppressed;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the permission manager for permission based on the principal of
|
|
|
|
// the toplevel content.
|
2014-04-29 21:27:26 +04:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManager = services::GetPermissionManager();
|
|
|
|
NS_ENSURE_TRUE(permissionManager, false);
|
2012-07-06 00:47:39 +04:00
|
|
|
|
|
|
|
// For now we always say that the system principal uses click-to-play since
|
2015-05-20 16:30:05 +03:00
|
|
|
// that maintains current behavior and we have tests that expect this. What
|
|
|
|
// we really should do is disable plugins entirely in pages that use the
|
|
|
|
// system principal, i.e. in chrome pages. That way the click-to-play code
|
|
|
|
// here wouldn't matter at all. Bug 775301 is tracking this.
|
2012-07-06 00:47:39 +04:00
|
|
|
if (!nsContentUtils::IsSystemPrincipal(topDoc->NodePrincipal())) {
|
2012-11-27 22:09:10 +04:00
|
|
|
nsAutoCString permissionString;
|
2015-02-25 19:36:39 +03:00
|
|
|
rv = pluginHost->GetPermissionStringForType(mContentType,
|
|
|
|
nsPluginHost::eExcludeNone,
|
|
|
|
permissionString);
|
2012-11-27 22:09:10 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t permission;
|
2012-07-06 00:47:39 +04:00
|
|
|
rv = permissionManager->TestPermissionFromPrincipal(topDoc->NodePrincipal(),
|
2012-11-27 22:09:10 +04:00
|
|
|
permissionString.Data(),
|
2012-07-06 00:47:39 +04:00
|
|
|
&permission);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2013-06-24 16:51:07 +04:00
|
|
|
if (permission != nsIPermissionManager::UNKNOWN_ACTION) {
|
|
|
|
uint64_t nowms = PR_Now() / 1000;
|
|
|
|
permissionManager->UpdateExpireTime(
|
|
|
|
topDoc->NodePrincipal(), permissionString.Data(), false,
|
|
|
|
nowms + sSessionTimeoutMinutes * 60 * 1000,
|
|
|
|
nowms / 1000 + uint64_t(sPersistentTimeoutDays) * 24 * 60 * 60 * 1000);
|
|
|
|
}
|
2013-06-11 18:58:43 +04:00
|
|
|
switch (permission) {
|
|
|
|
case nsIPermissionManager::ALLOW_ACTION:
|
2017-01-24 08:07:41 +03:00
|
|
|
if (PreferFallback(false /* isPluginClickToPlay */)) {
|
|
|
|
aReason = eFallbackAlternate;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-11 18:58:43 +04:00
|
|
|
return true;
|
|
|
|
case nsIPermissionManager::DENY_ACTION:
|
|
|
|
aReason = eFallbackDisabled;
|
|
|
|
return false;
|
|
|
|
case nsIPermissionManager::PROMPT_ACTION:
|
2017-01-24 08:07:41 +03:00
|
|
|
if (PreferFallback(true /* isPluginClickToPlay */)) {
|
|
|
|
// False is already returned in this case, but
|
|
|
|
// it's important to correctly set aReason too.
|
|
|
|
aReason = eFallbackAlternate;
|
|
|
|
}
|
|
|
|
|
2013-06-11 18:58:43 +04:00
|
|
|
return false;
|
|
|
|
case nsIPermissionManager::UNKNOWN_ACTION:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2013-06-11 18:58:43 +04:00
|
|
|
// No site-specific permissions. Vulnerable plugins are automatically CtP
|
|
|
|
if (blocklistState == nsIBlocklistService::STATE_VULNERABLE_UPDATE_AVAILABLE ||
|
|
|
|
blocklistState == nsIBlocklistService::STATE_VULNERABLE_NO_UPDATE) {
|
|
|
|
return false;
|
2013-02-15 01:38:41 +04:00
|
|
|
}
|
|
|
|
|
2017-01-24 08:07:41 +03:00
|
|
|
if (PreferFallback(enabledState == nsIPluginTag::STATE_CLICKTOPLAY)) {
|
|
|
|
aReason = eFallbackAlternate;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-25 00:15:02 +03:00
|
|
|
// On the following switch we don't need to handle the case where
|
|
|
|
// documentClassification is FlashClassification::Denied because
|
|
|
|
// that's already handled above.
|
2013-06-11 18:58:43 +04:00
|
|
|
switch (enabledState) {
|
|
|
|
case nsIPluginTag::STATE_ENABLED:
|
2017-03-25 00:15:02 +03:00
|
|
|
return true;
|
2013-06-11 18:58:43 +04:00
|
|
|
case nsIPluginTag::STATE_CLICKTOPLAY:
|
2017-03-25 00:15:02 +03:00
|
|
|
if (documentClassification == FlashClassification::Allowed) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-06-11 18:58:43 +04:00
|
|
|
return false;
|
|
|
|
}
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Unexpected enabledState");
|
2012-07-06 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2017-01-24 08:07:41 +03:00
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::FavorFallbackMode(bool aIsPluginClickToPlay) {
|
|
|
|
if (!IsFlashMIME(mContentType)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-31 03:52:51 +03:00
|
|
|
nsAutoCString prefString;
|
|
|
|
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackMode, prefString))) {
|
2017-01-24 08:07:41 +03:00
|
|
|
if (aIsPluginClickToPlay &&
|
|
|
|
prefString.EqualsLiteral("follow-ctp")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prefString.EqualsLiteral("always")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::HasGoodFallback() {
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
NS_ASSERTION(thisContent, "must be a content");
|
|
|
|
|
|
|
|
if (!thisContent->IsHTMLElement(nsGkAtoms::object) ||
|
|
|
|
mContentType.IsEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-24 08:08:04 +03:00
|
|
|
nsTArray<nsCString> rulesList;
|
2017-07-31 03:52:51 +03:00
|
|
|
nsAutoCString prefString;
|
|
|
|
if (NS_SUCCEEDED(Preferences::GetCString(kPrefFavorFallbackRules, prefString))) {
|
2017-01-24 08:08:04 +03:00
|
|
|
ParseString(prefString, ',', rulesList);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < rulesList.Length(); ++i) {
|
|
|
|
// RULE "embed":
|
|
|
|
// Don't use fallback content if the object contains an <embed> inside its
|
|
|
|
// fallback content.
|
|
|
|
if (rulesList[i].EqualsLiteral("embed")) {
|
|
|
|
nsTArray<nsINodeList*> childNodes;
|
|
|
|
for (nsIContent* child = thisContent->GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextNode(thisContent)) {
|
|
|
|
if (child->IsHTMLElement(nsGkAtoms::embed)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RULE "video":
|
|
|
|
// Use fallback content if the object contains a <video> inside its
|
|
|
|
// fallback content.
|
|
|
|
if (rulesList[i].EqualsLiteral("video")) {
|
|
|
|
nsTArray<nsINodeList*> childNodes;
|
|
|
|
for (nsIContent* child = thisContent->GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextNode(thisContent)) {
|
|
|
|
if (child->IsHTMLElement(nsGkAtoms::video)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 04:56:22 +03:00
|
|
|
// RULE "nosrc":
|
|
|
|
// Use fallback content if the object has not specified an URI.
|
|
|
|
if (rulesList[i].EqualsLiteral("nosrc")) {
|
|
|
|
if (!mOriginalURI) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-24 08:08:04 +03:00
|
|
|
// RULE "adobelink":
|
|
|
|
// Don't use fallback content when it has a link to adobe's website.
|
|
|
|
if (rulesList[i].EqualsLiteral("adobelink")) {
|
|
|
|
nsTArray<nsINodeList*> childNodes;
|
|
|
|
for (nsIContent* child = thisContent->GetFirstChild();
|
|
|
|
child;
|
|
|
|
child = child->GetNextNode(thisContent)) {
|
|
|
|
if (child->IsHTMLElement(nsGkAtoms::a)) {
|
|
|
|
nsCOMPtr<nsIURI> href = child->GetHrefURI();
|
|
|
|
if (href) {
|
|
|
|
nsAutoCString asciiHost;
|
|
|
|
nsresult rv = href->GetAsciiHost(asciiHost);
|
|
|
|
if (NS_SUCCEEDED(rv) &&
|
|
|
|
!asciiHost.IsEmpty() &&
|
|
|
|
(asciiHost.EqualsLiteral("adobe.com") ||
|
|
|
|
StringEndsWith(asciiHost, NS_LITERAL_CSTRING(".adobe.com")))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RULE "installinstructions":
|
|
|
|
// Don't use fallback content when the text content on the fallback appears
|
|
|
|
// to contain instructions to install or download Flash.
|
|
|
|
if (rulesList[i].EqualsLiteral("installinstructions")) {
|
|
|
|
nsAutoString textContent;
|
|
|
|
ErrorResult rv;
|
|
|
|
thisContent->GetTextContent(textContent, rv);
|
|
|
|
bool hasText =
|
|
|
|
!rv.Failed() &&
|
|
|
|
(CaseInsensitiveFindInReadable(NS_LITERAL_STRING("Flash"), textContent) ||
|
|
|
|
CaseInsensitiveFindInReadable(NS_LITERAL_STRING("Install"), textContent) ||
|
|
|
|
CaseInsensitiveFindInReadable(NS_LITERAL_STRING("Download"), textContent));
|
|
|
|
|
|
|
|
if (hasText) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RULE "true":
|
|
|
|
// By having a rule that returns true, we can put it at the end of the rules list
|
|
|
|
// to change the default-to-false behavior to be default-to-true.
|
|
|
|
if (rulesList[i].EqualsLiteral("true")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-01-24 08:07:41 +03:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::PreferFallback(bool aIsPluginClickToPlay) {
|
2017-01-24 08:07:51 +03:00
|
|
|
if (mPreferFallbackKnown) {
|
|
|
|
return mPreferFallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPreferFallbackKnown = true;
|
|
|
|
mPreferFallback = FavorFallbackMode(aIsPluginClickToPlay) && HasGoodFallback();
|
|
|
|
return mPreferFallback;
|
2017-01-24 08:07:41 +03:00
|
|
|
}
|
|
|
|
|
2013-03-04 23:08:24 +04:00
|
|
|
nsIDocument*
|
2016-10-11 04:07:48 +03:00
|
|
|
nsObjectLoadingContent::GetContentDocument(nsIPrincipal& aSubjectPrincipal)
|
2013-03-04 23:08:24 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
|
2015-02-24 17:41:43 +03:00
|
|
|
if (!thisContent->IsInComposedDoc()) {
|
2013-03-04 23:08:24 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument *sub_doc = thisContent->OwnerDoc()->GetSubDocumentFor(thisContent);
|
|
|
|
if (!sub_doc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-05-04 01:47:09 +04:00
|
|
|
// Return null for cross-origin contentDocument.
|
2016-10-11 04:07:48 +03:00
|
|
|
if (!aSubjectPrincipal.SubsumesConsideringDomain(sub_doc->NodePrincipal())) {
|
2013-05-04 01:47:09 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-03-04 23:08:24 +04:00
|
|
|
return sub_doc;
|
|
|
|
}
|
|
|
|
|
2013-03-04 23:08:23 +04:00
|
|
|
void
|
2013-05-02 13:12:45 +04:00
|
|
|
nsObjectLoadingContent::SetupProtoChain(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aObject)
|
2013-03-04 23:08:23 +04:00
|
|
|
{
|
2013-04-10 21:49:05 +04:00
|
|
|
if (mType != eType_Plugin) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nsContentUtils::IsSafeToRunScript()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SetupProtoChainRunner> runner = new SetupProtoChainRunner(this);
|
2013-03-04 23:08:23 +04:00
|
|
|
nsContentUtils::AddScriptRunner(runner);
|
2013-04-10 21:49:05 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We get called on random compartments here for some reason
|
|
|
|
// (perhaps because WrapObject can happen on a random compartment?)
|
|
|
|
// so make sure to enter the compartment of aObject.
|
|
|
|
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
|
|
|
|
|
|
|
JSAutoCompartment ac(aCx, aObject);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pi;
|
2013-04-10 21:49:05 +04:00
|
|
|
nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pi) {
|
|
|
|
// No plugin around for this object.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-06 16:30:40 +04:00
|
|
|
JS::Rooted<JSObject*> pi_obj(aCx); // XPConnect-wrapped peer object, when we get it.
|
|
|
|
JS::Rooted<JSObject*> pi_proto(aCx); // 'pi.__proto__'
|
2013-04-10 21:49:05 +04:00
|
|
|
|
2013-07-31 20:20:33 +04:00
|
|
|
rv = GetPluginJSObject(aCx, aObject, pi, &pi_obj, &pi_proto);
|
2013-04-10 21:49:05 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pi_obj) {
|
|
|
|
// Didn't get a plugin instance JSObject, nothing we can do then.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we got an xpconnect-wrapped plugin object, set obj's
|
|
|
|
// prototype's prototype to the scriptable plugin.
|
|
|
|
|
2016-07-09 07:19:52 +03:00
|
|
|
JS::Handle<JSObject*> my_proto = GetDOMClass(aObject)->mGetProto(aCx);
|
2013-04-10 21:49:05 +04:00
|
|
|
MOZ_ASSERT(my_proto);
|
|
|
|
|
|
|
|
// Set 'this.__proto__' to pi
|
|
|
|
if (!::JS_SetPrototype(aCx, aObject, pi_obj)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-04 11:50:50 +04:00
|
|
|
if (pi_proto && js::GetObjectClass(pi_proto) != js::ObjectClassPtr) {
|
2013-04-10 21:49:05 +04:00
|
|
|
// The plugin wrapper has a proto that's not Object.prototype, set
|
|
|
|
// 'pi.__proto__.__proto__' to the original 'this.__proto__'
|
|
|
|
if (pi_proto != my_proto && !::JS_SetPrototype(aCx, pi_proto, my_proto)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// 'pi' didn't have a prototype, or pi's proto was
|
|
|
|
// 'Object.prototype' (i.e. pi is an NPRuntime wrapped JS object)
|
|
|
|
// set 'pi.__proto__' to the original 'this.__proto__'
|
|
|
|
if (!::JS_SetPrototype(aCx, pi_obj, my_proto)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Before this proto dance the objects involved looked like this:
|
|
|
|
//
|
|
|
|
// this.__proto__.__proto__
|
|
|
|
// ^ ^ ^
|
|
|
|
// | | |__ Object.prototype
|
|
|
|
// | |
|
|
|
|
// | |__ WebIDL prototype (shared)
|
|
|
|
// |
|
|
|
|
// |__ WebIDL object
|
|
|
|
//
|
|
|
|
// pi.__proto__
|
|
|
|
// ^ ^
|
|
|
|
// | |__ Object.prototype or some other object
|
|
|
|
// |
|
|
|
|
// |__ Plugin NPRuntime JS object wrapper
|
|
|
|
//
|
|
|
|
// Now, after the above prototype setup the prototype chain should
|
|
|
|
// look like this if pi.__proto__ was Object.prototype:
|
|
|
|
//
|
|
|
|
// this.__proto__.__proto__.__proto__
|
|
|
|
// ^ ^ ^ ^
|
|
|
|
// | | | |__ Object.prototype
|
|
|
|
// | | |
|
|
|
|
// | | |__ WebIDL prototype (shared)
|
|
|
|
// | |
|
|
|
|
// | |__ Plugin NPRuntime JS object wrapper
|
|
|
|
// |
|
|
|
|
// |__ WebIDL object
|
|
|
|
//
|
|
|
|
// or like this if pi.__proto__ was some other object:
|
|
|
|
//
|
|
|
|
// this.__proto__.__proto__.__proto__.__proto__
|
|
|
|
// ^ ^ ^ ^ ^
|
|
|
|
// | | | | |__ Object.prototype
|
|
|
|
// | | | |
|
|
|
|
// | | | |__ WebIDL prototype (shared)
|
|
|
|
// | | |
|
|
|
|
// | | |__ old pi.__proto__
|
|
|
|
// | |
|
|
|
|
// | |__ Plugin NPRuntime JS object wrapper
|
|
|
|
// |
|
|
|
|
// |__ WebIDL object
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
2013-05-08 06:34:56 +04:00
|
|
|
nsObjectLoadingContent::GetPluginJSObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> obj,
|
2013-04-10 21:49:05 +04:00
|
|
|
nsNPAPIPluginInstance *plugin_inst,
|
2013-07-31 20:20:33 +04:00
|
|
|
JS::MutableHandle<JSObject*> plugin_obj,
|
|
|
|
JS::MutableHandle<JSObject*> plugin_proto)
|
2013-04-10 21:49:05 +04:00
|
|
|
{
|
|
|
|
// NB: We need an AutoEnterCompartment because we can be called from
|
2014-09-24 08:34:00 +04:00
|
|
|
// nsPluginFrame when the plugin loads after the JS object for our content
|
2013-04-10 21:49:05 +04:00
|
|
|
// node has been created.
|
|
|
|
JSAutoCompartment ac(cx, obj);
|
|
|
|
|
|
|
|
if (plugin_inst) {
|
2013-07-31 20:20:33 +04:00
|
|
|
plugin_inst->GetJSObject(cx, plugin_obj.address());
|
|
|
|
if (plugin_obj) {
|
|
|
|
if (!::JS_GetPrototype(cx, plugin_obj, plugin_proto)) {
|
2013-04-10 21:49:05 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
2013-03-04 23:08:23 +04:00
|
|
|
}
|
2013-04-10 21:49:05 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2013-03-04 23:08:23 +04:00
|
|
|
}
|
|
|
|
|
2013-03-15 05:23:31 +04:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::TeardownProtoChain()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
|
2016-03-18 17:48:38 +03:00
|
|
|
NS_ENSURE_TRUE_VOID(thisContent->GetWrapper());
|
|
|
|
|
|
|
|
// We don't init the AutoJSAPI with our wrapper because we don't want it
|
|
|
|
// reporting errors to our window's onerror listeners.
|
|
|
|
AutoJSAPI jsapi;
|
|
|
|
jsapi.Init();
|
|
|
|
JSContext* cx = jsapi.cx();
|
2013-05-02 13:12:45 +04:00
|
|
|
JS::Rooted<JSObject*> obj(cx, thisContent->GetWrapper());
|
2016-03-18 17:48:38 +03:00
|
|
|
MOZ_ASSERT(obj);
|
2013-03-15 05:23:31 +04:00
|
|
|
|
2013-05-02 13:12:47 +04:00
|
|
|
JS::Rooted<JSObject*> proto(cx);
|
2013-03-15 05:23:31 +04:00
|
|
|
JSAutoCompartment ac(cx, obj);
|
|
|
|
|
|
|
|
// Loop over the DOM element's JS object prototype chain and remove
|
|
|
|
// all JS objects of the class sNPObjectJSWrapperClass
|
2013-08-06 05:35:08 +04:00
|
|
|
DebugOnly<bool> removed = false;
|
2013-03-15 05:23:31 +04:00
|
|
|
while (obj) {
|
2013-07-31 20:20:33 +04:00
|
|
|
if (!::JS_GetPrototype(cx, obj, &proto)) {
|
2013-03-15 05:23:31 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!proto) {
|
|
|
|
break;
|
|
|
|
}
|
2014-11-05 19:37:16 +03:00
|
|
|
// Unwrap while checking the class - if the prototype is a wrapper for
|
2013-03-15 05:23:31 +04:00
|
|
|
// an NP object, that counts too.
|
2014-11-05 19:37:16 +03:00
|
|
|
if (nsNPObjWrapper::IsWrapper(js::UncheckedUnwrap(proto))) {
|
2013-03-15 05:23:31 +04:00
|
|
|
// We found an NPObject on the proto chain, get its prototype...
|
2013-07-31 20:20:33 +04:00
|
|
|
if (!::JS_GetPrototype(cx, proto, &proto)) {
|
2013-03-15 05:23:31 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(!removed, "more than one NPObject in prototype chain");
|
|
|
|
removed = true;
|
|
|
|
|
|
|
|
// ... and pull it out of the chain.
|
|
|
|
::JS_SetPrototype(cx, obj, proto);
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = proto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-04 23:08:23 +04:00
|
|
|
bool
|
2014-11-08 03:07:12 +03:00
|
|
|
nsObjectLoadingContent::DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
|
|
|
JS::Handle<jsid> aId,
|
2016-01-28 13:28:04 +03:00
|
|
|
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
2013-03-04 23:08:23 +04:00
|
|
|
{
|
2014-02-05 01:53:32 +04:00
|
|
|
// We don't resolve anything; we just try to make sure we're instantiated.
|
|
|
|
// This purposefully does not fire for chrome/xray resolves, see bug 967694
|
2013-03-04 23:08:23 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pi;
|
2013-04-10 21:49:05 +04:00
|
|
|
nsresult rv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi));
|
2013-03-04 23:08:23 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-09-09 07:29:21 +04:00
|
|
|
return mozilla::dom::Throw(aCx, rv);
|
2013-03-04 23:08:23 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2013-04-10 21:49:05 +04:00
|
|
|
|
2015-04-28 19:25:55 +03:00
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::MayResolve(jsid aId)
|
|
|
|
{
|
|
|
|
// We can resolve anything, really.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-04 07:38:54 +04:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::GetOwnPropertyNames(JSContext* aCx,
|
2017-06-07 04:21:45 +03:00
|
|
|
JS::AutoIdVector& /* unused */,
|
2017-06-13 05:17:03 +03:00
|
|
|
bool /* unused */,
|
2013-08-04 07:38:54 +04:00
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2014-11-08 03:07:12 +03:00
|
|
|
// Just like DoResolve, just make sure we're instantiated. That will do
|
2014-02-05 01:53:32 +04:00
|
|
|
// the work our Enumerate hook needs to do. This purposefully does not fire
|
|
|
|
// for xray resolves, see bug 967694
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pi;
|
2013-08-04 07:38:54 +04:00
|
|
|
aRv = ScriptRequestPluginInstance(aCx, getter_AddRefs(pi));
|
|
|
|
}
|
|
|
|
|
2016-06-23 07:32:23 +03:00
|
|
|
void
|
|
|
|
nsObjectLoadingContent::MaybeFireErrorEvent()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
// Queue a task to fire an error event if we're an <object> element. The
|
|
|
|
// queueing is important, since then we don't have to worry about reentry.
|
|
|
|
if (thisContent->IsHTMLElement(nsGkAtoms::object)) {
|
|
|
|
RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
|
|
|
|
new LoadBlockingAsyncEventDispatcher(thisContent,
|
|
|
|
NS_LITERAL_STRING("error"),
|
|
|
|
false, false);
|
|
|
|
loadBlockingAsyncDispatcher->PostDOMEvent();
|
|
|
|
}
|
|
|
|
}
|
2013-08-04 07:38:54 +04:00
|
|
|
|
2017-02-09 02:19:01 +03:00
|
|
|
bool
|
|
|
|
nsObjectLoadingContent::BlockEmbedOrObjectContentLoading()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> thisContent =
|
|
|
|
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
|
|
|
|
|
|
|
// Traverse up the node tree to see if we have any ancestors that may block us
|
|
|
|
// from loading
|
|
|
|
for (nsIContent* parent = thisContent->GetParent();
|
|
|
|
parent;
|
|
|
|
parent = parent->GetParent()) {
|
|
|
|
if (parent->IsAnyOfHTMLElements(nsGkAtoms::video, nsGkAtoms::audio)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// If we have an ancestor that is an object with a source, it'll have an
|
|
|
|
// associated displayed type. If that type is not null, don't load content
|
|
|
|
// for the embed.
|
|
|
|
if (HTMLObjectElement* object = HTMLObjectElement::FromContent(parent)) {
|
|
|
|
uint32_t type = object->DisplayedType();
|
|
|
|
if (type != eType_Null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-10 21:49:05 +04:00
|
|
|
// SetupProtoChainRunner implementation
|
|
|
|
nsObjectLoadingContent::SetupProtoChainRunner::SetupProtoChainRunner(
|
|
|
|
nsObjectLoadingContent* aContent)
|
2014-07-15 15:34:42 +04:00
|
|
|
: mContent(aContent)
|
2013-04-10 21:49:05 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsObjectLoadingContent::SetupProtoChainRunner::Run()
|
|
|
|
{
|
2014-07-15 15:34:42 +04:00
|
|
|
AutoJSAPI jsapi;
|
|
|
|
jsapi.Init();
|
|
|
|
JSContext* cx = jsapi.cx();
|
2013-04-10 21:49:05 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
CallQueryInterface(mContent.get(), getter_AddRefs(content));
|
2013-05-02 13:12:45 +04:00
|
|
|
JS::Rooted<JSObject*> obj(cx, content->GetWrapper());
|
2013-04-10 21:49:05 +04:00
|
|
|
if (!obj) {
|
|
|
|
// No need to set up our proto chain if we don't even have an object
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsObjectLoadingContent* objectLoadingContent =
|
|
|
|
static_cast<nsObjectLoadingContent*>(mContent.get());
|
|
|
|
objectLoadingContent->SetupProtoChain(cx, obj);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsObjectLoadingContent::SetupProtoChainRunner, nsIRunnable)
|