content/base/src/nsObjectLoadingContent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/nsObjectLoadingContent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,585 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +// vim:set et cin sw=2 sts=2:
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/*
    1.11 + * A base class implementing nsIObjectLoadingContent for use by
    1.12 + * various content nodes that want to provide plugin/document/image
    1.13 + * loading functionality (eg <embed>, <object>, <applet>, etc).
    1.14 + */
    1.15 +
    1.16 +#ifndef NSOBJECTLOADINGCONTENT_H_
    1.17 +#define NSOBJECTLOADINGCONTENT_H_
    1.18 +
    1.19 +#include "mozilla/Attributes.h"
    1.20 +#include "nsImageLoadingContent.h"
    1.21 +#include "nsIStreamListener.h"
    1.22 +#include "nsIChannelEventSink.h"
    1.23 +#include "nsIObjectLoadingContent.h"
    1.24 +#include "nsIRunnable.h"
    1.25 +#include "nsIThreadInternal.h"
    1.26 +#include "nsIFrame.h"
    1.27 +#include "nsIFrameLoader.h"
    1.28 +
    1.29 +class nsAsyncInstantiateEvent;
    1.30 +class nsStopPluginRunnable;
    1.31 +class AutoSetInstantiatingToFalse;
    1.32 +class nsObjectFrame;
    1.33 +class nsFrameLoader;
    1.34 +class nsXULElement;
    1.35 +class nsPluginInstanceOwner;
    1.36 +
    1.37 +namespace mozilla {
    1.38 +namespace dom {
    1.39 +template<typename T> class Sequence;
    1.40 +}
    1.41 +}
    1.42 +
    1.43 +class nsObjectLoadingContent : public nsImageLoadingContent
    1.44 +                             , public nsIStreamListener
    1.45 +                             , public nsIFrameLoaderOwner
    1.46 +                             , public nsIObjectLoadingContent
    1.47 +                             , public nsIChannelEventSink
    1.48 +{
    1.49 +  friend class AutoSetInstantiatingToFalse;
    1.50 +  friend class AutoSetLoadingToFalse;
    1.51 +  friend class CheckPluginStopEvent;
    1.52 +  friend class nsStopPluginRunnable;
    1.53 +  friend class nsAsyncInstantiateEvent;
    1.54 +
    1.55 +  public:
    1.56 +    // This enum's values must be the same as the constants on
    1.57 +    // nsIObjectLoadingContent
    1.58 +    enum ObjectType {
    1.59 +      // Loading, type not yet known. We may be waiting for a channel to open.
    1.60 +      eType_Loading        = TYPE_LOADING,
    1.61 +      // Content is a *non-svg* image
    1.62 +      eType_Image          = TYPE_IMAGE,
    1.63 +      // Content is a plugin
    1.64 +      eType_Plugin         = TYPE_PLUGIN,
    1.65 +      // Content is a subdocument, possibly SVG
    1.66 +      eType_Document       = TYPE_DOCUMENT,
    1.67 +      // No content loaded (fallback). May be showing alternate content or
    1.68 +      // a custom error handler - *including* click-to-play dialogs
    1.69 +      eType_Null           = TYPE_NULL
    1.70 +    };
    1.71 +    enum FallbackType {
    1.72 +      // The content type is not supported (e.g. plugin not installed)
    1.73 +      eFallbackUnsupported = nsIObjectLoadingContent::PLUGIN_UNSUPPORTED,
    1.74 +      // Showing alternate content
    1.75 +      eFallbackAlternate = nsIObjectLoadingContent::PLUGIN_ALTERNATE,
    1.76 +      // The plugin exists, but is disabled
    1.77 +      eFallbackDisabled = nsIObjectLoadingContent::PLUGIN_DISABLED,
    1.78 +      // The plugin is blocklisted and disabled
    1.79 +      eFallbackBlocklisted = nsIObjectLoadingContent::PLUGIN_BLOCKLISTED,
    1.80 +      // The plugin is considered outdated, but not disabled
    1.81 +      eFallbackOutdated = nsIObjectLoadingContent::PLUGIN_OUTDATED,
    1.82 +      // The plugin has crashed
    1.83 +      eFallbackCrashed = nsIObjectLoadingContent::PLUGIN_CRASHED,
    1.84 +      // Suppressed by security policy
    1.85 +      eFallbackSuppressed = nsIObjectLoadingContent::PLUGIN_SUPPRESSED,
    1.86 +      // Blocked by content policy
    1.87 +      eFallbackUserDisabled = nsIObjectLoadingContent::PLUGIN_USER_DISABLED,
    1.88 +      /// ** All values >= eFallbackClickToPlay are plugin placeholder types
    1.89 +      ///    that would be replaced by a real plugin if activated (PlayPlugin())
    1.90 +      /// ** Furthermore, values >= eFallbackClickToPlay and
    1.91 +      ///    <= eFallbackVulnerableNoUpdate are click-to-play types.
    1.92 +      // The plugin is disabled until the user clicks on it
    1.93 +      eFallbackClickToPlay = nsIObjectLoadingContent::PLUGIN_CLICK_TO_PLAY,
    1.94 +      // The plugin is vulnerable (update available)
    1.95 +      eFallbackVulnerableUpdatable = nsIObjectLoadingContent::PLUGIN_VULNERABLE_UPDATABLE,
    1.96 +      // The plugin is vulnerable (no update available)
    1.97 +      eFallbackVulnerableNoUpdate = nsIObjectLoadingContent::PLUGIN_VULNERABLE_NO_UPDATE,
    1.98 +      // The plugin is disabled and play preview content is displayed until
    1.99 +      // the extension code enables it by sending the MozPlayPlugin event
   1.100 +      eFallbackPlayPreview = nsIObjectLoadingContent::PLUGIN_PLAY_PREVIEW
   1.101 +    };
   1.102 +
   1.103 +    nsObjectLoadingContent();
   1.104 +    virtual ~nsObjectLoadingContent();
   1.105 +
   1.106 +    NS_DECL_NSIREQUESTOBSERVER
   1.107 +    NS_DECL_NSISTREAMLISTENER
   1.108 +    NS_DECL_NSIFRAMELOADEROWNER
   1.109 +    NS_DECL_NSIOBJECTLOADINGCONTENT
   1.110 +    NS_DECL_NSICHANNELEVENTSINK
   1.111 +
   1.112 +    /**
   1.113 +     * Object state. This is a bitmask of NS_EVENT_STATEs epresenting the
   1.114 +     * current state of the object.
   1.115 +     */
   1.116 +    mozilla::EventStates ObjectState() const;
   1.117 +
   1.118 +    ObjectType Type() const { return mType; }
   1.119 +
   1.120 +    void SetIsNetworkCreated(bool aNetworkCreated)
   1.121 +    {
   1.122 +      mNetworkCreated = aNetworkCreated;
   1.123 +    }
   1.124 +
   1.125 +    /**
   1.126 +     * Immediately instantiate a plugin instance. This is a no-op if mType !=
   1.127 +     * eType_Plugin or a plugin is already running.
   1.128 +     *
   1.129 +     * aIsLoading indicates that we are in the loading code, and we can bypass
   1.130 +     * the mIsLoading check.
   1.131 +     */
   1.132 +    nsresult InstantiatePluginInstance(bool aIsLoading = false);
   1.133 +
   1.134 +    /**
   1.135 +     * Notify this class the document state has changed
   1.136 +     * Called by nsDocument so we may suspend plugins in inactive documents)
   1.137 +     */
   1.138 +    void NotifyOwnerDocumentActivityChanged();
   1.139 +
   1.140 +    /**
   1.141 +     * When a plug-in is instantiated, it can create a scriptable
   1.142 +     * object that the page wants to interact with.  We expose this
   1.143 +     * object by placing it on the prototype chain of our element,
   1.144 +     * between the element itself and its most-derived DOM prototype.
   1.145 +     *
   1.146 +     * SetupProtoChain handles actually inserting the plug-in
   1.147 +     * scriptable object into the proto chain if needed.
   1.148 +     *
   1.149 +     * DoNewResolve is a hook that allows us to find out when the web
   1.150 +     * page is looking up a property name on our object and make sure
   1.151 +     * that our plug-in, if any, is instantiated.
   1.152 +     */
   1.153 +    // Helper for WebIDL node wrapping
   1.154 +    void SetupProtoChain(JSContext* aCx, JS::Handle<JSObject*> aObject);
   1.155 +
   1.156 +    // Remove plugin from protochain
   1.157 +    void TeardownProtoChain();
   1.158 +
   1.159 +    // Helper for WebIDL newResolve
   1.160 +    bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
   1.161 +                      JS::Handle<jsid> aId,
   1.162 +                      JS::MutableHandle<JSPropertyDescriptor> aDesc);
   1.163 +    // Helper for WebIDL enumeration
   1.164 +    void GetOwnPropertyNames(JSContext* aCx, nsTArray<nsString>& /* unused */,
   1.165 +                             mozilla::ErrorResult& aRv);
   1.166 +
   1.167 +    // WebIDL API
   1.168 +    nsIDocument* GetContentDocument();
   1.169 +    void GetActualType(nsAString& aType) const
   1.170 +    {
   1.171 +      CopyUTF8toUTF16(mContentType, aType);
   1.172 +    }
   1.173 +    uint32_t DisplayedType() const
   1.174 +    {
   1.175 +      return mType;
   1.176 +    }
   1.177 +    uint32_t GetContentTypeForMIMEType(const nsAString& aMIMEType)
   1.178 +    {
   1.179 +      return GetTypeOfContent(NS_ConvertUTF16toUTF8(aMIMEType));
   1.180 +    }
   1.181 +    void PlayPlugin(mozilla::ErrorResult& aRv)
   1.182 +    {
   1.183 +      aRv = PlayPlugin();
   1.184 +    }
   1.185 +    void Reload(bool aClearActivation, mozilla::ErrorResult& aRv)
   1.186 +    {
   1.187 +      aRv = Reload(aClearActivation);
   1.188 +    }
   1.189 +    bool Activated() const
   1.190 +    {
   1.191 +      return mActivated;
   1.192 +    }
   1.193 +    nsIURI* GetSrcURI() const
   1.194 +    {
   1.195 +      return mURI;
   1.196 +    }
   1.197 +  
   1.198 +    /**
   1.199 +     * The default state that this plugin would be without manual activation.
   1.200 +     * @returns PLUGIN_ACTIVE if the default state would be active.
   1.201 +     */
   1.202 +    uint32_t DefaultFallbackType();
   1.203 +
   1.204 +    uint32_t PluginFallbackType() const
   1.205 +    {
   1.206 +      return mFallbackType;
   1.207 +    }
   1.208 +    bool HasRunningPlugin() const
   1.209 +    {
   1.210 +      return !!mInstanceOwner;
   1.211 +    }
   1.212 +    void CancelPlayPreview(mozilla::ErrorResult& aRv)
   1.213 +    {
   1.214 +      aRv = CancelPlayPreview();
   1.215 +    }
   1.216 +    void SwapFrameLoaders(nsXULElement& aOtherOwner, mozilla::ErrorResult& aRv)
   1.217 +    {
   1.218 +      aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
   1.219 +    }
   1.220 +    void LegacyCall(JSContext* aCx, JS::Handle<JS::Value> aThisVal,
   1.221 +                    const mozilla::dom::Sequence<JS::Value>& aArguments,
   1.222 +                    JS::MutableHandle<JS::Value> aRetval,
   1.223 +                    mozilla::ErrorResult& aRv);
   1.224 +
   1.225 +  protected:
   1.226 +    /**
   1.227 +     * Begins loading the object when called
   1.228 +     *
   1.229 +     * Attributes of |this| QI'd to nsIContent will be inspected, depending on
   1.230 +     * the node type. This function currently assumes it is a <applet>,
   1.231 +     * <object>, or <embed> tag.
   1.232 +     *
   1.233 +     * The instantiated plugin depends on:
   1.234 +     * - The URI (<embed src>, <object data>)
   1.235 +     * - The type 'hint' (type attribute)
   1.236 +     * - The mime type returned by opening the URI
   1.237 +     * - Enabled plugins claiming the ultimate mime type
   1.238 +     * - The capabilities returned by GetCapabilities
   1.239 +     * - The classid attribute, if eSupportClassID is among the capabilities
   1.240 +     *
   1.241 +     * If eAllowPluginSkipChannel is true, we may skip opening the URI if our
   1.242 +     * type hint points to a valid plugin, deferring that responsibility to the
   1.243 +     * plugin.
   1.244 +     * Similarly, if no URI is provided, but a type hint for a valid plugin is
   1.245 +     * present, that plugin will be instantiated
   1.246 +     *
   1.247 +     * Otherwise a request to that URI is made and the type sent by the server
   1.248 +     * is used to find a suitable handler, EXCEPT when:
   1.249 +     *  - The type hint refers to a *supported* plugin, in which case that
   1.250 +     *    plugin will be instantiated regardless of the server provided type
   1.251 +     *  - The server returns a binary-stream type, and our type hint refers to
   1.252 +     *    a valid non-document type, we will use the type hint
   1.253 +     *
   1.254 +     * @param aNotify    If we should send notifications. If false, content
   1.255 +     *                   loading may be deferred while appropriate frames are
   1.256 +     *                   created
   1.257 +     * @param aForceLoad If we should reload this content (and re-attempt the
   1.258 +     *                   channel open) even if our parameters did not change
   1.259 +     */
   1.260 +    nsresult LoadObject(bool aNotify,
   1.261 +                        bool aForceLoad = false);
   1.262 +
   1.263 +    enum Capabilities {
   1.264 +      eSupportImages       = 1u << 0, // Images are supported (imgILoader)
   1.265 +      eSupportPlugins      = 1u << 1, // Plugins are supported (nsIPluginHost)
   1.266 +      eSupportDocuments    = 1u << 2, // Documents are supported
   1.267 +                                        // (nsIDocumentLoaderFactory)
   1.268 +                                        // This flag always includes SVG
   1.269 +      eSupportSVG          = 1u << 3, // SVG is supported (image/svg+xml)
   1.270 +      eSupportClassID      = 1u << 4, // The classid attribute is supported
   1.271 +
   1.272 +      // If possible to get a *plugin* type from the type attribute *or* file
   1.273 +      // extension, we can use that type and begin loading the plugin before
   1.274 +      // opening a channel.
   1.275 +      // A side effect of this is if the channel fails, the plugin is still
   1.276 +      // running.
   1.277 +      eAllowPluginSkipChannel  = 1u << 5
   1.278 +    };
   1.279 +
   1.280 +    /**
   1.281 +     * Returns the list of capabilities this content node supports. This is a
   1.282 +     * bitmask consisting of flags from the Capabilities enum.
   1.283 +     *
   1.284 +     * The default implementation supports all types but not
   1.285 +     * eSupportClassID or eAllowPluginSkipChannel
   1.286 +     */
   1.287 +    virtual uint32_t GetCapabilities() const;
   1.288 +
   1.289 +    /**
   1.290 +     * Destroys all loaded documents/plugins and releases references
   1.291 +     */
   1.292 +    void DestroyContent();
   1.293 +
   1.294 +    static void Traverse(nsObjectLoadingContent *tmp,
   1.295 +                         nsCycleCollectionTraversalCallback &cb);
   1.296 +
   1.297 +    void CreateStaticClone(nsObjectLoadingContent* aDest) const;
   1.298 +
   1.299 +    void DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner, bool aDelayedStop,
   1.300 +                      bool aForcedReentry = false);
   1.301 +
   1.302 +    nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
   1.303 +                        nsIContent* aBindingParent,
   1.304 +                        bool aCompileEventHandler);
   1.305 +    void UnbindFromTree(bool aDeep = true,
   1.306 +                        bool aNullParent = true);
   1.307 +
   1.308 +  private:
   1.309 +
   1.310 +    // Object parameter changes returned by UpdateObjectParameters
   1.311 +    enum ParameterUpdateFlags {
   1.312 +      eParamNoChange           = 0,
   1.313 +      // Parameters that potentially affect the channel changed
   1.314 +      // - mOriginalURI, mOriginalContentType
   1.315 +      eParamChannelChanged     = 1u << 0,
   1.316 +      // Parameters that affect displayed content changed
   1.317 +      // - mURI, mContentType, mType, mBaseURI
   1.318 +      eParamStateChanged       = 1u << 1,
   1.319 +      // The effective content type changed, independant of object type. This
   1.320 +      // can happen when changing from Loading -> Final type, but doesn't
   1.321 +      // necessarily happen when changing between object types. E.g., if a PDF
   1.322 +      // handler was installed between the last load of this object and now, we
   1.323 +      // might change from eType_Document -> eType_Plugin without changing
   1.324 +      // ContentType
   1.325 +      eParamContentTypeChanged = 1u << 2
   1.326 +    };
   1.327 +
   1.328 +    /**
   1.329 +     * Loads fallback content with the specified FallbackType
   1.330 +     *
   1.331 +     * @param aType   FallbackType value for type of fallback we're loading
   1.332 +     * @param aNotify Send notifications and events. If false, caller is
   1.333 +     *                responsible for doing so
   1.334 +     */
   1.335 +    void LoadFallback(FallbackType aType, bool aNotify);
   1.336 +
   1.337 +    /**
   1.338 +     * Internal version of LoadObject that should only be used by this class
   1.339 +     * aLoadingChannel is passed by the LoadObject call from OnStartRequest,
   1.340 +     * primarily for sanity-preservation
   1.341 +     */
   1.342 +    nsresult LoadObject(bool aNotify,
   1.343 +                        bool aForceLoad,
   1.344 +                        nsIRequest *aLoadingChannel);
   1.345 +
   1.346 +    /**
   1.347 +     * Introspects the object and sets the following member variables:
   1.348 +     * - mOriginalContentType : This is the type attribute on the element
   1.349 +     * - mOriginalURI         : The src or data attribute on the element
   1.350 +     * - mURI                 : The final URI, considering mChannel if
   1.351 +     *                          mChannelLoaded is set
   1.352 +     * - mContentType         : The final content type, considering mChannel if
   1.353 +     *                          mChannelLoaded is set
   1.354 +     * - mBaseURI             : The object's base URI, which may be set by the
   1.355 +     *                          object (codebase attribute)
   1.356 +     * - mType                : The type the object is determined to be based
   1.357 +     *                          on the above
   1.358 +     * 
   1.359 +     * NOTE The class assumes that mType is the currently loaded type at various
   1.360 +     *      points, so the caller of this function must take the appropriate
   1.361 +     *      actions to ensure this
   1.362 +     * 
   1.363 +     * NOTE This function does not perform security checks, only determining the
   1.364 +     *      requested type and parameters of the object.
   1.365 +     *
   1.366 +     * @param aJavaURI Specify that the URI will be consumed by java, which
   1.367 +     *                 changes codebase parsing and URI construction. Used
   1.368 +     *                 internally.
   1.369 +     *
   1.370 +     * @return Returns a bitmask of ParameterUpdateFlags values
   1.371 +     */
   1.372 +    ParameterUpdateFlags UpdateObjectParameters(bool aJavaURI = false);
   1.373 +
   1.374 +    /**
   1.375 +     * Queue a CheckPluginStopEvent and track it in mPendingCheckPluginStopEvent
   1.376 +     */
   1.377 +    void QueueCheckPluginStopEvent();
   1.378 +
   1.379 +    void NotifyContentObjectWrapper();
   1.380 +
   1.381 +    /**
   1.382 +     * Opens the channel pointed to by mURI into mChannel.
   1.383 +     */
   1.384 +    nsresult OpenChannel();
   1.385 +
   1.386 +    /**
   1.387 +     * Closes and releases references to mChannel and, if opened, mFinalListener
   1.388 +     */
   1.389 +    nsresult CloseChannel();
   1.390 +
   1.391 +    /**
   1.392 +     * If this object is allowed to play plugin content, or if it would display
   1.393 +     * click-to-play instead.
   1.394 +     * NOTE that this does not actually check if the object is a loadable plugin
   1.395 +     * NOTE This ignores the current activated state. The caller should check this if appropriate.
   1.396 +     */
   1.397 +    bool ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentType);
   1.398 +
   1.399 +    /*
   1.400 +     * Helper to check if mBaseURI can be used by java as a codebase
   1.401 +     */
   1.402 +    bool CheckJavaCodebase();
   1.403 +
   1.404 +    /**
   1.405 +     * Helper to check if our current URI passes policy
   1.406 +     *
   1.407 +     * @param aContentPolicy [out] The result of the content policy decision
   1.408 +     *
   1.409 +     * @return true if call succeeded and NS_CP_ACCEPTED(*aContentPolicy)
   1.410 +     */
   1.411 +    bool CheckLoadPolicy(int16_t *aContentPolicy);
   1.412 +
   1.413 +    /**
   1.414 +     * Helper to check if the object passes process policy. Assumes we have a
   1.415 +     * final determined type.
   1.416 +     *
   1.417 +     * @param aContentPolicy [out] The result of the content policy decision
   1.418 +     *
   1.419 +     * @return true if call succeeded and NS_CP_ACCEPTED(*aContentPolicy)
   1.420 +     */
   1.421 +    bool CheckProcessPolicy(int16_t *aContentPolicy);
   1.422 +
   1.423 +    /**
   1.424 +     * Checks whether the given type is a supported document type
   1.425 +     *
   1.426 +     * NOTE Does not take content policy or capabilities into account
   1.427 +     */
   1.428 +    bool IsSupportedDocument(const nsCString& aType);
   1.429 +
   1.430 +    /**
   1.431 +     * Gets the plugin instance and creates a plugin stream listener, assigning
   1.432 +     * it to mFinalListener
   1.433 +     */
   1.434 +    bool MakePluginListener();
   1.435 +
   1.436 +    /**
   1.437 +     * Unloads all content and resets the object to a completely unloaded state
   1.438 +     *
   1.439 +     * NOTE Calls StopPluginInstance() and may spin the event loop
   1.440 +     *
   1.441 +     * @param aResetState Reset the object type to 'loading' and destroy channel
   1.442 +     *                    as well
   1.443 +     */
   1.444 +    void UnloadObject(bool aResetState = true);
   1.445 +
   1.446 +    /**
   1.447 +     * Notifies document observes about a new type/state of this object.
   1.448 +     * Triggers frame construction as needed. mType must be set correctly when
   1.449 +     * this method is called. This method is cheap if the type and state didn't
   1.450 +     * actually change.
   1.451 +     *
   1.452 +     * @param aSync If a synchronous frame construction is required. If false,
   1.453 +     *              the construction may either be sync or async.
   1.454 +     * @param aNotify if false, only need to update the state of our element.
   1.455 +     */
   1.456 +    void NotifyStateChanged(ObjectType aOldType,
   1.457 +                            mozilla::EventStates aOldState,
   1.458 +                            bool aSync, bool aNotify);
   1.459 +
   1.460 +    /**
   1.461 +     * Returns a ObjectType value corresponding to the type of content we would
   1.462 +     * support the given MIME type as, taking capabilities and plugin state
   1.463 +     * into account
   1.464 +     * 
   1.465 +     * NOTE this does not consider whether the content would be suppressed by
   1.466 +     *      click-to-play or other content policy checks
   1.467 +     */
   1.468 +    ObjectType GetTypeOfContent(const nsCString& aMIMEType);
   1.469 +
   1.470 +    /**
   1.471 +     * Gets the frame that's associated with this content node.
   1.472 +     * Does not flush.
   1.473 +     */
   1.474 +    nsObjectFrame* GetExistingFrame();
   1.475 +
   1.476 +    // Helper class for SetupProtoChain
   1.477 +    class SetupProtoChainRunner MOZ_FINAL : public nsIRunnable
   1.478 +    {
   1.479 +    public:
   1.480 +      NS_DECL_ISUPPORTS
   1.481 +
   1.482 +      SetupProtoChainRunner(nsIScriptContext* scriptContext,
   1.483 +                            nsObjectLoadingContent* aContent);
   1.484 +
   1.485 +      NS_IMETHOD Run() MOZ_OVERRIDE;
   1.486 +
   1.487 +    private:
   1.488 +      nsCOMPtr<nsIScriptContext> mContext;
   1.489 +      // We store an nsIObjectLoadingContent because we can
   1.490 +      // unambiguously refcount that.
   1.491 +      nsRefPtr<nsIObjectLoadingContent> mContent;
   1.492 +    };
   1.493 +
   1.494 +    // Utility getter for getting our nsNPAPIPluginInstance in a safe way.
   1.495 +    nsresult ScriptRequestPluginInstance(JSContext* aCx,
   1.496 +                                         nsNPAPIPluginInstance** aResult);
   1.497 +
   1.498 +    // Utility method for getting our plugin JSObject
   1.499 +    static nsresult GetPluginJSObject(JSContext *cx,
   1.500 +                                      JS::Handle<JSObject*> obj,
   1.501 +                                      nsNPAPIPluginInstance *plugin_inst,
   1.502 +                                      JS::MutableHandle<JSObject*> plugin_obj,
   1.503 +                                      JS::MutableHandle<JSObject*> plugin_proto);
   1.504 +
   1.505 +    // The final listener for mChannel (uriloader, pluginstreamlistener, etc.)
   1.506 +    nsCOMPtr<nsIStreamListener> mFinalListener;
   1.507 +
   1.508 +    // Frame loader, for content documents we load.
   1.509 +    nsRefPtr<nsFrameLoader>     mFrameLoader;
   1.510 +
   1.511 +    // Track if we have a pending AsyncInstantiateEvent
   1.512 +    nsCOMPtr<nsIRunnable>       mPendingInstantiateEvent;
   1.513 +
   1.514 +    // Tracks if we have a pending CheckPluginStopEvent
   1.515 +    nsCOMPtr<nsIRunnable>       mPendingCheckPluginStopEvent;
   1.516 +
   1.517 +    // The content type of our current load target, updated by
   1.518 +    // UpdateObjectParameters(). Takes the channel's type into account once
   1.519 +    // opened.
   1.520 +    //
   1.521 +    // May change if a channel is opened, does not imply a loaded state
   1.522 +    nsCString                   mContentType;
   1.523 +
   1.524 +    // The content type 'hint' provided by the element's type attribute. May
   1.525 +    // or may not be used as a final type
   1.526 +    nsCString                   mOriginalContentType;
   1.527 +
   1.528 +    // The channel that's currently being loaded. If set, but mChannelLoaded is
   1.529 +    // false, has not yet reached OnStartRequest
   1.530 +    nsCOMPtr<nsIChannel>        mChannel;
   1.531 +
   1.532 +    // The URI of the current content.
   1.533 +    // May change as we open channels and encounter redirects - does not imply
   1.534 +    // a loaded type
   1.535 +    nsCOMPtr<nsIURI>            mURI;
   1.536 +
   1.537 +    // The original URI obtained from inspecting the element (codebase, and
   1.538 +    // src/data). May differ from mURI due to redirects
   1.539 +    nsCOMPtr<nsIURI>            mOriginalURI;
   1.540 +
   1.541 +    // The baseURI used for constructing mURI, and used by some plugins (java)
   1.542 +    // as a root for other resource requests.
   1.543 +    nsCOMPtr<nsIURI>            mBaseURI;
   1.544 +
   1.545 +
   1.546 +
   1.547 +    // Type of the currently-loaded content.
   1.548 +    ObjectType                  mType           : 8;
   1.549 +    // The type of fallback content we're showing (see ObjectState())
   1.550 +    FallbackType                mFallbackType : 8;
   1.551 +
   1.552 +    // If true, we have opened a channel as the listener and it has reached
   1.553 +    // OnStartRequest. Does not get set for channels that are passed directly to
   1.554 +    // the plugin listener.
   1.555 +    bool                        mChannelLoaded    : 1;
   1.556 +
   1.557 +    // Whether we are about to call instantiate on our frame. If we aren't,
   1.558 +    // SetFrame needs to asynchronously call Instantiate.
   1.559 +    bool                        mInstantiating : 1;
   1.560 +
   1.561 +    // True when the object is created for an element which the parser has
   1.562 +    // created using NS_FROM_PARSER_NETWORK flag. If the element is modified,
   1.563 +    // it may lose the flag.
   1.564 +    bool                        mNetworkCreated : 1;
   1.565 +
   1.566 +    // Used to keep track of whether or not a plugin has been explicitly
   1.567 +    // activated by PlayPlugin(). (see ShouldPlay())
   1.568 +    bool                        mActivated : 1;
   1.569 +
   1.570 +    // Used to keep track of whether or not a plugin is blocked by play-preview.
   1.571 +    bool                        mPlayPreviewCanceled : 1;
   1.572 +
   1.573 +    // Protects DoStopPlugin from reentry (bug 724781).
   1.574 +    bool                        mIsStopping : 1;
   1.575 +
   1.576 +    // Protects LoadObject from re-entry
   1.577 +    bool                        mIsLoading : 1;
   1.578 +
   1.579 +    // For plugin stand-in types (click-to-play, play preview, ...) tracks
   1.580 +    // whether content js has tried to access the plugin script object.
   1.581 +    bool                        mScriptRequested : 1;
   1.582 +
   1.583 +    nsWeakFrame                 mPrintFrame;
   1.584 +
   1.585 +    nsRefPtr<nsPluginInstanceOwner> mInstanceOwner;
   1.586 +};
   1.587 +
   1.588 +#endif

mercurial