Bug 606641: Cleanup for plugin initialization. r=bz
authorJosh Aas <joshmoz@gmail.com>
Thu, 28 Apr 2011 16:08:33 -0400
changeset 68734 e9dafe775b3187b130a838e841167d028fe53a93
parent 68733 befee55969f3174cc2a8f541937f6cce7208ebe9
child 68735 8adc01e9141cbb2280c22b34dadc07701201d834
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs606641
milestone6.0a1
Bug 606641: Cleanup for plugin initialization. r=bz
layout/generic/nsObjectFrame.cpp
layout/generic/nsObjectFrame.h
modules/plugin/base/public/nsIPluginHost.idl
modules/plugin/base/src/nsPluginHost.cpp
modules/plugin/base/src/nsPluginHost.h
modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -71,17 +71,17 @@ enum { XKeyPress = KeyPress };
 #include "nsCOMPtr.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsWidgetsCID.h"
 #include "nsIView.h"
 #include "nsIViewManager.h"
 #include "nsIDOMKeyListener.h"
 #include "nsIDOMDragEvent.h"
-#include "nsIPluginHost.h"
+#include "nsPluginHost.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "prmem.h"
 #include "nsGkAtoms.h"
 #include "nsIAppShell.h"
 #include "nsIDocument.h"
 #include "nsINodeInfo.h"
 #include "nsIURL.h"
@@ -1086,17 +1086,17 @@ nsObjectFrame::ReflowFinished()
 
 void
 nsObjectFrame::ReflowCallbackCanceled()
 {
   mReflowCallbackPosted = PR_FALSE;
 }
 
 nsresult
-nsObjectFrame::InstantiatePlugin(nsIPluginHost* aPluginHost, 
+nsObjectFrame::InstantiatePlugin(nsPluginHost* aPluginHost, 
                                  const char* aMimeType,
                                  nsIURI* aURI)
 {
   NS_ASSERTION(mPreventInstantiation,
                "Instantiation should be prevented here!");
 
   // If you add early return(s), be sure to balance this call to
   // appShell->SuspendNative() with additional call(s) to
@@ -1117,18 +1117,17 @@ nsObjectFrame::InstantiatePlugin(nsIPlug
 
   nsresult rv;
   if (fullPageMode) {  /* full-page mode */
     nsCOMPtr<nsIStreamListener> stream;
     rv = aPluginHost->InstantiateFullPagePlugin(aMimeType, aURI, mInstanceOwner, getter_AddRefs(stream));
     if (NS_SUCCEEDED(rv))
       pDoc->SetStreamListener(stream);
   } else {   /* embedded mode */
-    rv = aPluginHost->InstantiateEmbeddedPlugin(aMimeType, aURI,
-                                                mInstanceOwner);
+    rv = aPluginHost->InstantiateEmbeddedPlugin(aMimeType, aURI, mInstanceOwner, PR_TRUE);
   }
 
   // Note that |this| may very well be destroyed already!
 
   if (appShell) {
     appShell->ResumeNative();
   }
 
@@ -2711,17 +2710,17 @@ nsObjectFrame::Instantiate(const char* a
   nsCOMPtr<nsIPluginHost> pluginHost(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &rv));
   if (NS_FAILED(rv))
     return rv;
   mInstanceOwner->SetPluginHost(pluginHost);
 
   NS_ASSERTION(!mPreventInstantiation, "Say what?");
   mPreventInstantiation = PR_TRUE;
 
-  rv = InstantiatePlugin(pluginHost, aMimeType, aURI);
+  rv = InstantiatePlugin(static_cast<nsPluginHost*>(pluginHost.get()), aMimeType, aURI);
 
   if (!weakFrame.IsAlive()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // finish up
   if (NS_SUCCEEDED(rv)) {
     TryNotifyContentObjectWrapper();
--- a/layout/generic/nsObjectFrame.h
+++ b/layout/generic/nsObjectFrame.h
@@ -52,17 +52,17 @@
 #include "Layers.h"
 #include "ImageLayers.h"
 
 #ifdef ACCESSIBILITY
 class nsIAccessible;
 #endif
 
 class nsPluginInstanceOwner;
-class nsIPluginHost;
+class nsPluginHost;
 class nsIPluginInstance;
 class nsPresContext;
 class nsDisplayPlugin;
 class nsIDOMElement;
 class nsIOSurface;
 class PluginBackgroundSink;
 
 #define nsObjectFrameSuper nsFrame
@@ -215,17 +215,17 @@ protected:
   virtual ~nsObjectFrame();
 
   // NOTE:  This frame class does not inherit from |nsLeafFrame|, so
   // this is not a virtual method implementation.
   void GetDesiredSize(nsPresContext* aPresContext,
                       const nsHTMLReflowState& aReflowState,
                       nsHTMLReflowMetrics& aDesiredSize);
 
-  nsresult InstantiatePlugin(nsIPluginHost* aPluginHost, 
+  nsresult InstantiatePlugin(nsPluginHost* aPluginHost, 
                              const char* aMimetype,
                              nsIURI* aURL);
 
   /**
    * Adjust the plugin's idea of its size, using aSize as its new size.
    * (aSize must be in twips)
    */
   void FixupWindow(const nsSize& aSize);
--- a/modules/plugin/base/public/nsIPluginHost.idl
+++ b/modules/plugin/base/public/nsIPluginHost.idl
@@ -59,17 +59,17 @@ interface nsIPlugin;
 interface nsIURI;
 interface nsIDOMPlugin;
 interface nsIChannel;
 interface nsIPluginStreamListener;
 
 [ptr] native PRLibraryPtr(PRLibrary);
 [ptr] native nsPluginNativeWindowPtr(nsPluginNativeWindow);
 
-[scriptable, uuid(C198DEAA-3F93-482D-A47C-85FF6514FE07)]
+[scriptable, uuid(0BB66261-4114-4D73-8DFC-C3CA997E6817)]
 interface nsIPluginHost : nsISupports
 {
   [noscript] void init();
 
   [noscript] void destroy();
 
   [noscript] void loadPlugins();
 
@@ -79,23 +79,16 @@ interface nsIPluginHost : nsISupports
    *
    * @param reloadPages - indicates whether currently visible pages should 
    * also be reloaded
    */
   void reloadPlugins(in boolean reloadPages);
 
   [noscript] nsIPlugin getPlugin(in string aMimeType);
 
-  [noscript] void instantiateEmbeddedPlugin(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner);
-
-  [noscript] void instantiateFullPagePlugin(in string aMimeType,
-                                            in nsIURI aURI,
-                                            in nsIPluginInstanceOwner aOwner,
-                                            out nsIStreamListener aStreamListener);
-
   /**
    * Instantiate an embedded plugin for an existing channel. The caller is
    * responsible for opening the channel. It may or may not be already opened
    * when this function is called.
    */
   [noscript] nsIStreamListener instantiatePluginForChannel(in nsIChannel aChannel, in nsIPluginInstanceOwner aOwner);
 
   [noscript] void setUpPluginInstance(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner);
--- a/modules/plugin/base/src/nsPluginHost.cpp
+++ b/modules/plugin/base/src/nsPluginHost.cpp
@@ -960,28 +960,20 @@ NS_IMETHODIMP nsPluginHost::InstantiateP
 
   // Note that we're not setting up a plugin instance here; the stream
   // listener's OnStartRequest will handle doing that, looking for
   // stopped plugins, etc, etc.
 
   return NewEmbeddedPluginStreamListener(uri, aOwner, nsnull, aListener);
 }
 
-// Called by nsPluginInstanceOwner
-NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
-                                                      nsIURI* aURL,
-                                                      nsIPluginInstanceOwner *aOwner)
-{
-  return DoInstantiateEmbeddedPlugin(aMimeType, aURL, aOwner, PR_TRUE);
-}
-
 nsresult
-nsPluginHost::DoInstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
-                                          nsIPluginInstanceOwner* aOwner,
-                                          PRBool aAllowOpeningStreams)
+nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
+                                        nsIPluginInstanceOwner* aOwner,
+                                        PRBool aAllowOpeningStreams)
 {
   NS_ENSURE_ARG_POINTER(aOwner);
 
 #ifdef PLUGIN_LOGGING
   nsCAutoString urlSpec;
   if (aURL)
     aURL->GetAsciiSpec(urlSpec);
 
@@ -1134,21 +1126,20 @@ nsPluginHost::DoInstantiateEmbeddedPlugi
         aMimeType, rv, aOwner, urlSpec2.get()));
 
   PR_LogFlush();
 #endif
 
   return rv;
 }
 
-// Called by full-page case
-NS_IMETHODIMP nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
-                                                      nsIURI* aURI,
-                                                      nsIPluginInstanceOwner *aOwner,
-                                                      nsIStreamListener **aStreamListener)
+nsresult nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
+                                                 nsIURI* aURI,
+                                                 nsIPluginInstanceOwner *aOwner,
+                                                 nsIStreamListener **aStreamListener)
 {
 #ifdef PLUGIN_LOGGING
   nsCAutoString urlSpec;
   aURI->GetSpec(urlSpec);
   PLUGIN_LOG(PLUGIN_LOG_NORMAL,
   ("nsPluginHost::InstantiateFullPagePlugin Begin mime=%s, owner=%p, url=%s\n",
   aMimeType, aOwner, urlSpec.get()));
 #endif
--- a/modules/plugin/base/src/nsPluginHost.h
+++ b/modules/plugin/base/src/nsPluginHost.h
@@ -159,22 +159,26 @@ public:
 
   nsTArray< nsRefPtr<nsNPAPIPluginInstance> > *InstanceArray();
 
   void DestroyRunningInstances(nsISupportsArray* aReloadDocs, nsPluginTag* aPluginTag);
 
   // Return the tag for |aLibrary| if found, nsnull if not.
   nsPluginTag* FindTagForLibrary(PRLibrary* aLibrary);
 
-  // The guts of InstantiateEmbeddedPlugin.  The last argument should
-  // be false if we already have an in-flight stream and don't need to
-  // set up a new stream.
-  nsresult DoInstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
-                                       nsIPluginInstanceOwner* aOwner,
-                                       PRBool aAllowOpeningStreams);
+  // The last argument should be false if we already have an in-flight stream
+  // and don't need to set up a new stream.
+  nsresult InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
+                                     nsIPluginInstanceOwner* aOwner,
+                                     PRBool aAllowOpeningStreams);
+
+  nsresult InstantiateFullPagePlugin(const char *aMimeType,
+                                     nsIURI* aURI,
+                                     nsIPluginInstanceOwner *aOwner,
+                                     nsIStreamListener **aStreamListener);
 
   // Does not accept NULL and should never fail.
   nsPluginTag* TagForPlugin(nsNPAPIPlugin* aPlugin);
 
 private:
   nsresult
   TrySetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner);
 
--- a/modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
+++ b/modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
@@ -653,18 +653,18 @@ nsPluginStreamListenerPeer::OnStartReque
       
       // determine if we need to try embedded again. FullPage takes a different code path
       PRInt32 mode;
       mOwner->GetMode(&mode);
       if (mode == NP_EMBED) {
         // Make sure to not allow new streams to be opened here; we've
         // already got a stream for this data; we just need a properly
         // set up plugin instance.
-        rv = pluginHost->DoInstantiateEmbeddedPlugin(aContentType.get(), aURL,
-                                                     mOwner, PR_FALSE);
+        rv = pluginHost->InstantiateEmbeddedPlugin(aContentType.get(), aURL,
+                                                   mOwner, PR_FALSE);
       }
       else {
         rv = pluginHost->SetUpPluginInstance(aContentType.get(), aURL, mOwner);
       }
       
       if (NS_OK == rv) {
         mOwner->GetInstance(getter_AddRefs(pluginInstCOMPtr));
         mPluginInstance = static_cast<nsNPAPIPluginInstance*>(pluginInstCOMPtr.get());