2006-08-12 02:13:24 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-09-21 19:14:30 +00:00
|
|
|
// vim:set et cin sw=2 sts=2:
|
2012-05-21 11:12:37 +00: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/. */
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2006-03-31 08:00:42 +00:00
|
|
|
/*
|
2010-01-05 18:30:00 +00:00
|
|
|
* A base class implementing nsIObjectLoadingContent for use by
|
2006-03-31 08:20:34 +00:00
|
|
|
* various content nodes that want to provide plugin/document/image
|
|
|
|
* loading functionality (eg <embed>, <object>, <applet>, etc).
|
2006-03-31 08:00:42 +00:00
|
|
|
*/
|
2005-09-21 19:14:30 +00:00
|
|
|
|
|
|
|
#ifndef NSOBJECTLOADINGCONTENT_H_
|
|
|
|
#define NSOBJECTLOADINGCONTENT_H_
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2005-09-21 19:14:30 +00:00
|
|
|
#include "nsImageLoadingContent.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIChannelEventSink.h"
|
|
|
|
#include "nsIObjectLoadingContent.h"
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsIRunnable.h"
|
2012-01-31 21:55:54 +00:00
|
|
|
#include "nsIThreadInternal.h"
|
2012-08-06 03:00:56 +00:00
|
|
|
#include "nsIFrame.h"
|
2013-02-01 11:00:41 +00:00
|
|
|
#include "nsIFrameLoader.h"
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2008-06-27 19:54:27 +00:00
|
|
|
class nsAsyncInstantiateEvent;
|
2012-01-31 21:55:54 +00:00
|
|
|
class nsStopPluginRunnable;
|
2008-06-27 19:54:27 +00:00
|
|
|
class AutoSetInstantiatingToFalse;
|
2014-09-24 04:34:00 +00:00
|
|
|
class nsPluginFrame;
|
2013-02-01 11:00:41 +00:00
|
|
|
class nsFrameLoader;
|
2013-03-04 19:08:24 +00:00
|
|
|
class nsXULElement;
|
2013-08-27 05:05:29 +00:00
|
|
|
class nsPluginInstanceOwner;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2013-10-01 21:00:38 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
template<typename T> class Sequence;
|
2014-08-15 21:17:35 +00:00
|
|
|
struct MozPluginParameter;
|
2013-10-01 21:00:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
class nsObjectLoadingContent : public nsImageLoadingContent
|
|
|
|
, public nsIStreamListener
|
|
|
|
, public nsIFrameLoaderOwner
|
|
|
|
, public nsIObjectLoadingContent
|
|
|
|
, public nsIChannelEventSink
|
|
|
|
{
|
2005-12-03 11:27:42 +00:00
|
|
|
friend class AutoSetInstantiatingToFalse;
|
2012-07-05 21:07:46 +00:00
|
|
|
friend class AutoSetLoadingToFalse;
|
2012-09-07 00:16:02 +00:00
|
|
|
friend class CheckPluginStopEvent;
|
2012-01-31 21:55:54 +00:00
|
|
|
friend class nsStopPluginRunnable;
|
|
|
|
friend class nsAsyncInstantiateEvent;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// This enum's values must be the same as the constants on
|
|
|
|
// nsIObjectLoadingContent
|
|
|
|
enum ObjectType {
|
2012-07-05 21:07:46 +00:00
|
|
|
// Loading, type not yet known. We may be waiting for a channel to open.
|
|
|
|
eType_Loading = TYPE_LOADING,
|
|
|
|
// Content is a *non-svg* image
|
|
|
|
eType_Image = TYPE_IMAGE,
|
|
|
|
// Content is a plugin
|
|
|
|
eType_Plugin = TYPE_PLUGIN,
|
|
|
|
// Content is a subdocument, possibly SVG
|
|
|
|
eType_Document = TYPE_DOCUMENT,
|
|
|
|
// No content loaded (fallback). May be showing alternate content or
|
|
|
|
// a custom error handler - *including* click-to-play dialogs
|
|
|
|
eType_Null = TYPE_NULL
|
2012-07-05 20:47:39 +00:00
|
|
|
};
|
2012-07-05 20:47:39 +00:00
|
|
|
enum FallbackType {
|
2012-08-20 22:00:51 +00:00
|
|
|
// The content type is not supported (e.g. plugin not installed)
|
|
|
|
eFallbackUnsupported = nsIObjectLoadingContent::PLUGIN_UNSUPPORTED,
|
|
|
|
// Showing alternate content
|
|
|
|
eFallbackAlternate = nsIObjectLoadingContent::PLUGIN_ALTERNATE,
|
|
|
|
// The plugin exists, but is disabled
|
|
|
|
eFallbackDisabled = nsIObjectLoadingContent::PLUGIN_DISABLED,
|
|
|
|
// The plugin is blocklisted and disabled
|
|
|
|
eFallbackBlocklisted = nsIObjectLoadingContent::PLUGIN_BLOCKLISTED,
|
|
|
|
// The plugin is considered outdated, but not disabled
|
|
|
|
eFallbackOutdated = nsIObjectLoadingContent::PLUGIN_OUTDATED,
|
|
|
|
// The plugin has crashed
|
|
|
|
eFallbackCrashed = nsIObjectLoadingContent::PLUGIN_CRASHED,
|
|
|
|
// Suppressed by security policy
|
|
|
|
eFallbackSuppressed = nsIObjectLoadingContent::PLUGIN_SUPPRESSED,
|
|
|
|
// Blocked by content policy
|
|
|
|
eFallbackUserDisabled = nsIObjectLoadingContent::PLUGIN_USER_DISABLED,
|
2012-10-04 19:57:24 +00:00
|
|
|
/// ** All values >= eFallbackClickToPlay are plugin placeholder types
|
|
|
|
/// that would be replaced by a real plugin if activated (PlayPlugin())
|
2012-12-05 21:00:52 +00:00
|
|
|
/// ** Furthermore, values >= eFallbackClickToPlay and
|
|
|
|
/// <= eFallbackVulnerableNoUpdate are click-to-play types.
|
2012-08-20 22:00:51 +00:00
|
|
|
// The plugin is disabled until the user clicks on it
|
|
|
|
eFallbackClickToPlay = nsIObjectLoadingContent::PLUGIN_CLICK_TO_PLAY,
|
|
|
|
// The plugin is vulnerable (update available)
|
|
|
|
eFallbackVulnerableUpdatable = nsIObjectLoadingContent::PLUGIN_VULNERABLE_UPDATABLE,
|
|
|
|
// The plugin is vulnerable (no update available)
|
2012-08-25 21:18:44 +00:00
|
|
|
eFallbackVulnerableNoUpdate = nsIObjectLoadingContent::PLUGIN_VULNERABLE_NO_UPDATE,
|
|
|
|
// The plugin is disabled and play preview content is displayed until
|
|
|
|
// the extension code enables it by sending the MozPlayPlugin event
|
|
|
|
eFallbackPlayPreview = nsIObjectLoadingContent::PLUGIN_PLAY_PREVIEW
|
2012-07-05 20:47:39 +00:00
|
|
|
};
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2005-10-31 18:28:56 +00:00
|
|
|
nsObjectLoadingContent();
|
2005-09-21 19:14:30 +00:00
|
|
|
virtual ~nsObjectLoadingContent();
|
|
|
|
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
NS_DECL_NSIFRAMELOADEROWNER
|
|
|
|
NS_DECL_NSIOBJECTLOADINGCONTENT
|
|
|
|
NS_DECL_NSICHANNELEVENTSINK
|
|
|
|
|
|
|
|
/**
|
2012-07-05 21:07:46 +00:00
|
|
|
* Object state. This is a bitmask of NS_EVENT_STATEs epresenting the
|
|
|
|
* current state of the object.
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2014-04-03 04:18:36 +00:00
|
|
|
mozilla::EventStates ObjectState() const;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-11-10 23:30:15 +00:00
|
|
|
ObjectType Type() const { return mType; }
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetIsNetworkCreated(bool aNetworkCreated)
|
2010-08-17 14:13:55 +00:00
|
|
|
{
|
|
|
|
mNetworkCreated = aNetworkCreated;
|
|
|
|
}
|
2012-01-31 21:55:54 +00:00
|
|
|
|
2014-08-15 21:17:35 +00:00
|
|
|
/**
|
|
|
|
* When the object is loaded, the attributes and all nested <param>
|
|
|
|
* elements are cached as name:value string pairs to be passed as
|
|
|
|
* parameters when instantiating the plugin.
|
|
|
|
*
|
|
|
|
* Note: these cached values can be overriden for different quirk cases.
|
|
|
|
*/
|
|
|
|
// Returns the cached attributes array.
|
|
|
|
void GetPluginAttributes(nsTArray<mozilla::dom::MozPluginParameter>& aAttributes);
|
|
|
|
|
|
|
|
// Returns the cached <param> array.
|
|
|
|
void GetPluginParameters(nsTArray<mozilla::dom::MozPluginParameter>& aParameters);
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
/**
|
2012-12-06 23:10:54 +00:00
|
|
|
* Immediately instantiate a plugin instance. This is a no-op if mType !=
|
|
|
|
* eType_Plugin or a plugin is already running.
|
|
|
|
*
|
|
|
|
* aIsLoading indicates that we are in the loading code, and we can bypass
|
|
|
|
* the mIsLoading check.
|
2012-07-05 21:07:46 +00:00
|
|
|
*/
|
2012-12-06 23:10:54 +00:00
|
|
|
nsresult InstantiatePluginInstance(bool aIsLoading = false);
|
2012-01-31 21:55:54 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
/**
|
|
|
|
* Notify this class the document state has changed
|
|
|
|
* Called by nsDocument so we may suspend plugins in inactive documents)
|
|
|
|
*/
|
2012-01-31 21:55:54 +00:00
|
|
|
void NotifyOwnerDocumentActivityChanged();
|
|
|
|
|
2013-03-04 19:08:23 +00:00
|
|
|
/**
|
|
|
|
* When a plug-in is instantiated, it can create a scriptable
|
|
|
|
* object that the page wants to interact with. We expose this
|
|
|
|
* object by placing it on the prototype chain of our element,
|
|
|
|
* between the element itself and its most-derived DOM prototype.
|
|
|
|
*
|
|
|
|
* SetupProtoChain handles actually inserting the plug-in
|
|
|
|
* scriptable object into the proto chain if needed.
|
|
|
|
*
|
2014-11-08 00:07:12 +00:00
|
|
|
* DoResolve is a hook that allows us to find out when the web
|
2013-03-04 19:08:23 +00:00
|
|
|
* page is looking up a property name on our object and make sure
|
|
|
|
* that our plug-in, if any, is instantiated.
|
|
|
|
*/
|
|
|
|
// Helper for WebIDL node wrapping
|
2013-05-02 09:12:45 +00:00
|
|
|
void SetupProtoChain(JSContext* aCx, JS::Handle<JSObject*> aObject);
|
2013-03-04 19:08:23 +00:00
|
|
|
|
2013-03-15 01:23:31 +00:00
|
|
|
// Remove plugin from protochain
|
|
|
|
void TeardownProtoChain();
|
|
|
|
|
2014-11-08 00:07:12 +00:00
|
|
|
// Helper for WebIDL NeedResolve
|
|
|
|
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
|
|
|
|
JS::Handle<jsid> aId,
|
|
|
|
JS::MutableHandle<JSPropertyDescriptor> aDesc);
|
2013-08-04 03:38:54 +00:00
|
|
|
// Helper for WebIDL enumeration
|
|
|
|
void GetOwnPropertyNames(JSContext* aCx, nsTArray<nsString>& /* unused */,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2013-03-04 19:08:23 +00:00
|
|
|
|
2013-03-04 19:08:24 +00:00
|
|
|
// WebIDL API
|
|
|
|
nsIDocument* GetContentDocument();
|
|
|
|
void GetActualType(nsAString& aType) const
|
|
|
|
{
|
|
|
|
CopyUTF8toUTF16(mContentType, aType);
|
|
|
|
}
|
|
|
|
uint32_t DisplayedType() const
|
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
uint32_t GetContentTypeForMIMEType(const nsAString& aMIMEType)
|
|
|
|
{
|
|
|
|
return GetTypeOfContent(NS_ConvertUTF16toUTF8(aMIMEType));
|
|
|
|
}
|
|
|
|
void PlayPlugin(mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = PlayPlugin();
|
|
|
|
}
|
2013-06-18 21:35:26 +00:00
|
|
|
void Reload(bool aClearActivation, mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = Reload(aClearActivation);
|
|
|
|
}
|
2013-03-04 19:08:24 +00:00
|
|
|
bool Activated() const
|
|
|
|
{
|
|
|
|
return mActivated;
|
|
|
|
}
|
|
|
|
nsIURI* GetSrcURI() const
|
|
|
|
{
|
|
|
|
return mURI;
|
|
|
|
}
|
2013-06-24 12:51:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The default state that this plugin would be without manual activation.
|
|
|
|
* @returns PLUGIN_ACTIVE if the default state would be active.
|
|
|
|
*/
|
|
|
|
uint32_t DefaultFallbackType();
|
|
|
|
|
2013-03-04 19:08:24 +00:00
|
|
|
uint32_t PluginFallbackType() const
|
|
|
|
{
|
|
|
|
return mFallbackType;
|
|
|
|
}
|
2013-03-08 00:11:27 +00:00
|
|
|
bool HasRunningPlugin() const
|
|
|
|
{
|
|
|
|
return !!mInstanceOwner;
|
|
|
|
}
|
2013-03-04 19:08:24 +00:00
|
|
|
void CancelPlayPreview(mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = CancelPlayPreview();
|
|
|
|
}
|
|
|
|
void SwapFrameLoaders(nsXULElement& aOtherOwner, mozilla::ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
|
|
|
}
|
2014-06-11 20:26:52 +00:00
|
|
|
void LegacyCall(JSContext* aCx, JS::Handle<JS::Value> aThisVal,
|
|
|
|
const mozilla::dom::Sequence<JS::Value>& aArguments,
|
|
|
|
JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::ErrorResult& aRv);
|
2013-03-04 19:08:24 +00:00
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
protected:
|
|
|
|
/**
|
2012-07-05 21:07:46 +00:00
|
|
|
* Begins loading the object when called
|
2005-09-21 19:14:30 +00:00
|
|
|
*
|
2012-07-05 21:07:46 +00:00
|
|
|
* Attributes of |this| QI'd to nsIContent will be inspected, depending on
|
|
|
|
* the node type. This function currently assumes it is a <applet>,
|
|
|
|
* <object>, or <embed> tag.
|
2005-09-21 19:14:30 +00:00
|
|
|
*
|
2012-07-05 21:07:46 +00:00
|
|
|
* The instantiated plugin depends on:
|
|
|
|
* - The URI (<embed src>, <object data>)
|
|
|
|
* - The type 'hint' (type attribute)
|
|
|
|
* - The mime type returned by opening the URI
|
|
|
|
* - Enabled plugins claiming the ultimate mime type
|
|
|
|
* - The capabilities returned by GetCapabilities
|
2005-09-21 19:14:30 +00:00
|
|
|
* - The classid attribute, if eSupportClassID is among the capabilities
|
|
|
|
*
|
2012-07-05 21:07:46 +00:00
|
|
|
* If eAllowPluginSkipChannel is true, we may skip opening the URI if our
|
|
|
|
* type hint points to a valid plugin, deferring that responsibility to the
|
|
|
|
* plugin.
|
|
|
|
* Similarly, if no URI is provided, but a type hint for a valid plugin is
|
|
|
|
* present, that plugin will be instantiated
|
2005-09-21 19:14:30 +00:00
|
|
|
*
|
|
|
|
* Otherwise a request to that URI is made and the type sent by the server
|
2012-07-05 21:07:46 +00:00
|
|
|
* is used to find a suitable handler, EXCEPT when:
|
|
|
|
* - The type hint refers to a *supported* plugin, in which case that
|
|
|
|
* plugin will be instantiated regardless of the server provided type
|
|
|
|
* - The server returns a binary-stream type, and our type hint refers to
|
|
|
|
* a valid non-document type, we will use the type hint
|
2005-09-21 19:14:30 +00:00
|
|
|
*
|
2012-07-05 21:07:46 +00:00
|
|
|
* @param aNotify If we should send notifications. If false, content
|
|
|
|
* loading may be deferred while appropriate frames are
|
|
|
|
* created
|
|
|
|
* @param aForceLoad If we should reload this content (and re-attempt the
|
|
|
|
* channel open) even if our parameters did not change
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2012-07-05 21:07:46 +00:00
|
|
|
nsresult LoadObject(bool aNotify,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aForceLoad = false);
|
2005-09-21 19:14:30 +00:00
|
|
|
|
|
|
|
enum Capabilities {
|
2012-10-20 02:01:43 +00:00
|
|
|
eSupportImages = 1u << 0, // Images are supported (imgILoader)
|
|
|
|
eSupportPlugins = 1u << 1, // Plugins are supported (nsIPluginHost)
|
|
|
|
eSupportDocuments = 1u << 2, // Documents are supported
|
2012-07-05 21:07:46 +00:00
|
|
|
// (nsIDocumentLoaderFactory)
|
|
|
|
// This flag always includes SVG
|
2012-10-20 02:01:43 +00:00
|
|
|
eSupportSVG = 1u << 3, // SVG is supported (image/svg+xml)
|
|
|
|
eSupportClassID = 1u << 4, // The classid attribute is supported
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-12-06 23:10:54 +00:00
|
|
|
// If possible to get a *plugin* type from the type attribute *or* file
|
|
|
|
// extension, we can use that type and begin loading the plugin before
|
|
|
|
// opening a channel.
|
|
|
|
// A side effect of this is if the channel fails, the plugin is still
|
|
|
|
// running.
|
2012-10-20 02:01:43 +00:00
|
|
|
eAllowPluginSkipChannel = 1u << 5
|
2005-09-21 19:14:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of capabilities this content node supports. This is a
|
|
|
|
* bitmask consisting of flags from the Capabilities enum.
|
|
|
|
*
|
2012-07-05 21:07:46 +00:00
|
|
|
* The default implementation supports all types but not
|
|
|
|
* eSupportClassID or eAllowPluginSkipChannel
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual uint32_t GetCapabilities() const;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-07-25 20:39:01 +00:00
|
|
|
/**
|
2012-07-05 21:07:46 +00:00
|
|
|
* Destroys all loaded documents/plugins and releases references
|
2012-07-25 20:39:01 +00:00
|
|
|
*/
|
2012-07-05 21:07:46 +00:00
|
|
|
void DestroyContent();
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2011-08-28 14:07:24 +00:00
|
|
|
static void Traverse(nsObjectLoadingContent *tmp,
|
|
|
|
nsCycleCollectionTraversalCallback &cb);
|
2007-03-08 11:17:16 +00:00
|
|
|
|
2009-12-11 04:02:13 +00:00
|
|
|
void CreateStaticClone(nsObjectLoadingContent* aDest) const;
|
2012-01-31 21:55:54 +00:00
|
|
|
|
2012-05-25 22:34:11 +00:00
|
|
|
void DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner, bool aDelayedStop,
|
|
|
|
bool aForcedReentry = false);
|
2012-01-31 21:55:54 +00:00
|
|
|
|
2012-03-28 15:53:56 +00:00
|
|
|
nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandler);
|
|
|
|
void UnbindFromTree(bool aDeep = true,
|
|
|
|
bool aNullParent = true);
|
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
private:
|
2012-12-06 23:09:10 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// Object parameter changes returned by UpdateObjectParameters
|
|
|
|
enum ParameterUpdateFlags {
|
|
|
|
eParamNoChange = 0,
|
|
|
|
// Parameters that potentially affect the channel changed
|
|
|
|
// - mOriginalURI, mOriginalContentType
|
2012-10-20 02:01:43 +00:00
|
|
|
eParamChannelChanged = 1u << 0,
|
2012-07-05 21:07:46 +00:00
|
|
|
// Parameters that affect displayed content changed
|
|
|
|
// - mURI, mContentType, mType, mBaseURI
|
2012-10-20 02:01:43 +00:00
|
|
|
eParamStateChanged = 1u << 1,
|
2012-10-04 19:57:24 +00:00
|
|
|
// The effective content type changed, independant of object type. This
|
|
|
|
// can happen when changing from Loading -> Final type, but doesn't
|
|
|
|
// necessarily happen when changing between object types. E.g., if a PDF
|
|
|
|
// handler was installed between the last load of this object and now, we
|
|
|
|
// might change from eType_Document -> eType_Plugin without changing
|
|
|
|
// ContentType
|
2012-10-20 02:01:43 +00:00
|
|
|
eParamContentTypeChanged = 1u << 2
|
2012-07-05 21:07:46 +00:00
|
|
|
};
|
|
|
|
|
2014-08-15 21:17:35 +00:00
|
|
|
/**
|
|
|
|
* Getter for child <param> elements that are not nested in another plugin
|
|
|
|
* dom element.
|
|
|
|
* This is an internal helper function and should not be used directly for
|
|
|
|
* passing parameters to the plugin instance.
|
|
|
|
*
|
|
|
|
* See GetPluginParameters and GetPluginAttributes, which also handle
|
|
|
|
* quirk-overrides.
|
|
|
|
*
|
|
|
|
* @param aParameters The array containing pairs of name/value strings
|
|
|
|
* from nested <param> objects.
|
|
|
|
* @param aIgnoreCodebase Flag for ignoring the "codebase" param when
|
|
|
|
* building the array. This is useful when loading
|
|
|
|
* java.
|
|
|
|
*/
|
|
|
|
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters,
|
|
|
|
bool aIgnoreCodebase);
|
|
|
|
|
|
|
|
void BuildParametersArray();
|
|
|
|
|
2012-07-05 20:47:39 +00:00
|
|
|
/**
|
|
|
|
* Loads fallback content with the specified FallbackType
|
|
|
|
*
|
|
|
|
* @param aType FallbackType value for type of fallback we're loading
|
|
|
|
* @param aNotify Send notifications and events. If false, caller is
|
|
|
|
* responsible for doing so
|
|
|
|
*/
|
|
|
|
void LoadFallback(FallbackType aType, bool aNotify);
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
/**
|
|
|
|
* Internal version of LoadObject that should only be used by this class
|
|
|
|
* aLoadingChannel is passed by the LoadObject call from OnStartRequest,
|
|
|
|
* primarily for sanity-preservation
|
|
|
|
*/
|
|
|
|
nsresult LoadObject(bool aNotify,
|
|
|
|
bool aForceLoad,
|
|
|
|
nsIRequest *aLoadingChannel);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Introspects the object and sets the following member variables:
|
|
|
|
* - mOriginalContentType : This is the type attribute on the element
|
|
|
|
* - mOriginalURI : The src or data attribute on the element
|
|
|
|
* - mURI : The final URI, considering mChannel if
|
|
|
|
* mChannelLoaded is set
|
|
|
|
* - mContentType : The final content type, considering mChannel if
|
|
|
|
* mChannelLoaded is set
|
|
|
|
* - mBaseURI : The object's base URI, which may be set by the
|
|
|
|
* object (codebase attribute)
|
|
|
|
* - mType : The type the object is determined to be based
|
|
|
|
* on the above
|
|
|
|
*
|
|
|
|
* NOTE The class assumes that mType is the currently loaded type at various
|
|
|
|
* points, so the caller of this function must take the appropriate
|
|
|
|
* actions to ensure this
|
|
|
|
*
|
|
|
|
* NOTE This function does not perform security checks, only determining the
|
|
|
|
* requested type and parameters of the object.
|
2013-03-25 19:26:38 +00:00
|
|
|
*
|
|
|
|
* @param aJavaURI Specify that the URI will be consumed by java, which
|
|
|
|
* changes codebase parsing and URI construction. Used
|
|
|
|
* internally.
|
|
|
|
*
|
2012-07-05 21:07:46 +00:00
|
|
|
* @return Returns a bitmask of ParameterUpdateFlags values
|
|
|
|
*/
|
2013-03-25 19:26:38 +00:00
|
|
|
ParameterUpdateFlags UpdateObjectParameters(bool aJavaURI = false);
|
2012-01-31 21:55:54 +00:00
|
|
|
|
2013-03-19 00:34:27 +00:00
|
|
|
/**
|
|
|
|
* Queue a CheckPluginStopEvent and track it in mPendingCheckPluginStopEvent
|
|
|
|
*/
|
|
|
|
void QueueCheckPluginStopEvent();
|
|
|
|
|
2012-01-31 21:55:54 +00:00
|
|
|
void NotifyContentObjectWrapper();
|
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
/**
|
2012-07-05 21:07:46 +00:00
|
|
|
* Opens the channel pointed to by mURI into mChannel.
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2012-08-17 01:44:14 +00:00
|
|
|
nsresult OpenChannel();
|
2005-09-21 19:14:30 +00:00
|
|
|
|
|
|
|
/**
|
2012-07-05 21:07:46 +00:00
|
|
|
* Closes and releases references to mChannel and, if opened, mFinalListener
|
|
|
|
*/
|
|
|
|
nsresult CloseChannel();
|
|
|
|
|
2012-07-05 20:47:39 +00:00
|
|
|
/**
|
|
|
|
* If this object is allowed to play plugin content, or if it would display
|
|
|
|
* click-to-play instead.
|
|
|
|
* NOTE that this does not actually check if the object is a loadable plugin
|
2013-06-24 12:51:07 +00:00
|
|
|
* NOTE This ignores the current activated state. The caller should check this if appropriate.
|
2012-07-05 20:47:39 +00:00
|
|
|
*/
|
2013-06-24 12:51:07 +00:00
|
|
|
bool ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentType);
|
2012-07-05 20:47:39 +00:00
|
|
|
|
2013-04-04 21:08:46 +00:00
|
|
|
/*
|
|
|
|
* Helper to check if mBaseURI can be used by java as a codebase
|
|
|
|
*/
|
|
|
|
bool CheckJavaCodebase();
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
/**
|
2012-08-17 01:44:14 +00:00
|
|
|
* Helper to check if our current URI passes policy
|
2012-07-05 21:07:46 +00:00
|
|
|
*
|
2012-08-17 01:44:14 +00:00
|
|
|
* @param aContentPolicy [out] The result of the content policy decision
|
2012-07-05 21:07:46 +00:00
|
|
|
*
|
2012-08-17 01:44:14 +00:00
|
|
|
* @return true if call succeeded and NS_CP_ACCEPTED(*aContentPolicy)
|
2012-07-05 21:07:46 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
bool CheckLoadPolicy(int16_t *aContentPolicy);
|
2012-07-05 21:07:46 +00:00
|
|
|
|
|
|
|
/**
|
2012-08-17 01:44:14 +00:00
|
|
|
* Helper to check if the object passes process policy. Assumes we have a
|
|
|
|
* final determined type.
|
2012-07-05 21:07:46 +00:00
|
|
|
*
|
2012-08-17 01:44:14 +00:00
|
|
|
* @param aContentPolicy [out] The result of the content policy decision
|
2012-07-05 21:07:46 +00:00
|
|
|
*
|
2012-08-17 01:44:14 +00:00
|
|
|
* @return true if call succeeded and NS_CP_ACCEPTED(*aContentPolicy)
|
2012-07-05 21:07:46 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
bool CheckProcessPolicy(int16_t *aContentPolicy);
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-07-05 20:47:39 +00:00
|
|
|
/**
|
2012-07-05 21:07:46 +00:00
|
|
|
* Checks whether the given type is a supported document type
|
|
|
|
*
|
|
|
|
* NOTE Does not take content policy or capabilities into account
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsSupportedDocument(const nsCString& aType);
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-12-06 23:10:54 +00:00
|
|
|
/**
|
|
|
|
* Gets the plugin instance and creates a plugin stream listener, assigning
|
|
|
|
* it to mFinalListener
|
|
|
|
*/
|
|
|
|
bool MakePluginListener();
|
|
|
|
|
2005-09-21 19:14:30 +00:00
|
|
|
/**
|
2012-07-05 20:47:39 +00:00
|
|
|
* Unloads all content and resets the object to a completely unloaded state
|
|
|
|
*
|
|
|
|
* NOTE Calls StopPluginInstance() and may spin the event loop
|
2012-07-05 21:07:46 +00:00
|
|
|
*
|
2012-07-05 20:47:39 +00:00
|
|
|
* @param aResetState Reset the object type to 'loading' and destroy channel
|
|
|
|
* as well
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2012-07-05 20:47:39 +00:00
|
|
|
void UnloadObject(bool aResetState = true);
|
2005-09-21 19:14:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies document observes about a new type/state of this object.
|
|
|
|
* Triggers frame construction as needed. mType must be set correctly when
|
|
|
|
* this method is called. This method is cheap if the type and state didn't
|
|
|
|
* actually change.
|
2005-10-23 20:00:47 +00:00
|
|
|
*
|
|
|
|
* @param aSync If a synchronous frame construction is required. If false,
|
|
|
|
* the construction may either be sync or async.
|
2011-06-01 01:46:57 +00:00
|
|
|
* @param aNotify if false, only need to update the state of our element.
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2014-04-03 04:18:36 +00:00
|
|
|
void NotifyStateChanged(ObjectType aOldType,
|
|
|
|
mozilla::EventStates aOldState,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aSync, bool aNotify);
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
/**
|
|
|
|
* Returns a ObjectType value corresponding to the type of content we would
|
|
|
|
* support the given MIME type as, taking capabilities and plugin state
|
|
|
|
* into account
|
|
|
|
*
|
|
|
|
* NOTE this does not consider whether the content would be suppressed by
|
|
|
|
* click-to-play or other content policy checks
|
|
|
|
*/
|
2005-09-21 19:14:30 +00:00
|
|
|
ObjectType GetTypeOfContent(const nsCString& aMIMEType);
|
|
|
|
|
|
|
|
/**
|
2012-01-31 21:55:54 +00:00
|
|
|
* Gets the frame that's associated with this content node.
|
|
|
|
* Does not flush.
|
2005-09-21 19:14:30 +00:00
|
|
|
*/
|
2014-09-24 04:34:00 +00:00
|
|
|
nsPluginFrame* GetExistingFrame();
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2013-04-10 17:49:05 +00:00
|
|
|
// Helper class for SetupProtoChain
|
|
|
|
class SetupProtoChainRunner MOZ_FINAL : public nsIRunnable
|
|
|
|
{
|
2014-06-25 02:09:15 +00:00
|
|
|
~SetupProtoChainRunner();
|
2013-04-10 17:49:05 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit SetupProtoChainRunner(nsObjectLoadingContent* aContent);
|
2013-04-10 17:49:05 +00:00
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
NS_IMETHOD Run() MOZ_OVERRIDE;
|
2013-04-10 17:49:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// We store an nsIObjectLoadingContent because we can
|
|
|
|
// unambiguously refcount that.
|
|
|
|
nsRefPtr<nsIObjectLoadingContent> mContent;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Utility getter for getting our nsNPAPIPluginInstance in a safe way.
|
|
|
|
nsresult ScriptRequestPluginInstance(JSContext* aCx,
|
|
|
|
nsNPAPIPluginInstance** aResult);
|
|
|
|
|
|
|
|
// Utility method for getting our plugin JSObject
|
2013-05-08 02:34:56 +00:00
|
|
|
static nsresult GetPluginJSObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> obj,
|
2013-04-10 17:49:05 +00:00
|
|
|
nsNPAPIPluginInstance *plugin_inst,
|
2013-07-31 16:20:33 +00:00
|
|
|
JS::MutableHandle<JSObject*> plugin_obj,
|
|
|
|
JS::MutableHandle<JSObject*> plugin_proto);
|
2013-04-10 17:49:05 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// The final listener for mChannel (uriloader, pluginstreamlistener, etc.)
|
2012-07-25 20:39:01 +00:00
|
|
|
nsCOMPtr<nsIStreamListener> mFinalListener;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// Frame loader, for content documents we load.
|
2012-07-25 20:39:01 +00:00
|
|
|
nsRefPtr<nsFrameLoader> mFrameLoader;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2013-03-12 23:13:46 +00:00
|
|
|
// Track if we have a pending AsyncInstantiateEvent
|
|
|
|
nsCOMPtr<nsIRunnable> mPendingInstantiateEvent;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-09-07 00:16:02 +00:00
|
|
|
// Tracks if we have a pending CheckPluginStopEvent
|
|
|
|
nsCOMPtr<nsIRunnable> mPendingCheckPluginStopEvent;
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// The content type of our current load target, updated by
|
|
|
|
// UpdateObjectParameters(). Takes the channel's type into account once
|
|
|
|
// opened.
|
|
|
|
//
|
|
|
|
// May change if a channel is opened, does not imply a loaded state
|
2012-07-25 20:39:01 +00:00
|
|
|
nsCString mContentType;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// The content type 'hint' provided by the element's type attribute. May
|
|
|
|
// or may not be used as a final type
|
|
|
|
nsCString mOriginalContentType;
|
2005-09-21 19:14:30 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// The channel that's currently being loaded. If set, but mChannelLoaded is
|
|
|
|
// false, has not yet reached OnStartRequest
|
2012-07-05 20:47:39 +00:00
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
|
|
|
// The URI of the current content.
|
|
|
|
// May change as we open channels and encounter redirects - does not imply
|
|
|
|
// a loaded type
|
2012-07-25 20:39:01 +00:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// The original URI obtained from inspecting the element (codebase, and
|
|
|
|
// src/data). May differ from mURI due to redirects
|
|
|
|
nsCOMPtr<nsIURI> mOriginalURI;
|
|
|
|
|
|
|
|
// The baseURI used for constructing mURI, and used by some plugins (java)
|
|
|
|
// as a root for other resource requests.
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-07-05 20:47:39 +00:00
|
|
|
// Type of the currently-loaded content.
|
|
|
|
ObjectType mType : 8;
|
|
|
|
// The type of fallback content we're showing (see ObjectState())
|
|
|
|
FallbackType mFallbackType : 8;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2012-12-06 23:10:54 +00:00
|
|
|
// If true, we have opened a channel as the listener and it has reached
|
|
|
|
// OnStartRequest. Does not get set for channels that are passed directly to
|
|
|
|
// the plugin listener.
|
2012-07-05 21:07:46 +00:00
|
|
|
bool mChannelLoaded : 1;
|
|
|
|
|
|
|
|
// Whether we are about to call instantiate on our frame. If we aren't,
|
|
|
|
// SetFrame needs to asynchronously call Instantiate.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInstantiating : 1;
|
2012-07-05 21:07:46 +00:00
|
|
|
|
2010-08-17 14:13:55 +00:00
|
|
|
// True when the object is created for an element which the parser has
|
|
|
|
// created using NS_FROM_PARSER_NETWORK flag. If the element is modified,
|
|
|
|
// it may lose the flag.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mNetworkCreated : 1;
|
2010-08-17 14:13:55 +00:00
|
|
|
|
2012-07-05 20:47:39 +00:00
|
|
|
// Used to keep track of whether or not a plugin has been explicitly
|
|
|
|
// activated by PlayPlugin(). (see ShouldPlay())
|
2012-03-28 15:53:56 +00:00
|
|
|
bool mActivated : 1;
|
|
|
|
|
2012-08-25 21:18:44 +00:00
|
|
|
// Used to keep track of whether or not a plugin is blocked by play-preview.
|
|
|
|
bool mPlayPreviewCanceled : 1;
|
|
|
|
|
2012-05-25 22:34:11 +00:00
|
|
|
// Protects DoStopPlugin from reentry (bug 724781).
|
|
|
|
bool mIsStopping : 1;
|
|
|
|
|
2012-07-05 21:07:46 +00:00
|
|
|
// Protects LoadObject from re-entry
|
|
|
|
bool mIsLoading : 1;
|
|
|
|
|
2012-12-07 22:50:10 +00:00
|
|
|
// For plugin stand-in types (click-to-play, play preview, ...) tracks
|
|
|
|
// whether content js has tried to access the plugin script object.
|
|
|
|
bool mScriptRequested : 1;
|
|
|
|
|
2009-12-11 04:02:13 +00:00
|
|
|
nsWeakFrame mPrintFrame;
|
|
|
|
|
2012-01-31 21:55:54 +00:00
|
|
|
nsRefPtr<nsPluginInstanceOwner> mInstanceOwner;
|
2014-08-15 21:17:35 +00:00
|
|
|
nsTArray<mozilla::dom::MozPluginParameter> mCachedAttributes;
|
|
|
|
nsTArray<mozilla::dom::MozPluginParameter> mCachedParameters;
|
2005-09-21 19:14:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|