Bug 883404 - Add a object.reload() call for chrome to de-activate plugins. r=josh
authorJohn Schoenick <jschoenick@mozilla.com>
Tue, 18 Jun 2013 14:35:26 -0700
changeset 154210 f9cbcd8206a056c50845c5a751e240d3b2840396
parent 154209 044c3c08e2c65c2857fae91c56c3dd592d197e29
child 154211 141085686227c2a51f35a39f0a55ae7d312e6cca
push id25628
push usercbook@mozilla.com
push dateSat, 09 Nov 2013 08:03:33 +0000
treeherdermozilla-central@a39a26962730 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs883404
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 883404 - Add a object.reload() call for chrome to de-activate plugins. r=josh
content/base/public/nsIObjectLoadingContent.idl
content/base/src/nsObjectLoadingContent.cpp
content/base/src/nsObjectLoadingContent.h
dom/webidl/HTMLObjectElement.webidl
--- a/content/base/public/nsIObjectLoadingContent.idl
+++ b/content/base/public/nsIObjectLoadingContent.idl
@@ -20,17 +20,17 @@ class nsNPAPIPluginInstance;
 
 /**
  * This interface represents a content node that loads objects.
  *
  * Please make sure to update the MozObjectLoadingContent WebIDL
  * interface to mirror this interface when changing it.
  */
 
-[scriptable, uuid(070bfc7f-f8b8-4e84-aa31-a0bfaffa8e8e)]
+[scriptable, uuid(16c14177-52eb-49d3-9842-a1a0b92be11a)]
 interface nsIObjectLoadingContent : nsISupports
 {
   /**
    * See notes in nsObjectLoadingContent.h
    */
   const unsigned long TYPE_LOADING  = 0;
   const unsigned long TYPE_IMAGE    = 1;
   const unsigned long TYPE_PLUGIN   = 2;
@@ -129,16 +129,24 @@ interface nsIObjectLoadingContent : nsIS
 
   /**
    * This method will play a plugin that has been stopped by the
    * click-to-play plugins or play-preview features.
    */
   void playPlugin();
 
   /**
+   * Forces a re-evaluation and reload of the tag, optionally invalidating its
+   * click-to-play state.  This can be used when the MIME type that provides a
+   * type has changed, for instance, to force the tag to re-evalulate the
+   * handler to use.
+   */
+  void reload(in boolean aClearActivation);
+
+  /**
    * This attribute will return true if the current content type has been
    * activated, either explicitly or by passing checks that would have it be
    * click-to-play or play-preview.
    */
   readonly attribute boolean activated;
 
   [noscript] void stopPluginInstance();
 
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -2890,16 +2890,27 @@ nsObjectLoadingContent::PlayPlugin()
   if (mType == eType_Null && mFallbackType >= eFallbackClickToPlay) {
     return LoadObject(true, true);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsObjectLoadingContent::Reload(bool aClearActivation)
+{
+  if (aClearActivation) {
+    mActivated = false;
+    mPlayPreviewCanceled = false;
+  }
+
+  return LoadObject(true, true);
+}
+
+NS_IMETHODIMP
 nsObjectLoadingContent::GetActivated(bool *aActivated)
 {
   *aActivated = Activated();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsObjectLoadingContent::GetPluginFallbackType(uint32_t* aPluginFallbackType)
--- a/content/base/src/nsObjectLoadingContent.h
+++ b/content/base/src/nsObjectLoadingContent.h
@@ -174,16 +174,20 @@ class nsObjectLoadingContent : public ns
     uint32_t GetContentTypeForMIMEType(const nsAString& aMIMEType)
     {
       return GetTypeOfContent(NS_ConvertUTF16toUTF8(aMIMEType));
     }
     void PlayPlugin(mozilla::ErrorResult& aRv)
     {
       aRv = PlayPlugin();
     }
+    void Reload(bool aClearActivation, mozilla::ErrorResult& aRv)
+    {
+      aRv = Reload(aClearActivation);
+    }
     bool Activated() const
     {
       return mActivated;
     }
     nsIURI* GetSrcURI() const
     {
       return mURI;
     }
--- a/dom/webidl/HTMLObjectElement.webidl
+++ b/dom/webidl/HTMLObjectElement.webidl
@@ -158,16 +158,25 @@ interface MozObjectLoadingContent {
   /**
    * This method will play a plugin that has been stopped by the
    * click-to-play plugins or play-preview features.
    */
   [ChromeOnly, Throws]
   void playPlugin();
 
   /**
+   * Forces a re-evaluation and reload of the tag, optionally invalidating its
+   * click-to-play state.  This can be used when the MIME type that provides a
+   * type has changed, for instance, to force the tag to re-evalulate the
+   * handler to use.
+   */
+  [ChromeOnly, Throws]
+  void reload(boolean aClearActivation);
+
+  /**
    * This attribute will return true if the current content type has been
    * activated, either explicitly or by passing checks that would have it be
    * click-to-play or play-preview.
    */
   [ChromeOnly]
   readonly attribute boolean activated;
 
   /**